From 2fd3cbadbd86613950bbf6c766752893cb6cbe1c Mon Sep 17 00:00:00 2001 From: Adam Kupczyk Date: Tue, 10 Aug 2021 15:15:52 +0200 Subject: [PATCH] os/bluestore/bluefs: Rearrange locks in prealocate Rearranged locks in preallocate to avoid possible deadlock with compact_log_async_dump_metadata_NF. Cycle was: L->N rename/mkdir N->F compact_log_async_dump_metadata_NF F->L preallocate Signed-off-by: Adam Kupczyk (cherry picked from commit 49316abbc9873f50bf70c5eba3b67f3ebab189bf) --- src/os/bluestore/BlueFS.cc | 3 ++- src/os/bluestore/BlueFS.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index c37d95d056a79..e961522331b01 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -3448,6 +3448,7 @@ int BlueFS::_allocate(uint8_t id, uint64_t len, int BlueFS::preallocate(FileRef f, uint64_t off, uint64_t len) { + std::lock_guard ll(log.lock); std::lock_guard fl(f->lock); dout(10) << __func__ << " file " << f->fnode << " 0x" << std::hex << off << "~" << len << std::dec << dendl; @@ -3467,7 +3468,7 @@ int BlueFS::preallocate(FileRef f, uint64_t off, uint64_t len) vselector->add_usage(f->vselector_hint, f->fnode); if (r < 0) return r; - std::lock_guard ll(log.lock); + log.t.op_file_update_inc(f->fnode); } return 0; diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index 87d2727f67923..06880c8b3c8ac 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -706,8 +706,8 @@ public: * log L | < < * dirty D | * nodes N | < - * File F | < - * FileWriter W | < < < + * File F | + * FileWriter W | < < < * * Claim: Deadlock is possible IFF graph contains cycles. */ -- 2.39.5