linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v1.1 5/5] btrfs: extent_io: Unify the return value of btrfs_clone_extent_buffer() with alloc_extent_buffer()
Date: Fri, 22 Feb 2019 21:02:29 +0800	[thread overview]
Message-ID: <20190222130229.13231-1-wqu@suse.com> (raw)
In-Reply-To: <20190222101645.4403-6-wqu@suse.com>

The direct callers are:
1) qgroup_rescan_leaf()
2) btrfs_compare_trees()
   These two call sites are stubs.

3) tree_mod_log_rewind()
4) get_old_root()
   These two doesn't follow the name pattern *_extent_buffer(), thus we
   don't need to unify their return value.
   However for get_old_root(), all its eb assignment can no longer be
   NULL, change its IS_ERR_OR_NULL() to IS_ERR().

5) btrfs_search_slot_get_root()
   This is a stub. The only caller has already handled the return value.

This patch should cover all the call sites of
btrfs_clone_extent_buffer().

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
changelog
v1.1:
- Add a missing IS_ERR() check for left_path.
---
 fs/btrfs/backref.c   |  8 ++++----
 fs/btrfs/ctree.c     | 16 +++++++++-------
 fs/btrfs/extent_io.c |  4 ++--
 fs/btrfs/qgroup.c    |  5 +++--
 4 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 78556447e1d5..b6e469a12011 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -2016,8 +2016,8 @@ static int iterate_inode_refs(u64 inum, struct btrfs_root *fs_root,
 		parent = found_key.offset;
 		slot = path->slots[0];
 		eb = btrfs_clone_extent_buffer(path->nodes[0]);
-		if (!eb) {
-			ret = -ENOMEM;
+		if (IS_ERR(eb)) {
+			ret = PTR_ERR(eb);
 			break;
 		}
 		btrfs_release_path(path);
@@ -2075,8 +2075,8 @@ static int iterate_inode_extrefs(u64 inum, struct btrfs_root *fs_root,
 
 		slot = path->slots[0];
 		eb = btrfs_clone_extent_buffer(path->nodes[0]);
-		if (!eb) {
-			ret = -ENOMEM;
+		if (IS_ERR(eb)) {
+			ret = PTR_ERR(eb);
 			break;
 		}
 		btrfs_release_path(path);
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 3276b743f40a..ebd640f2ad86 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1384,7 +1384,7 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
 		free_extent_buffer(eb_root);
 	}
 
-	if (IS_ERR_OR_NULL(eb))
+	if (IS_ERR(eb))
 		return NULL;
 	btrfs_tree_read_lock(eb);
 	if (old_root) {
@@ -2624,8 +2624,8 @@ static struct extent_buffer *btrfs_search_slot_get_root(struct btrfs_root *root,
 			down_read(&fs_info->commit_root_sem);
 			b = btrfs_clone_extent_buffer(root->commit_root);
 			up_read(&fs_info->commit_root_sem);
-			if (!b)
-				return ERR_PTR(-ENOMEM);
+			if (IS_ERR(b))
+				return b;
 
 		} else {
 			b = root->commit_root;
@@ -5429,9 +5429,10 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
 	left_root_level = left_level;
 	left_path->nodes[left_level] =
 			btrfs_clone_extent_buffer(left_root->commit_root);
-	if (!left_path->nodes[left_level]) {
+	if (IS_ERR(left_path->nodes[left_level])) {
 		up_read(&fs_info->commit_root_sem);
-		ret = -ENOMEM;
+		ret = PTR_ERR(left_path->nodes[left_level]);
+		left_path->nodes[left_level] = NULL;
 		goto out;
 	}
 
@@ -5439,9 +5440,10 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
 	right_root_level = right_level;
 	right_path->nodes[right_level] =
 			btrfs_clone_extent_buffer(right_root->commit_root);
-	if (!right_path->nodes[right_level]) {
+	if (IS_ERR(right_path->nodes[right_level])) {
 		up_read(&fs_info->commit_root_sem);
-		ret = -ENOMEM;
+		ret = PTR_ERR(right_path->nodes[right_level]);
+		right_path->nodes[right_level] = NULL;
 		goto out;
 	}
 	up_read(&fs_info->commit_root_sem);
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index a19bd8bc3b32..dbdb649f1957 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4713,13 +4713,13 @@ struct extent_buffer *btrfs_clone_extent_buffer(struct extent_buffer *src)
 
 	new = __alloc_extent_buffer(src->fs_info, src->start, src->len);
 	if (IS_ERR(new))
-		return NULL;
+		return new;
 
 	for (i = 0; i < num_pages; i++) {
 		p = alloc_page(GFP_NOFS);
 		if (!p) {
 			btrfs_release_extent_buffer(new);
-			return NULL;
+			return ERR_PTR(-ENOMEM);
 		}
 		attach_extent_buffer_page(new, p);
 		WARN_ON(PageDirty(p));
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 4e473a998219..ccfa992a10bf 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -3105,8 +3105,9 @@ static int qgroup_rescan_leaf(struct btrfs_trans_handle *trans,
 	fs_info->qgroup_rescan_progress.objectid = found.objectid + 1;
 
 	scratch_leaf = btrfs_clone_extent_buffer(path->nodes[0]);
-	if (!scratch_leaf) {
-		ret = -ENOMEM;
+	if (IS_ERR(scratch_leaf)) {
+		ret = PTR_ERR(scratch_leaf);
+		scratch_leaf = NULL;
 		mutex_unlock(&fs_info->qgroup_rescan_lock);
 		goto out;
 	}
-- 
2.20.1


  parent reply	other threads:[~2019-02-22 13:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22 10:16 [PATCH 0/5] Unify the return value of alloc/clone_extent_buffer() Qu Wenruo
2019-02-22 10:16 ` [PATCH 1/5] btrfs: extent_io: Add comment about the return value of alloc_extent_buffer() Qu Wenruo
2019-02-27 13:36   ` David Sterba
2019-02-27 13:41     ` Qu Wenruo
2019-02-27 13:44       ` David Sterba
2019-02-22 10:16 ` [PATCH 2/5] btrfs: extent_io: Unify the return value of __alloc_extent_buffer() with alloc_extent_buffer() Qu Wenruo
2019-02-22 10:16 ` [PATCH 3/5] btrfs: extent_io: Unify the return value of alloc_dummy_extent_buffer() " Qu Wenruo
2019-02-22 10:16 ` [PATCH 4/5] btrfs: extent_io: Unify the return value of alloc_test_extent_buffer() " Qu Wenruo
2019-02-22 10:16 ` [PATCH 5/5] btrfs: extent_io: Unify the return value of btrfs_clone_extent_buffer() " Qu Wenruo
2019-02-22 12:47   ` Nikolay Borisov
2019-02-22 12:53     ` Qu Wenruo
2019-02-22 13:02   ` Qu Wenruo [this message]
2019-02-22 12:54 ` [PATCH 0/5] Unify the return value of alloc/clone_extent_buffer() Nikolay Borisov
2019-02-22 13:02   ` Qu Wenruo
2019-02-22 13:29     ` Nikolay Borisov
2019-02-22 13:31       ` Qu Wenruo
2019-02-27 14:11         ` David Sterba
2019-02-22 13:32       ` Qu Wenruo

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=20190222130229.13231-1-wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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).