All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: remove WARN_ON() in log_dir_items
@ 2019-03-06 22:13 Josef Bacik
  2019-03-07 10:21 ` Filipe Manana
  2019-03-07 16:04 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Josef Bacik @ 2019-03-06 22:13 UTC (permalink / raw)
  To: kernel-team, linux-btrfs

When Filipe added the recursive directory logging stuff 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.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/tree-log.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index f06454a55e00..bccb62c1c587 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3578,9 +3578,16 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans,
 	}
 	btrfs_release_path(path);
 
-	/* find the first key from this transaction again */
+	/*
+	 * Find the first key from this transaction again.  See the note for
+	 * log_new_dir_dentries, if we're logging a directory recursively we
+	 * won't be holding its i_mutex, which means we can modify the directory
+	 * while we're logging it.  If we remove an entry between our first
+	 * search and this search we'll not find the key again and can just
+	 * bail.
+	 */
 	ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0);
-	if (WARN_ON(ret != 0))
+	if (ret != 0)
 		goto done;
 
 	/*
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: remove WARN_ON() in log_dir_items
  2019-03-06 22:13 [PATCH] btrfs: remove WARN_ON() in log_dir_items Josef Bacik
@ 2019-03-07 10:21 ` Filipe Manana
  2019-03-07 16:04 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Filipe Manana @ 2019-03-07 10:21 UTC (permalink / raw)
  To: Josef Bacik; +Cc: kernel-team, linux-btrfs

On Wed, Mar 6, 2019 at 10:15 PM Josef Bacik <josef@toxicpanda.com> wrote:
>
> When Filipe added the recursive directory logging stuff 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.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Filipe Manana <fdmanana@suse.com>

Looks good, thanks!

> ---
>  fs/btrfs/tree-log.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index f06454a55e00..bccb62c1c587 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -3578,9 +3578,16 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans,
>         }
>         btrfs_release_path(path);
>
> -       /* find the first key from this transaction again */
> +       /*
> +        * Find the first key from this transaction again.  See the note for
> +        * log_new_dir_dentries, if we're logging a directory recursively we
> +        * won't be holding its i_mutex, which means we can modify the directory
> +        * while we're logging it.  If we remove an entry between our first
> +        * search and this search we'll not find the key again and can just
> +        * bail.
> +        */
>         ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0);
> -       if (WARN_ON(ret != 0))
> +       if (ret != 0)
>                 goto done;
>
>         /*
> --
> 2.14.3
>


-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: remove WARN_ON() in log_dir_items
  2019-03-06 22:13 [PATCH] btrfs: remove WARN_ON() in log_dir_items Josef Bacik
  2019-03-07 10:21 ` Filipe Manana
@ 2019-03-07 16:04 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2019-03-07 16:04 UTC (permalink / raw)
  To: Josef Bacik; +Cc: kernel-team, linux-btrfs

On Wed, Mar 06, 2019 at 05:13:04PM -0500, Josef Bacik wrote:
> When Filipe added the recursive directory logging stuff 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.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Added to misc-next, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-07 16:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-06 22:13 [PATCH] btrfs: remove WARN_ON() in log_dir_items Josef Bacik
2019-03-07 10:21 ` Filipe Manana
2019-03-07 16:04 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.