public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: remove redundant code
@ 2022-09-23 14:56 Hao Peng
  2022-10-07 16:32 ` David Sterba
  0 siblings, 1 reply; 5+ messages in thread
From: Hao Peng @ 2022-09-23 14:56 UTC (permalink / raw)
  To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com
  Cc: linux-btrfs@vger.kernel.org

From: Peng Hao <flyingpeng@tencent.com>

Since leaf is already NULL, and no other branch will go fail_unlock,
the fail_unlock branch is useless.

Signed-off-by: Peng Hao <flyingpeng@tencent.com>
---
 fs/btrfs/disk-io.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 4c3166f3c725..f39165aec175 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1284,7 +1284,7 @@ struct btrfs_root *btrfs_create_tree(struct
btrfs_trans_handle *trans,
        if (IS_ERR(leaf)) {
                ret = PTR_ERR(leaf);
                leaf = NULL;
-               goto fail_unlock;
+               goto fail;
        }

        root->node = leaf;
@@ -1319,9 +1319,6 @@ struct btrfs_root *btrfs_create_tree(struct
btrfs_trans_handle *trans,

        return root;

-fail_unlock:
-       if (leaf)
-               btrfs_tree_unlock(leaf);
 fail:
        btrfs_put_root(root);

--
2.27.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH]  btrfs: remove redundant code
@ 2022-09-18  7:26 flyingpeng(彭浩)
  0 siblings, 0 replies; 5+ messages in thread
From: flyingpeng(彭浩) @ 2022-09-18  7:26 UTC (permalink / raw)
  To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com
  Cc: linux-btrfs@vger.kernel.org

Since leaf is already NULL, and no other branch will go fail_unlock,
the fail_unlock branch is useless.

Signed-off-by: Peng Hao <flyingpeng@tencent.com>
---
 fs/btrfs/disk-io.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 4c3166f3c725..f39165aec175 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1284,7 +1284,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
        if (IS_ERR(leaf)) {
                ret = PTR_ERR(leaf);
                leaf = NULL;
-               goto fail_unlock;
+               goto fail;
        }

        root->node = leaf;
@@ -1319,9 +1319,6 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,

        return root;

-fail_unlock:
-       if (leaf)
-               btrfs_tree_unlock(leaf);
 fail:
        btrfs_put_root(root);

--
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] btrfs: Remove redundant code
@ 2017-07-12  6:32 Nikolay Borisov
  2017-07-12 14:55 ` David Sterba
  0 siblings, 1 reply; 5+ messages in thread
From: Nikolay Borisov @ 2017-07-12  6:32 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba, Nikolay Borisov

insert_into_bitmap has only one caller which always allocates the info struct
passed. As such remove the any NULL checks for info and also remove code
to allocate info in case it was NULL.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/free-space-cache.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index c5e6180cdb8c..fd24fb99d6dc 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -2101,7 +2101,7 @@ static int insert_into_bitmap(struct btrfs_free_space_ctl *ctl,
 		goto again;
 
 new_bitmap:
-	if (info && info->bitmap) {
+	if (info->bitmap) {
 		add_new_bitmap(ctl, info, offset);
 		added = 1;
 		info = NULL;
@@ -2109,17 +2109,6 @@ static int insert_into_bitmap(struct btrfs_free_space_ctl *ctl,
 	} else {
 		spin_unlock(&ctl->tree_lock);
 
-		/* no pre-allocated info, allocate a new one */
-		if (!info) {
-			info = kmem_cache_zalloc(btrfs_free_space_cachep,
-						 GFP_NOFS);
-			if (!info) {
-				spin_lock(&ctl->tree_lock);
-				ret = -ENOMEM;
-				goto out;
-			}
-		}
-
 		/* allocate the bitmap */
 		info->bitmap = kzalloc(PAGE_SIZE, GFP_NOFS);
 		spin_lock(&ctl->tree_lock);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-07 16:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-23 14:56 [PATCH] btrfs: remove redundant code Hao Peng
2022-10-07 16:32 ` David Sterba
  -- strict thread matches above, loose matches on Subject: below --
2022-09-18  7:26 flyingpeng(彭浩)
2017-07-12  6:32 [PATCH] btrfs: Remove " Nikolay Borisov
2017-07-12 14:55 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox