linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: fdmanana@kernel.org
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 24/24] btrfs: simplify exit paths of btrfs_evict_inode()
Date: Tue, 21 Mar 2023 11:14:00 +0000	[thread overview]
Message-ID: <b831b63a2d19c77f520898f0a0ead203670aa538.1679326435.git.fdmanana@suse.com> (raw)
In-Reply-To: <cover.1679326426.git.fdmanana@suse.com>

From: Filipe Manana <fdmanana@suse.com>

Instead of using two labels at btrfs_evict_inode() for exiting depending
on whether we need to delete the inode items and orphan or some error
happened, we can use a single exit label if we initialize the block
reserve to NULL, since btrfs_free_block_rsv() ignores a NULL block reserve
pointer. So just do that. It will also make an upcoming change simpler by
avoiding one extra error label.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/inode.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0b3710d47dd0..865d56ff2ce1 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5271,7 +5271,7 @@ void btrfs_evict_inode(struct inode *inode)
 	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
 	struct btrfs_trans_handle *trans;
 	struct btrfs_root *root = BTRFS_I(inode)->root;
-	struct btrfs_block_rsv *rsv;
+	struct btrfs_block_rsv *rsv = NULL;
 	int ret;
 
 	trace_btrfs_inode_evict(inode);
@@ -5288,18 +5288,18 @@ void btrfs_evict_inode(struct inode *inode)
 	    ((btrfs_root_refs(&root->root_item) != 0 &&
 	      root->root_key.objectid != BTRFS_ROOT_TREE_OBJECTID) ||
 	     btrfs_is_free_space_inode(BTRFS_I(inode))))
-		goto no_delete;
+		goto out;
 
 	if (is_bad_inode(inode))
-		goto no_delete;
+		goto out;
 
 	if (test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags))
-		goto no_delete;
+		goto out;
 
 	if (inode->i_nlink > 0) {
 		BUG_ON(btrfs_root_refs(&root->root_item) != 0 &&
 		       root->root_key.objectid != BTRFS_ROOT_TREE_OBJECTID);
-		goto no_delete;
+		goto out;
 	}
 
 	/*
@@ -5308,7 +5308,7 @@ void btrfs_evict_inode(struct inode *inode)
 	 */
 	ret = btrfs_commit_inode_delayed_inode(BTRFS_I(inode));
 	if (ret)
-		goto no_delete;
+		goto out;
 
 	/*
 	 * This drops any pending insert or delete operations we have for this
@@ -5320,7 +5320,7 @@ void btrfs_evict_inode(struct inode *inode)
 
 	rsv = btrfs_alloc_block_rsv(fs_info, BTRFS_BLOCK_RSV_TEMP);
 	if (!rsv)
-		goto no_delete;
+		goto out;
 	rsv->size = btrfs_calc_metadata_size(fs_info, 1);
 	rsv->failfast = true;
 
@@ -5336,7 +5336,7 @@ void btrfs_evict_inode(struct inode *inode)
 
 		trans = evict_refill_and_join(root, rsv);
 		if (IS_ERR(trans))
-			goto free_rsv;
+			goto out;
 
 		trans->block_rsv = rsv;
 
@@ -5350,7 +5350,7 @@ void btrfs_evict_inode(struct inode *inode)
 		 */
 		btrfs_btree_balance_dirty_nodelay(fs_info);
 		if (ret && ret != -ENOSPC && ret != -EAGAIN)
-			goto free_rsv;
+			goto out;
 		else if (!ret)
 			break;
 	}
@@ -5372,9 +5372,8 @@ void btrfs_evict_inode(struct inode *inode)
 		btrfs_end_transaction(trans);
 	}
 
-free_rsv:
+out:
 	btrfs_free_block_rsv(fs_info, rsv);
