Btrfs: move the sb_end_intwrite until after the throttle logic
Sage reported the following lockdep backtrace
=====================================
[ BUG: bad unlock balance detected! ]
3.6.0-rc2-ceph-00171-gc7ed62d #1 Not tainted
-------------------------------------
btrfs-cleaner/7607 is trying to release lock (sb_internal) at:
[<
ffffffffa00422ae>] btrfs_commit_transaction+0xa6e/0xb20 [btrfs]
but there are no more locks to release!
other info that might help us debug this:
1 lock held by btrfs-cleaner/7607:
#0: (&fs_info->cleaner_mutex){+.+...}, at: [<
ffffffffa003b405>] cleaner_kthread+0x95/0x120 [btrfs]
stack backtrace:
Pid: 7607, comm: btrfs-cleaner Not tainted 3.6.0-rc2-ceph-00171-gc7ed62d #1
Call Trace:
[<
ffffffffa00422ae>] ? btrfs_commit_transaction+0xa6e/0xb20 [btrfs]
[<
ffffffff810afa9e>] print_unlock_inbalance_bug+0xfe/0x110
[<
ffffffff810b289e>] lock_release_non_nested+0x1ee/0x310
[<
ffffffff81172f9b>] ? kmem_cache_free+0x7b/0x160
[<
ffffffffa004106c>] ? put_transaction+0x8c/0x130 [btrfs]
[<
ffffffffa00422ae>] ? btrfs_commit_transaction+0xa6e/0xb20 [btrfs]
[<
ffffffff810b2a95>] lock_release+0xd5/0x220
[<
ffffffff81173071>] ? kmem_cache_free+0x151/0x160
[<
ffffffff8117d9ed>] __sb_end_write+0x7d/0x90
[<
ffffffffa00422ae>] btrfs_commit_transaction+0xa6e/0xb20 [btrfs]
[<
ffffffff81079850>] ? __init_waitqueue_head+0x60/0x60
[<
ffffffff81634c6b>] ? _raw_spin_unlock+0x2b/0x40
[<
ffffffffa0042758>] __btrfs_end_transaction+0x368/0x3c0 [btrfs]
[<
ffffffffa0042808>] btrfs_end_transaction_throttle+0x18/0x20 [btrfs]
[<
ffffffffa00318f0>] btrfs_drop_snapshot+0x410/0x600 [btrfs]
[<
ffffffff8132babd>] ? do_raw_spin_unlock+0x5d/0xb0
[<
ffffffffa00430ef>] btrfs_clean_old_snapshots+0xaf/0x150 [btrfs]
[<
ffffffffa003b405>] ? cleaner_kthread+0x95/0x120 [btrfs]
[<
ffffffffa003b419>] cleaner_kthread+0xa9/0x120 [btrfs]
[<
ffffffffa003b370>] ? btrfs_destroy_delayed_refs.isra.102+0x220/0x220 [btrfs]
[<
ffffffff810791ee>] kthread+0xae/0xc0
[<
ffffffff810b379d>] ? trace_hardirqs_on+0xd/0x10
[<
ffffffff8163e744>] kernel_thread_helper+0x4/0x10
[<
ffffffff81635430>] ? retint_restore_args+0x13/0x13
[<
ffffffff81079140>] ? flush_kthread_work+0x1a0/0x1a0
[<
ffffffff8163e740>] ? gs_change+0x13/0x13
This is because the throttle stuff can commit the transaction, which expects to
be the one stopping the intwrite stuff, but we've already done it in the
__btrfs_end_transaction. Moving the sb_end_intewrite after this logic makes the
lockdep go away. Thanks,
Tested-by: Sage Weil <sage@inktank.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>