All of lore.kernel.org
 help / color / mirror / Atom feed
From: Filipe Manana <fdmanana@gmail.com>
To: Josef Bacik <josef@toxicpanda.com>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>, kernel-team@fb.com
Subject: Re: [PATCH v2 02/42] btrfs: fix lockdep splat in btrfs_recover_relocation
Date: Tue, 24 Nov 2020 16:56:02 +0000	[thread overview]
Message-ID: <CAL3q7H6vUsWfKn1KtU+=5w_cn5OBa5k1VBEQnK=d51gfuiC9+w@mail.gmail.com> (raw)
In-Reply-To: <44c756daa28122f0f51f52d154c1232a09e66872.1605284383.git.josef@toxicpanda.com>

On Fri, Nov 13, 2020 at 4:25 PM Josef Bacik <josef@toxicpanda.com> wrote:
>
> While testing the error paths of relocation I hit the following lockdep
> splat

The lockdep splat has a kernel named exactly like mine: *-btrfs-next-71 :)

>
> ======================================================
> WARNING: possible circular locking dependency detected
> 5.10.0-rc2-btrfs-next-71 #1 Not tainted
> ------------------------------------------------------
> find/324157 is trying to acquire lock:
> ffff8ebc48d293a0 (btrfs-tree-01#2/3){++++}-{3:3}, at: __btrfs_tree_read_lock+0x32/0x1a0 [btrfs]
>
> but task is already holding lock:
> ffff8eb9932c5088 (btrfs-tree-00){++++}-{3:3}, at: __btrfs_tree_read_lock+0x32/0x1a0 [btrfs]
>
> which lock already depends on the new lock.
>
> the existing dependency chain (in reverse order) is:
>
> -> #1 (btrfs-tree-00){++++}-{3:3}:
>        lock_acquire+0xd8/0x490
>        down_write_nested+0x44/0x120
>        __btrfs_tree_lock+0x27/0x120 [btrfs]
>        btrfs_search_slot+0x2a3/0xc50 [btrfs]
>        btrfs_insert_empty_items+0x58/0xa0 [btrfs]
>        insert_with_overflow+0x44/0x110 [btrfs]
>        btrfs_insert_xattr_item+0xb8/0x1d0 [btrfs]
>        btrfs_setxattr+0xd6/0x4c0 [btrfs]
>        btrfs_setxattr_trans+0x68/0x100 [btrfs]
>        __vfs_setxattr+0x66/0x80
>        __vfs_setxattr_noperm+0x70/0x200
>        vfs_setxattr+0x6b/0x120
>        setxattr+0x125/0x240
>        path_setxattr+0xba/0xd0
>        __x64_sys_setxattr+0x27/0x30
>        do_syscall_64+0x33/0x80
>        entry_SYSCALL_64_after_hwframe+0x44/0xa9
>
> -> #0 (btrfs-tree-01#2/3){++++}-{3:3}:
>        check_prev_add+0x91/0xc60
>        __lock_acquire+0x1689/0x3130
>        lock_acquire+0xd8/0x490
>        down_read_nested+0x45/0x220
>        __btrfs_tree_read_lock+0x32/0x1a0 [btrfs]
>        btrfs_next_old_leaf+0x27d/0x580 [btrfs]
>        btrfs_real_readdir+0x1e3/0x4b0 [btrfs]
>        iterate_dir+0x170/0x1c0
>        __x64_sys_getdents64+0x83/0x140
>        do_syscall_64+0x33/0x80
>        entry_SYSCALL_64_after_hwframe+0x44/0xa9
>
> other info that might help us debug this:
>
>  Possible unsafe locking scenario:
>
>        CPU0                    CPU1
>        ----                    ----
>   lock(btrfs-tree-00);
>                                lock(btrfs-tree-01#2/3);
>                                lock(btrfs-tree-00);
>   lock(btrfs-tree-01#2/3);
>
>  *** DEADLOCK ***
>
> 5 locks held by find/324157:
>  #0: ffff8ebc502c6e00 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x4d/0x60
>  #1: ffff8eb97f689980 (&type->i_mutex_dir_key#10){++++}-{3:3}, at: iterate_dir+0x52/0x1c0
>  #2: ffff8ebaec00ca58 (btrfs-tree-02#2){++++}-{3:3}, at: __btrfs_tree_read_lock+0x32/0x1a0 [btrfs]
>  #3: ffff8eb98f986f78 (btrfs-tree-01#2){++++}-{3:3}, at: __btrfs_tree_read_lock+0x32/0x1a0 [btrfs]
>  #4: ffff8eb9932c5088 (btrfs-tree-00){++++}-{3:3}, at: __btrfs_tree_read_lock+0x32/0x1a0 [btrfs]
>
> stack backtrace:
> CPU: 2 PID: 324157 Comm: find Not tainted 5.10.0-rc2-btrfs-next-71 #1
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
> Call Trace:
>  dump_stack+0x8d/0xb5
>  check_noncircular+0xff/0x110
>  ? mark_lock.part.0+0x468/0xe90
>  check_prev_add+0x91/0xc60
>  __lock_acquire+0x1689/0x3130
>  ? kvm_clock_read+0x14/0x30
>  ? kvm_sched_clock_read+0x5/0x10
>  lock_acquire+0xd8/0x490
>  ? __btrfs_tree_read_lock+0x32/0x1a0 [btrfs]
>  down_read_nested+0x45/0x220
>  ? __btrfs_tree_read_lock+0x32/0x1a0 [btrfs]
>  __btrfs_tree_read_lock+0x32/0x1a0 [btrfs]
>  btrfs_next_old_leaf+0x27d/0x580 [btrfs]
>  btrfs_real_readdir+0x1e3/0x4b0 [btrfs]
>  iterate_dir+0x170/0x1c0
>  __x64_sys_getdents64+0x83/0x140
>  ? filldir+0x1d0/0x1d0
>  do_syscall_64+0x33/0x80
>  entry_SYSCALL_64_after_hwframe+0x44/0xa9
>
> This is thankfully straightforward to fix, simply release the path
> before we setup the reloc_ctl.

Ok, so that splat is exactly what I reported not long ago and is
already fixed by:

https://lore.kernel.org/linux-btrfs/36b861f262858990f84eda72da6bb2e6762c41b7.1604697895.git.josef@toxicpanda.com/#r

Which is the splat that happened in one of my test boxes.

So, have you pasted the wrong splat?
Did it happen with any existing test case from fstests, if so, which?
That one I reported was with btrfs/187 (worth mentioning in the
changelog).

Thanks.

>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
>  fs/btrfs/volumes.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index bb1aa96e1233..ece8bb62fcc1 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -4283,6 +4283,8 @@ int btrfs_recover_balance(struct btrfs_fs_info *fs_info)
>                 btrfs_warn(fs_info,
>         "balance: cannot set exclusive op status, resume manually");
>
> +       btrfs_release_path(path);
> +
>         mutex_lock(&fs_info->balance_mutex);
>         BUG_ON(fs_info->balance_ctl);
>         spin_lock(&fs_info->balance_lock);
> --
> 2.26.2
>


-- 
Filipe David Manana,

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

  parent reply	other threads:[~2020-11-24 16:56 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13 16:22 [PATCH v2 00/42] Cleanup error handling in relocation Josef Bacik
2020-11-13 16:22 ` [PATCH v2 01/42] btrfs: allow error injection for btrfs_search_slot and btrfs_cow_block Josef Bacik
2020-11-13 16:22 ` [PATCH v2 02/42] btrfs: fix lockdep splat in btrfs_recover_relocation Josef Bacik
2020-11-24 10:44   ` Nikolay Borisov
2020-11-24 16:56   ` Filipe Manana [this message]
2020-11-24 18:44     ` Josef Bacik
2020-11-13 16:22 ` [PATCH v2 03/42] btrfs: convert some BUG_ON()'s to ASSERT()'s in do_relocation Josef Bacik
2020-11-13 16:22 ` [PATCH v2 04/42] btrfs: convert BUG_ON()'s in relocate_tree_block Josef Bacik
2020-11-13 16:22 ` [PATCH v2 05/42] btrfs: return an error from btrfs_record_root_in_trans Josef Bacik
2020-11-24 11:02   ` Nikolay Borisov
2020-11-24 12:53     ` Nikolay Borisov
2020-11-13 16:22 ` [PATCH v2 06/42] btrfs: handle errors from select_reloc_root() Josef Bacik
2020-11-13 16:22 ` [PATCH v2 07/42] btrfs: convert BUG_ON()'s in select_reloc_root() to proper errors Josef Bacik
2020-11-13 16:22 ` [PATCH v2 08/42] btrfs: check record_root_in_trans related failures in select_reloc_root Josef Bacik
2020-11-13 16:22 ` [PATCH v2 09/42] btrfs: do proper error handling in record_reloc_root_in_trans Josef Bacik
2020-11-13 16:23 ` [PATCH v2 10/42] btrfs: handle btrfs_record_root_in_trans failure in btrfs_rename_exchange Josef Bacik
2020-11-13 16:23 ` [PATCH v2 11/42] btrfs: handle btrfs_record_root_in_trans failure in btrfs_rename Josef Bacik
2020-11-13 16:23 ` [PATCH v2 12/42] btrfs: handle btrfs_record_root_in_trans failure in btrfs_delete_subvolume Josef Bacik
2020-11-13 16:23 ` [PATCH v2 13/42] btrfs: handle btrfs_record_root_in_trans failure in btrfs_recover_log_trees Josef Bacik
2020-11-24 12:37   ` Nikolay Borisov
2020-12-02 18:05     ` Josef Bacik
2020-11-13 16:23 ` [PATCH v2 14/42] btrfs: handle btrfs_record_root_in_trans failure in create_subvol Josef Bacik
2020-11-24 12:42   ` Nikolay Borisov
2020-12-02 18:12     ` Josef Bacik
2020-11-13 16:23 ` [PATCH v2 15/42] btrfs: btrfs: handle btrfs_record_root_in_trans failure in relocate_tree_block Josef Bacik
2020-11-13 16:23 ` [PATCH v2 16/42] btrfs: handle btrfs_record_root_in_trans failure in start_transaction Josef Bacik
2020-11-13 16:23 ` [PATCH v2 17/42] btrfs: handle record_root_in_trans failure in qgroup_account_snapshot Josef Bacik
2020-11-13 16:23 ` [PATCH v2 18/42] btrfs: handle record_root_in_trans failure in btrfs_record_root_in_trans Josef Bacik
2020-11-13 16:23 ` [PATCH v2 19/42] btrfs: handle record_root_in_trans failure in create_pending_snapshot Josef Bacik
2020-11-13 16:23 ` [PATCH v2 20/42] btrfs: do not panic in __add_reloc_root Josef Bacik
2020-11-24 12:51   ` Nikolay Borisov
2020-11-13 16:23 ` [PATCH v2 21/42] btrfs: have proper error handling in btrfs_init_reloc_root Josef Bacik
2020-11-13 16:23 ` [PATCH v2 22/42] btrfs: do proper error handling in create_reloc_root Josef Bacik
2020-11-13 16:23 ` [PATCH v2 23/42] btrfs: handle btrfs_update_reloc_root failure in commit_fs_roots Josef Bacik
2020-11-13 16:23 ` [PATCH v2 24/42] btrfs: change insert_dirty_subvol to return errors Josef Bacik
2020-11-13 16:23 ` [PATCH v2 25/42] btrfs: handle btrfs_update_reloc_root failure in insert_dirty_subvol Josef Bacik
2020-11-13 16:23 ` [PATCH v2 26/42] btrfs: handle btrfs_update_reloc_root failure in prepare_to_merge Josef Bacik
2020-11-13 16:23 ` [PATCH v2 27/42] btrfs: do proper error handling in btrfs_update_reloc_root Josef Bacik
2020-11-13 16:23 ` [PATCH v2 28/42] btrfs: convert logic BUG_ON()'s in replace_path to ASSERT()'s Josef Bacik
2020-11-13 16:23 ` [PATCH v2 29/42] btrfs: handle initial btrfs_cow_block error in replace_path Josef Bacik
2020-11-13 16:23 ` [PATCH v2 30/42] btrfs: handle the loop " Josef Bacik
2020-11-13 16:23 ` [PATCH v2 31/42] btrfs: handle btrfs_search_slot failure " Josef Bacik
2020-11-13 16:23 ` [PATCH v2 32/42] btrfs: handle errors in reference count manipulation " Josef Bacik
2020-11-13 16:23 ` [PATCH v2 33/42] btrfs: handle extent reference errors in do_relocation Josef Bacik
2020-11-24 13:15   ` Nikolay Borisov
2020-11-13 16:23 ` [PATCH v2 34/42] btrfs: check for BTRFS_BLOCK_FLAG_FULL_BACKREF being set improperly Josef Bacik
2020-11-13 16:23 ` [PATCH v2 35/42] btrfs: remove the extent item sanity checks in relocate_block_group Josef Bacik
2020-11-13 16:23 ` [PATCH v2 36/42] btrfs: do proper error handling in create_reloc_inode Josef Bacik
2020-11-13 16:23 ` [PATCH v2 37/42] btrfs: handle __add_reloc_root failure in btrfs_recover_relocation Josef Bacik
2020-11-24 13:26   ` Nikolay Borisov
2020-12-02 18:29     ` Josef Bacik
2020-11-13 16:23 ` [PATCH v2 38/42] btrfs: handle __add_reloc_root failure in btrfs_reloc_post_snapshot Josef Bacik
2020-11-13 16:23 ` [PATCH v2 39/42] btrfs: cleanup error handling in prepare_to_merge Josef Bacik
2020-11-13 16:23 ` [PATCH v2 40/42] btrfs: handle extent corruption with select_one_root properly Josef Bacik
2020-11-13 16:23 ` [PATCH v2 41/42] btrfs: do proper error handling in merge_reloc_roots Josef Bacik
2020-11-13 16:23 ` [PATCH v2 42/42] btrfs: check return value of btrfs_commit_transaction in relocation Josef Bacik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAL3q7H6vUsWfKn1KtU+=5w_cn5OBa5k1VBEQnK=d51gfuiC9+w@mail.gmail.com' \
    --to=fdmanana@gmail.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.