]> www.infradead.org Git - users/hch/misc.git/commitdiff
btrfs: pass walk_control structure to check_item_in_log()
authorFilipe Manana <fdmanana@suse.com>
Wed, 27 Aug 2025 15:27:57 +0000 (16:27 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 23 Sep 2025 06:49:18 +0000 (08:49 +0200)
Instead of passing the transaction and log tree as arguments to
check_item_in_log(), pass the walk_control structure as we can grab those
from the structure. This reduces the number of arguments passed and it's
going to be needed by an incoming change that improves error reporting for
log replay. Notice that a NULL log root argument to check_item_in_log()
makes it unconditionally delete a directory entry, so since the
walk_control always has a non-NULL log root, we add an extra boolean to
check_item_in_log() to tell it if it should unconditionally delete a
directory entry, preserving the behaviour and also making it a bit more
clear.

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 460dc51e8c820dfcb9f848c382d10206a927f245..ca0946f947dfa14817e994d504c8bc18e27c6c90 100644 (file)
@@ -2254,13 +2254,14 @@ out:
  * item is not in the log, the item is removed and the inode it points
  * to is unlinked
  */
-static noinline int check_item_in_log(struct btrfs_trans_handle *trans,
-                                     struct btrfs_root *log,
+static noinline int check_item_in_log(struct walk_control *wc,
                                      struct btrfs_path *path,
                                      struct btrfs_path *log_path,
                                      struct btrfs_inode *dir,
-                                     struct btrfs_key *dir_key)
+                                     struct btrfs_key *dir_key,
+                                     bool force_remove)
 {
+       struct btrfs_trans_handle *trans = wc->trans;
        struct btrfs_root *root = dir->root;
        int ret;
        struct extent_buffer *eb;
@@ -2287,10 +2288,10 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans,
                goto out;
        }
 
-       if (log) {
+       if (!force_remove) {
                struct btrfs_dir_item *log_di;
 
-               log_di = btrfs_lookup_dir_index_item(trans, log, log_path,
+               log_di = btrfs_lookup_dir_index_item(trans, wc->log, log_path,
                                                     dir_key->objectid,
                                                     dir_key->offset, &name, 0);
                if (IS_ERR(log_di)) {
@@ -2540,9 +2541,8 @@ static noinline int replay_dir_deletes(struct walk_control *wc,
                        if (found_key.offset > range_end)
                                break;
 
-                       ret = check_item_in_log(trans, log, path,
-                                               log_path, dir,
-                                               &found_key);
+                       ret = check_item_in_log(wc, path, log_path, dir,
+                                               &found_key, del_all);
                        if (ret)
                                goto out;
                        if (found_key.offset == (u64)-1)