btrfs: use btrfs_get_fs_generation() at try_release_extent_mapping()
authorFilipe Manana <fdmanana@suse.com>
Tue, 16 Apr 2024 14:13:03 +0000 (15:13 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 May 2024 19:31:07 +0000 (21:31 +0200)
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.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c

index 6438c3e74756f8aedb6ab18a0832c965d8fbfd5b..f689c53553e3443dd2a102b57b8a14df8ccfea0c 100644 (file)
@@ -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: