]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
fix the broken lockdep logic in __sb_start_write()
authorOleg Nesterov <oleg@redhat.com>
Sun, 19 Jul 2015 22:50:55 +0000 (00:50 +0200)
committerOleg Nesterov <oleg@redhat.com>
Sat, 15 Aug 2015 11:52:09 +0000 (13:52 +0200)
commitf4b554af9931585174d4913b482eacab75858964
treee01977e85b9568688a28058ebacd82f34be6ae14
parentbee9182d955227f01ff3b80c4cb6acca9bb40b11
fix the broken lockdep logic in __sb_start_write()

1. wait_event(frozen < level) without rwsem_acquire_read() is just
   wrong from lockdep perspective. If we are going to deadlock
   because the caller is buggy, lockdep can't detect this problem.

2. __sb_start_write() can race with thaw_super() + freeze_super(),
   and after "goto retry" the 2nd  acquire_freeze_lock() is wrong.

3. The "tell lockdep we are doing trylock" hack doesn't look nice.

   I think this is correct, but this logic should be more explicit.
   Yes, the recursive read_lock() is fine if we hold the lock on a
   higher level. But we do not need to fool lockdep. If we can not
   deadlock in this case then try-lock must not fail and we can use
   use wait == F throughout this code.

Note: as Dave Chinner explains, the "trylock" hack and the fat comment
can be probably removed. But this needs a separate change and it will
be trivial: just kill __sb_start_write() and rename do_sb_start_write()
back to __sb_start_write().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Jan Kara <jack@suse.com>
fs/super.c