]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/bluefs: Rearrange locks in prealocate
authorAdam Kupczyk <akupczyk@redhat.com>
Tue, 10 Aug 2021 13:15:52 +0000 (15:15 +0200)
committerIgor Fedotov <igor.fedotov@croit.io>
Tue, 27 Jun 2023 10:55:55 +0000 (13:55 +0300)
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 <akupczyk@redhat.com>
(cherry picked from commit 49316abbc9873f50bf70c5eba3b67f3ebab189bf)

src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h

index c37d95d056a79ced68313b7e3771fc500aabc2b7..e961522331b010d29f165ec362481f6fc8bd5653 100644 (file)
@@ -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;
index 87d2727f67923e80da6488efd84a594a21350f1a..06880c8b3c8acf37e47e980a01eb5a3425bb864b 100644 (file)
@@ -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.
  */