]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: simplify condition for logging new dentries at btrfs_log_inode_parent()
authorFilipe Manana <fdmanana@suse.com>
Thu, 13 Mar 2025 17:07:47 +0000 (17:07 +0000)
committerDavid Sterba <dsterba@suse.com>
Tue, 18 Mar 2025 19:35:56 +0000 (20:35 +0100)
There's no point in checking if the inode is a directory as
ctx->log_new_dentries is only set in case we are logging a directory down
the call chain of btrfs_log_inode(). So remove that check making the logic
more simple and while at it add a comment about why use a local variable
to track if we later need to log new dentries.

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 6c59c581ebe47797388795777fbe95d1604a95f4..6bc9f5f3239306a4da1870cd1fc6a0b3e86c98eb 100644 (file)
@@ -7036,7 +7036,7 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
        struct btrfs_root *root = inode->root;
        struct btrfs_fs_info *fs_info = root->fs_info;
        int ret = 0;
-       bool log_dentries = false;
+       bool log_dentries;
 
        if (btrfs_test_opt(fs_info, NOTREELOG)) {
                ret = BTRFS_LOG_FORCE_COMMIT;
@@ -7090,8 +7090,11 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
                goto end_trans;
        }
 
-       if (S_ISDIR(inode->vfs_inode.i_mode) && ctx->log_new_dentries)
-               log_dentries = true;
+       /*
+        * Track if we need to log dentries because ctx->log_new_dentries can
+        * be modified in the call chains below.
+        */
+       log_dentries = ctx->log_new_dentries;
 
        /*
         * On unlink we must make sure all our current and old parent directory