]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: remove leftover EXTENT_UPTODATE clear from an inode's io_tree
authorFilipe Manana <fdmanana@suse.com>
Fri, 28 Mar 2025 11:27:09 +0000 (11:27 +0000)
committerDavid Sterba <dsterba@suse.com>
Thu, 15 May 2025 12:30:39 +0000 (14:30 +0200)
After commit 52b029f42751 ("btrfs: remove unnecessary EXTENT_UPTODATE
state in buffered I/O path") we never set EXTENT_UPTODATE in an inode's
io_tree anymore, but we still have some code attempting to clear that
bit from an inode's io_tree. Remove that code as it doesn't do anything
anymore. The sole use of the EXTENT_UPTODATE bit is for the excluded
extents io_tree (fs_info->excluded_extents), which is used to track the
locations of super blocks, so that their ranges are never marked as free,
making them unavailable for extent allocation.

Reviewed-by: Boris Burkov <boris@bur.io>
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-tree.h
fs/btrfs/inode.c
fs/btrfs/relocation.c
fs/btrfs/tests/inode-tests.c

index 6ffef1cd37c1bf7d30a12669ef616b42c34323a9..673af5ece25ebc14a95308aeff341ba3ea93719b 100644 (file)
@@ -196,13 +196,6 @@ int set_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
 int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
                   u32 bits, struct extent_state **cached_state);
 
-static inline int clear_extent_uptodate(struct extent_io_tree *tree, u64 start,
-               u64 end, struct extent_state **cached_state)
-{
-       return __clear_extent_bit(tree, start, end, EXTENT_UPTODATE,
-                                 cached_state, NULL);
-}
-
 static inline int clear_extent_dirty(struct extent_io_tree *tree, u64 start,
                                     u64 end, struct extent_state **cached)
 {
index 4603dc6dd533203b488d7cbb7f4172cfe529ac67..e0b17a14df6857e282c7773469fee974050ddf16 100644 (file)
@@ -3232,8 +3232,6 @@ out:
                btrfs_end_transaction(trans);
 
        if (ret || truncated) {
-               u64 unwritten_start = start;
-
                /*
                 * If we failed to finish this ordered extent for any reason we
                 * need to make sure BTRFS_ORDERED_IOERR is set on the ordered
@@ -3245,10 +3243,6 @@ out:
                if (ret)
                        btrfs_mark_ordered_extent_error(ordered_extent);
 
-               if (truncated)
-                       unwritten_start += logical_len;
-               clear_extent_uptodate(io_tree, unwritten_start, end, NULL);
-
                /*
                 * Drop extent maps for the part of the extent we didn't write.
                 *
@@ -3263,9 +3257,15 @@ out:
                 * we don't mess with the extent map tree in the NOCOW case, but
                 * for now simply skip this if we are the free space inode.
                 */
-               if (!btrfs_is_free_space_inode(inode))
+               if (!btrfs_is_free_space_inode(inode)) {
+                       u64 unwritten_start = start;
+
+                       if (truncated)
+                               unwritten_start += logical_len;
+
                        btrfs_drop_extent_map_range(inode, unwritten_start,
                                                    end, false);
+               }
 
                /*
                 * If the ordered extent had an IOERR or something else went
@@ -7480,12 +7480,10 @@ next:
                 *    Since the IO will never happen for this page.
                 */
                btrfs_qgroup_free_data(inode, NULL, cur, range_end + 1 - cur, NULL);
-               if (!inode_evicting) {
+               if (!inode_evicting)
                        clear_extent_bit(tree, cur, range_end, EXTENT_LOCKED |
-                                EXTENT_DELALLOC | EXTENT_UPTODATE |
-                                EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG |
-                                extra_flags, &cached_state);
-               }
+                                        EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING |
+                                        EXTENT_DEFRAG | extra_flags, &cached_state);
                cur = range_end + 1;
        }
        /*
index e17bcb034595199401e13ae40c8aba12f58b0593..b7f7563d3c141a5de6c437767e668a9b231ea76e 100644 (file)
@@ -2706,9 +2706,6 @@ static noinline_for_stack int prealloc_file_extent_cluster(struct reloc_control
                if (ret < 0)
                        return ret;
 
-               clear_extent_bits(&inode->io_tree, i_size,
-                                 round_up(i_size, PAGE_SIZE) - 1,
-                                 EXTENT_UPTODATE);
                folio = filemap_lock_folio(mapping, i_size >> PAGE_SHIFT);
                /*
                 * If page is freed we don't need to do anything then, as we
index 3ea3bc2225fe82beaee67e1fe9f48e268ca7db04..8142a84129b60ad4e8ea6e7cc89b4ae7aae115fb 100644 (file)
@@ -952,8 +952,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
        ret = clear_extent_bit(&BTRFS_I(inode)->io_tree,
                               BTRFS_MAX_EXTENT_SIZE >> 1,
                               (BTRFS_MAX_EXTENT_SIZE >> 1) + sectorsize - 1,
-                              EXTENT_DELALLOC | EXTENT_DELALLOC_NEW |
-                              EXTENT_UPTODATE, NULL);
+                              EXTENT_DELALLOC | EXTENT_DELALLOC_NEW, NULL);
        if (ret) {
                test_err("clear_extent_bit returned %d", ret);
                goto out;
@@ -1020,8 +1019,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
        ret = clear_extent_bit(&BTRFS_I(inode)->io_tree,
                               BTRFS_MAX_EXTENT_SIZE + sectorsize,
                               BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize - 1,
-                              EXTENT_DELALLOC | EXTENT_DELALLOC_NEW |
-                              EXTENT_UPTODATE, NULL);
+                              EXTENT_DELALLOC | EXTENT_DELALLOC_NEW, NULL);
        if (ret) {
                test_err("clear_extent_bit returned %d", ret);
                goto out;
@@ -1053,8 +1051,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
 
        /* Empty */
        ret = clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, (u64)-1,
-                              EXTENT_DELALLOC | EXTENT_DELALLOC_NEW |
-                              EXTENT_UPTODATE, NULL);
+                              EXTENT_DELALLOC | EXTENT_DELALLOC_NEW, NULL);
        if (ret) {
                test_err("clear_extent_bit returned %d", ret);
                goto out;
@@ -1069,8 +1066,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
 out:
        if (ret)
                clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, (u64)-1,
-                                EXTENT_DELALLOC | EXTENT_DELALLOC_NEW |
-                                EXTENT_UPTODATE, NULL);
+                                EXTENT_DELALLOC | EXTENT_DELALLOC_NEW, NULL);
        iput(inode);
        btrfs_free_dummy_root(root);
        btrfs_free_dummy_fs_info(fs_info);