From: Filipe Manana Date: Fri, 29 Aug 2025 15:46:15 +0000 (+0100) Subject: btrfs: use the inode item boolean everywhere in overwrite_item() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2a13cfc949e591702f1288d62c691099c67e04ca;p=users%2Fhch%2Fmisc.git btrfs: use the inode item boolean everywhere in overwrite_item() We have this boolean 'inode_item' to tell if we are processing an inode item key and we use it in a couple of places while in another two places we open code by checking if the key type matches the inode item type. Make this consistent and use the boolean everywhere. Also rename it from 'inode_item' to 'is_inode_item', which makes it more clear that it's a boolean and not an instance of struct btrfs_inode_item, and make it const too. Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 88e813bb28d8..d830c33be7c6 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -424,7 +424,7 @@ static int overwrite_item(struct walk_control *wc, unsigned long dst_ptr; struct extent_buffer *dst_eb; int dst_slot; - bool inode_item = key->type == BTRFS_INODE_ITEM_KEY; + const bool is_inode_item = (key->type == BTRFS_INODE_ITEM_KEY); /* * This is only used during log replay, so the root is always from a @@ -486,7 +486,7 @@ static int overwrite_item(struct walk_control *wc, * We need to load the old nbytes into the inode so when we * replay the extents we've logged we get the right nbytes. */ - if (inode_item) { + if (is_inode_item) { struct btrfs_inode_item *item; u64 nbytes; u32 mode; @@ -507,7 +507,7 @@ static int overwrite_item(struct walk_control *wc, if (S_ISDIR(mode)) btrfs_set_inode_size(eb, item, 0); } - } else if (inode_item) { + } else if (is_inode_item) { struct btrfs_inode_item *item; u32 mode; @@ -561,7 +561,7 @@ insert: * state of the tree found in the subvolume, and i_size is modified * as it goes */ - if (key->type == BTRFS_INODE_ITEM_KEY && ret == -EEXIST) { + if (is_inode_item && ret == -EEXIST) { struct btrfs_inode_item *src_item; struct btrfs_inode_item *dst_item; @@ -602,7 +602,7 @@ insert: } /* make sure the generation is filled in */ - if (key->type == BTRFS_INODE_ITEM_KEY) { + if (is_inode_item) { struct btrfs_inode_item *dst_item; dst_item = (struct btrfs_inode_item *)dst_ptr;