All of lore.kernel.org
 help / color / mirror / Atom feed
From: fdmanana@kernel.org
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 2/5] btrfs: use btrfs_get_fs_generation() at try_release_extent_mapping()
Date: Wed, 17 Apr 2024 12:03:32 +0100	[thread overview]
Message-ID: <afc9fac7a3b01d7538c43efee19ae3924addd8ad.1713302470.git.fdmanana@suse.com> (raw)
In-Reply-To: <cover.1713302470.git.fdmanana@suse.com>

From: Filipe Manana <fdmanana@suse.com>

Nowadays we have the btrfs_get_fs_generation() to get the current
generation of the filesystem, so there's no need anymore to lock the
transaction spinlock to read it.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/extent_io.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 6438c3e74756..f689c53553e3 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2406,8 +2406,7 @@ int try_release_extent_mapping(struct page *page, gfp_t mask)
 	    page->mapping->host->i_size > SZ_16M) {
 		u64 len;
 		while (start <= end) {
-			struct btrfs_fs_info *fs_info;
-			u64 cur_gen;
+			const u64 cur_gen = btrfs_get_fs_generation(inode->root->fs_info);
 
 			len = end - start + 1;
 			write_lock(&extent_tree->lock);
@@ -2442,10 +2441,6 @@ int try_release_extent_mapping(struct page *page, gfp_t mask)
 			 * Otherwise don't remove it, we could be racing with an
 			 * ongoing fast fsync that could miss the new extent.
 			 */
-			fs_info = inode->root->fs_info;
-			spin_lock(&fs_info->trans_lock);
-			cur_gen = fs_info->generation;
-			spin_unlock(&fs_info->trans_lock);
 			if (em->generation >= cur_gen)
 				goto next;
 remove_em:
-- 
2.43.0


  parent reply	other threads:[~2024-04-17 11:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-17 11:03 [PATCH 0/5] btrfs: cleanups and improvements around extent map release fdmanana
2024-04-17 11:03 ` [PATCH 1/5] btrfs: rename some variables at try_release_extent_mapping() fdmanana
2024-04-17 11:21   ` Johannes Thumshirn
2024-04-17 11:03 ` fdmanana [this message]
2024-04-17 11:22   ` [PATCH 2/5] btrfs: use btrfs_get_fs_generation() " Johannes Thumshirn
2024-04-17 11:03 ` [PATCH 3/5] btrfs: remove i_size restriction " fdmanana
2024-04-17 11:23   ` Johannes Thumshirn
2024-04-17 11:03 ` [PATCH 4/5] btrfs: be better releasing extent maps " fdmanana
2024-04-17 11:28   ` Johannes Thumshirn
2024-04-17 11:03 ` [PATCH 5/5] btrfs: make try_release_extent_mapping() return a bool fdmanana
2024-04-17 11:27   ` Johannes Thumshirn
2024-04-17 21:44 ` [PATCH 0/5] btrfs: cleanups and improvements around extent map release 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=afc9fac7a3b01d7538c43efee19ae3924addd8ad.1713302470.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.