-no_delete:
 	/*
 	 * If we didn't successfully delete, the orphan item will still be in
 	 * the tree and we'll retry on the next mount. Again, we might also want
-- 
2.34.1


  parent reply	other threads:[~2023-03-21 11:15 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21 11:13 [PATCH 00/24] btrfs: cleanups and small fixes mostly around block reserves fdmanana
2023-03-21 11:13 ` [PATCH 01/24] btrfs: pass a bool to btrfs_block_rsv_migrate() at evict_refill_and_join() fdmanana
2023-03-21 11:40   ` Anand Jain
2023-03-21 12:18   ` Johannes Thumshirn
2023-03-21 11:13 ` [PATCH 02/24] btrfs: pass a bool size update argument to btrfs_block_rsv_add_bytes() fdmanana
2023-03-21 11:43   ` Anand Jain
2023-03-21 12:18   ` Johannes Thumshirn
2023-03-21 11:13 ` [PATCH 03/24] btrfs: remove check for NULL block reserve at btrfs_block_rsv_check() fdmanana
2023-03-21 11:48   ` Anand Jain
2023-03-21 11:54   ` Anand Jain
2023-03-21 12:19   ` Johannes Thumshirn
2023-03-21 11:13 ` [PATCH 04/24] btrfs: update documentation for BTRFS_RESERVE_FLUSH_EVICT flush method fdmanana
2023-03-21 12:19   ` Johannes Thumshirn
2023-03-21 11:13 ` [PATCH 05/24] btrfs: update flush method assertion when reserving space fdmanana
2023-03-21 11:13 ` [PATCH 06/24] btrfs: initialize ret to -ENOSPC at __reserve_bytes() fdmanana
2023-03-21 12:24   ` Johannes Thumshirn
2023-03-21 12:43   ` Anand Jain
2023-03-21 11:13 ` [PATCH 07/24] btrfs: simplify btrfs_should_throttle_delayed_refs() fdmanana
2023-03-21 12:52   ` Anand Jain
2023-03-21 11:13 ` [PATCH 08/24] btrfs: collapse should_end_transaction() into btrfs_should_end_transaction() fdmanana
2023-03-21 13:00   ` Anand Jain
2023-03-21 11:13 ` [PATCH 09/24] btrfs: remove bytes_used argument from btrfs_make_block_group() fdmanana
2023-03-21 13:05   ` Anand Jain
2023-03-21 11:13 ` [PATCH 10/24] btrfs: count extents before taking inode's spinlock when reserving metadata fdmanana
2023-03-21 13:26   ` Anand Jain
2023-03-21 11:13 ` [PATCH 11/24] btrfs: remove redundant counter check at btrfs_truncate_inode_items() fdmanana
2023-03-21 13:31   ` Anand Jain
2023-03-21 11:13 ` [PATCH 12/24] btrfs: simplify btrfs_block_rsv_refill() fdmanana
2023-03-21 13:40   ` Anand Jain
2023-03-21 11:13 ` [PATCH 13/24] btrfs: remove obsolete delayed ref throttling logic when truncating items fdmanana
2023-03-21 11:13 ` [PATCH 14/24] btrfs: don't throttle on delayed items when evicting deleted inode fdmanana
2023-03-21 11:13 ` [PATCH 15/24] btrfs: calculate the right space for a single delayed ref when refilling fdmanana
2023-03-21 13:59   ` Anand Jain
2023-03-21 11:13 ` [PATCH 16/24] btrfs: accurately calculate number of delayed refs when flushing fdmanana
2023-03-21 11:13 ` [PATCH 17/24] btrfs: constify fs_info argument of the metadata size calculation helpers fdmanana
2023-03-21 15:09   ` Anand Jain
2023-03-21 11:13 ` [PATCH 18/24] btrfs: constify fs_info argument for the reclaim items " fdmanana
2023-03-21 14:24   ` Anand Jain
2023-03-21 11:13 ` [PATCH 19/24] btrfs: add helper to calculate space for delayed references fdmanana
2023-03-21 11:13 ` [PATCH 20/24] btrfs: calculate correct amount of space for delayed reference when evicting fdmanana
2023-03-21 11:13 ` [PATCH 21/24] btrfs: fix calculation of the global block reserve's size fdmanana
2023-03-21 11:13 ` [PATCH 22/24] btrfs: use a constant for the number of metadata units needed for an unlink fdmanana
2023-03-21 14:37   ` Anand Jain
2023-03-21 11:13 ` [PATCH 23/24] btrfs: calculate the right space for delayed refs when updating global reserve fdmanana
2023-03-21 11:14 ` fdmanana [this message]
2023-03-22 14:37 ` [PATCH 00/24] btrfs: cleanups and small fixes mostly around block reserves Josef Bacik
2023-03-23 19:35 ` David Sterba

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=b831b63a2d19c77f520898f0a0ead203670aa538.1679326435.git.fdmanana@suse.com \
    --to=fdmanana@kernel.org \
    --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).