From: Sage Weil Date: Thu, 30 Aug 2012 22:26:17 +0000 (-0600) Subject: Btrfs: do not take cleanup_work_sem in btrfs_run_delayed_iputs() X-Git-Tag: v3.7-rc3~21^2~92 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ac14aed66558d686b1f95dac1f07ecfe11d8c30e;p=platform%2Fupstream%2Fkernel-adaptation-pc.git Btrfs: do not take cleanup_work_sem in btrfs_run_delayed_iputs() Josef has suggested that this is not necessary. Removing it also avoids this lockdep splat (after the new sb_internal locking stuff was added): [ 604.090449] ====================================================== [ 604.114819] [ INFO: possible circular locking dependency detected ] [ 604.139262] 3.6.0-rc2-ceph-00144-g463b030 #1 Not tainted [ 604.162193] ------------------------------------------------------- [ 604.186139] btrfs-cleaner/6669 is trying to acquire lock: [ 604.209555] (sb_internal#2){.+.+..}, at: [] start_transaction+0x124/0x430 [btrfs] [ 604.257100] [ 604.257100] but task is already holding lock: [ 604.300366] (&fs_info->cleanup_work_sem){.+.+..}, at: [] btrfs_run_delayed_iputs+0x72/0x130 [btrfs] [ 604.352989] [ 604.352989] which lock already depends on the new lock. [ 604.352989] [ 604.427104] [ 604.427104] the existing dependency chain (in reverse order) is: [ 604.478493] [ 604.478493] -> #1 (&fs_info->cleanup_work_sem){.+.+..}: [ 604.529313] [] lock_acquire+0xa2/0x140 [ 604.559621] [] down_read+0x39/0x4e [ 604.589382] [] btrfs_lookup_dentry+0x218/0x550 [btrfs] [ 604.596161] btrfs: unlinked 1 orphans [ 604.675002] [] create_subvol+0x62d/0x690 [btrfs] [ 604.708859] [] btrfs_mksubvol.isra.52+0x346/0x3a0 [btrfs] [ 604.772466] [] btrfs_ioctl_snap_create_transid+0x132/0x190 [btrfs] [ 604.842245] [] btrfs_ioctl_snap_create+0x5e/0x80 [btrfs] [ 604.912852] [] btrfs_ioctl+0x138e/0x1990 [btrfs] [ 604.951888] [] do_vfs_ioctl+0x98/0x560 [ 604.989961] [] sys_ioctl+0x91/0xa0 [ 605.026628] [] system_call_fastpath+0x16/0x1b [ 605.064404] [ 605.064404] -> #0 (sb_internal#2){.+.+..}: [ 605.126832] [] __lock_acquire+0x1ac8/0x1b90 [ 605.163671] [] lock_acquire+0xa2/0x140 [ 605.200228] [] __sb_start_write+0xc6/0x1b0 [ 605.236818] [] start_transaction+0x124/0x430 [btrfs] [ 605.274029] [] btrfs_start_transaction+0x13/0x20 [btrfs] [ 605.340520] [] btrfs_evict_inode+0x19a/0x330 [btrfs] [ 605.378720] [] evict+0xb8/0x1c0 [ 605.416057] [] iput+0x105/0x210 [ 605.452373] [] btrfs_run_delayed_iputs+0xf2/0x130 [btrfs] [ 605.521627] [] cleaner_kthread+0xa1/0x120 [btrfs] [ 605.560520] [] kthread+0xae/0xc0 [ 605.598094] [] kernel_thread_helper+0x4/0x10 [ 605.636499] [ 605.636499] other info that might help us debug this: [ 605.636499] [ 605.736504] Possible unsafe locking scenario: [ 605.736504] [ 605.801931] CPU0 CPU1 [ 605.835126] ---- ---- [ 605.867093] lock(&fs_info->cleanup_work_sem); [ 605.898594] lock(sb_internal#2); [ 605.931954] lock(&fs_info->cleanup_work_sem); [ 605.965359] lock(sb_internal#2); [ 605.994758] [ 605.994758] *** DEADLOCK *** [ 605.994758] [ 606.075281] 2 locks held by btrfs-cleaner/6669: [ 606.104528] #0: (&fs_info->cleaner_mutex){+.+...}, at: [] cleaner_kthread+0x95/0x120 [btrfs] [ 606.165626] #1: (&fs_info->cleanup_work_sem){.+.+..}, at: [] btrfs_run_delayed_iputs+0x72/0x130 [btrfs] [ 606.231297] [ 606.231297] stack backtrace: [ 606.287723] Pid: 6669, comm: btrfs-cleaner Not tainted 3.6.0-rc2-ceph-00144-g463b030 #1 [ 606.347823] Call Trace: [ 606.376184] [] print_circular_bug+0x1fb/0x20c [ 606.409243] [] __lock_acquire+0x1ac8/0x1b90 [ 606.441343] [] ? start_transaction+0x124/0x430 [btrfs] [ 606.474583] [] lock_acquire+0xa2/0x140 [ 606.505934] [] ? start_transaction+0x124/0x430 [btrfs] [ 606.539429] [] ? do_raw_spin_unlock+0x5d/0xb0 [ 606.571719] [] __sb_start_write+0xc6/0x1b0 [ 606.603498] [] ? start_transaction+0x124/0x430 [btrfs] [ 606.637405] [] ? start_transaction+0x124/0x430 [btrfs] [ 606.670165] [] ? kmem_cache_alloc+0xb5/0x160 [ 606.702144] [] start_transaction+0x124/0x430 [btrfs] [ 606.735562] [] ? block_rsv_add_bytes+0x56/0x80 [btrfs] [ 606.769861] [] btrfs_start_transaction+0x13/0x20 [btrfs] [ 606.804575] [] btrfs_evict_inode+0x19a/0x330 [btrfs] [ 606.838756] [] ? _raw_spin_unlock+0x2b/0x40 [ 606.872010] [] evict+0xb8/0x1c0 [ 606.903800] [] iput+0x105/0x210 [ 606.935416] [] btrfs_run_delayed_iputs+0xf2/0x130 [btrfs] [ 606.970510] [] ? cleaner_kthread+0x95/0x120 [btrfs] [ 607.005648] [] cleaner_kthread+0xa1/0x120 [btrfs] [ 607.040724] [] ? btrfs_destroy_delayed_refs.isra.102+0x220/0x220 [btrfs] [ 607.104740] [] kthread+0xae/0xc0 [ 607.137119] [] ? trace_hardirqs_on+0xd/0x10 [ 607.169797] [] kernel_thread_helper+0x4/0x10 [ 607.202472] [] ? retint_restore_args+0x13/0x13 [ 607.235884] [] ? flush_kthread_work+0x1a0/0x1a0 [ 607.268731] [] ? gs_change+0x13/0x13 Signed-off-by: Sage Weil --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 8cb272c..073af07 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2118,7 +2118,6 @@ void btrfs_run_delayed_iputs(struct btrfs_root *root) if (empty) return; - down_read(&root->fs_info->cleanup_work_sem); spin_lock(&fs_info->delayed_iput_lock); list_splice_init(&fs_info->delayed_iputs, &list); spin_unlock(&fs_info->delayed_iput_lock); @@ -2129,7 +2128,6 @@ void btrfs_run_delayed_iputs(struct btrfs_root *root) iput(delayed->inode); kfree(delayed); } - up_read(&root->fs_info->cleanup_work_sem); } enum btrfs_orphan_cleanup_state {