Skip to content

Commit 2cc8334

Browse files
josefbacikkdave
authored andcommitted
btrfs: remove WARN_ON in log_dir_items
When Filipe added the recursive directory logging stuff in 2f2ff0e ("Btrfs: fix metadata inconsistencies after directory fsync") he specifically didn't take the directory i_mutex for the children directories that we need to log because of lockdep. This is generally fine, but can lead to this WARN_ON() tripping if we happen to run delayed deletion's in between our first search and our second search of dir_item/dir_indexes for this directory. We expect this to happen, so the WARN_ON() isn't necessary. Drop the WARN_ON() and add a comment so we know why this case can happen. CC: [email protected] # 4.4+ Reviewed-by: Filipe Manana <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent bf50411 commit 2cc8334

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

fs/btrfs/tree-log.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3578,9 +3578,16 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans,
35783578
}
35793579
btrfs_release_path(path);
35803580

3581-
/* find the first key from this transaction again */
3581+
/*
3582+
* Find the first key from this transaction again. See the note for
3583+
* log_new_dir_dentries, if we're logging a directory recursively we
3584+
* won't be holding its i_mutex, which means we can modify the directory
3585+
* while we're logging it. If we remove an entry between our first
3586+
* search and this search we'll not find the key again and can just
3587+
* bail.
3588+
*/
35823589
ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0);
3583-
if (WARN_ON(ret != 0))
3590+
if (ret != 0)
35843591
goto done;
35853592

35863593
/*

0 commit comments

Comments
 (0)