]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: use saner variable type and name to indicate extrefs at add_inode_ref()
authorFilipe Manana <fdmanana@suse.com>
Fri, 11 Jul 2025 19:59:36 +0000 (20:59 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 23:14:07 +0000 (01:14 +0200)
We are using a variable named 'log_ref_ver' of type int to indicate if we
are processing an extref item or not, using a value of 1 if so, otherwise
0. This is an odd name and type, so rename it to 'is_extref_item' and
change its type to bool.

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/tree-log.c

index 467b69a4ef3bdd093e31476baef9d9268636f2e4..9f05d454b9dfd2fcfb42005b53270952a041f652 100644 (file)
@@ -1385,7 +1385,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
        unsigned long ref_end;
        struct fscrypt_str name = { 0 };
        int ret;
-       int log_ref_ver = 0;
+       const bool is_extref_item = (key->type == BTRFS_INODE_EXTREF_KEY);
        u64 parent_objectid;
        u64 inode_objectid;
        u64 ref_index = 0;
@@ -1394,11 +1394,10 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
        ref_ptr = btrfs_item_ptr_offset(eb, slot);
        ref_end = ref_ptr + btrfs_item_size(eb, slot);
 
-       if (key->type == BTRFS_INODE_EXTREF_KEY) {
+       if (is_extref_item) {
                struct btrfs_inode_extref *r;
 
                ref_struct_size = sizeof(struct btrfs_inode_extref);
-               log_ref_ver = 1;
                r = (struct btrfs_inode_extref *)ref_ptr;
                parent_objectid = btrfs_inode_extref_parent(eb, r);
        } else {
@@ -1430,7 +1429,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
        }
 
        while (ref_ptr < ref_end) {
-               if (log_ref_ver) {
+               if (is_extref_item) {
                        ret = extref_get_fields(eb, ref_ptr, &name,
                                                &ref_index, &parent_objectid);
                        if (ret)
@@ -1505,7 +1504,7 @@ next:
                ref_ptr = (unsigned long)(ref_ptr + ref_struct_size) + name.len;
                kfree(name.name);
                name.name = NULL;
-               if (log_ref_ver && dir) {
+               if (is_extref_item && dir) {
                        iput(&dir->vfs_inode);
                        dir = NULL;
                }