]> www.infradead.org Git - users/hch/misc.git/commitdiff
btrfs: remove pointless key offset setup in create_pending_snapshot()
authorFilipe Manana <fdmanana@suse.com>
Fri, 19 Sep 2025 16:46:05 +0000 (17:46 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 23 Sep 2025 06:49:24 +0000 (08:49 +0200)
There's no point in setting the key's offset to (u64)-1 since we never
use it before setting it to the current transaction's ID. So remove the
assignment of (u64)-1 to the key's offset and move the remainder of the
key initialization close to where it's used.

Reviewed-by: Qu Wenruo <wqu@suse.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/transaction.c

index d04fa6ce83901e056851006dfd56de0c5957e240..febf456a9ab0996aa3e8e32abc07b4ad4e57e9c3 100644 (file)
@@ -1694,10 +1694,6 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
                        goto clear_skip_qgroup;
        }
 
-       key.objectid = objectid;
-       key.type = BTRFS_ROOT_ITEM_KEY;
-       key.offset = (u64)-1;
-
        rsv = trans->block_rsv;
        trans->block_rsv = &pending->block_rsv;
        trans->bytes_reserved = trans->block_rsv->reserved;
@@ -1810,6 +1806,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
 
        btrfs_set_root_node(new_root_item, tmp);
        /* record when the snapshot was created in key.offset */
+       key.objectid = objectid;
+       key.type = BTRFS_ROOT_ITEM_KEY;
        key.offset = trans->transid;
        ret = btrfs_insert_root(trans, tree_root, &key, new_root_item);
        btrfs_tree_unlock(tmp);