From: Dan Carpenter <error27@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: Josef Bacik <josef@redhat.com>, Yan Zheng <zheng.yan@oracle.com>,
Jens Axboe <jens.axboe@oracle.com>, Tejun Heo <tj@kernel.org>,
kernel-janitors@vger.kernel.org,
Chris Mason <chris.mason@oracle.com>
Subject: [patch 6/11] btrfs: cleanup btrfs_dec_test_ordered_pending()
Date: Sat, 29 May 2010 11:46:06 +0200 [thread overview]
Message-ID: <20100529094606.GG5483@bicker> (raw)
"ret" was used in a confusing way because instead of returning "ret" we
returned the opposite of ret. I refactored it. Also if ret is non-zero
in the new code then entry is clearly non-null so I removed that check.
Signed-off-by: Dan Carpenter <error27@gmail.com>
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index e56c72b..0a37019 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -270,13 +270,13 @@ int btrfs_dec_test_ordered_pending(struct inode *inode,
spin_lock(&tree->lock);
node = tree_search(tree, file_offset);
if (!node) {
- ret = 1;
+ ret = 0;
goto out;
}
entry = rb_entry(node, struct btrfs_ordered_extent, rb_node);
if (!offset_in_entry(entry, file_offset)) {
- ret = 1;
+ ret = 0;
goto out;
}
@@ -286,17 +286,19 @@ int btrfs_dec_test_ordered_pending(struct inode *inode,
(unsigned long long)io_size);
}
entry->bytes_left -= io_size;
- if (entry->bytes_left == 0)
+ if (entry->bytes_left == 0) {
ret = test_and_set_bit(BTRFS_ORDERED_IO_DONE, &entry->flags);
- else
- ret = 1;
+ ret = !ret;
+ } else {
+ ret = 0;
+ }
out:
- if (!ret && cached && entry) {
+ if (ret && cached) {
*cached = entry;
atomic_inc(&entry->refs);
}
spin_unlock(&tree->lock);
- return ret == 0;
+ return ret;
}
/*
reply other threads:[~2010-05-29 9:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100529094606.GG5483@bicker \
--to=error27@gmail.com \
--cc=chris.mason@oracle.com \
--cc=jens.axboe@oracle.com \
--cc=josef@redhat.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=tj@kernel.org \
--cc=zheng.yan@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).