Skip to content

Commit

Permalink
os/bluestore/bluefs: Fix false collision with lockdep module
Browse files Browse the repository at this point in the history
Usually sequence of locking is 1) FileWriter 2) File.
In _compact_log_async_LD_NF_D it was in reversed order.
No real deadlock was possible, but lockdep complained.

Bonus: Improved lock dependency graph.

Fixes: https://tracker.ceph.com/issues/52939
Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
  • Loading branch information
aclamk committed Oct 19, 2021
1 parent 84d37ec commit e292475
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/os/bluestore/BlueFS.cc
Expand Up @@ -2437,16 +2437,16 @@ void BlueFS::_compact_log_async_LD_NF_D() //also locks FW for new_writer
new_log_writer = _create_writer(new_log);

new_log_writer->append(bl);
new_log->lock.lock();
new_log_writer->lock.lock();
new_log->lock.lock();
// 3. flush
r = _flush_special(new_log_writer);
ceph_assert(r == 0);

// 4. wait
_flush_bdev(new_log_writer);
new_log_writer->lock.unlock();
new_log->lock.unlock();
new_log_writer->lock.unlock();
// 5. update our log fnode
// discard first old_log_jump_to extents

Expand Down
12 changes: 6 additions & 6 deletions src/os/bluestore/BlueFS.h
Expand Up @@ -703,13 +703,13 @@ class FitToFastVolumeSelector : public OriginalVolumeSelector {
* Column represents last lock taken.
* Row represents next lock taken.
*
* < | L | D | N | F | W
* > | W | L | D | N | F
* -------------|---|---|---|---|---
* log L | < <
* dirty D |
* nodes N | <
* File F |
* FileWriter W | < < <
* FileWriter W | | > | > | | >
* log L | | > | > | >
* dirty D | | | >
* nodes N | | >
* File F |
*
* Claim: Deadlock is possible IFF graph contains cycles.
*/
Expand Down

0 comments on commit e292475

Please sign in to comment.