]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common/lockdep: add recursive flag for _will_lock
authorSage Weil <sage@redhat.com>
Mon, 17 Sep 2018 16:40:17 +0000 (11:40 -0500)
committerSage Weil <sage@redhat.com>
Fri, 21 Sep 2018 16:51:09 +0000 (11:51 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/Mutex.h
src/common/lockdep.cc
src/common/lockdep.h

index e8d528848d0a80e47f42973a1babd9d83f756a91..792ba3239c0c96ea55e87f481701d6d454ba116c 100644 (file)
@@ -44,7 +44,7 @@ private:
     id = lockdep_register(name.c_str());
   }
   void _will_lock() { // about to lock
-    id = lockdep_will_lock(name.c_str(), id, backtrace);
+    id = lockdep_will_lock(name.c_str(), id, backtrace, recursive);
   }
   void _locked() {    // just locked
     id = lockdep_locked(name.c_str(), id, backtrace);
index 91504bb9b482280774b134f189b959f4f6c5ec0f..c37e38f53db2b0975de23b066c73ef5c179d5f52 100644 (file)
@@ -269,7 +269,8 @@ static bool does_follow(int a, int b)
   return false;
 }
 
-int lockdep_will_lock(const char *name, int id, bool force_backtrace)
+int lockdep_will_lock(const char *name, int id, bool force_backtrace,
+                     bool recursive)
 {
   pthread_t p = pthread_self();
 
@@ -290,17 +291,19 @@ int lockdep_will_lock(const char *name, int id, bool force_backtrace)
        p != m.end();
        ++p) {
     if (p->first == id) {
-      lockdep_dout(0) << "\n";
-      *_dout << "recursive lock of " << name << " (" << id << ")\n";
-      BackTrace *bt = new BackTrace(BACKTRACE_SKIP);
-      bt->print(*_dout);
-      if (p->second) {
-       *_dout << "\npreviously locked at\n";
-       p->second->print(*_dout);
+      if (!recursive) {
+       lockdep_dout(0) << "\n";
+       *_dout << "recursive lock of " << name << " (" << id << ")\n";
+       BackTrace *bt = new BackTrace(BACKTRACE_SKIP);
+       bt->print(*_dout);
+       if (p->second) {
+         *_dout << "\npreviously locked at\n";
+         p->second->print(*_dout);
+       }
+       delete bt;
+       *_dout << dendl;
+       ceph_abort();
       }
-      delete bt;
-      *_dout << dendl;
-      ceph_abort();
     }
     else if (!(follows[p->first][id/8] & (1 << (id % 8)))) {
       // new dependency
index ffafc300c3a4b3332036950ce3c629b6f8afdb1c..1c854a9eaec7cbac374eaee9a7462a1b611787fb 100644 (file)
@@ -23,7 +23,8 @@ extern void lockdep_register_ceph_context(CephContext *cct);
 extern void lockdep_unregister_ceph_context(CephContext *cct);
 extern int lockdep_register(const char *n);
 extern void lockdep_unregister(int id);
-extern int lockdep_will_lock(const char *n, int id, bool force_backtrace=false);
+extern int lockdep_will_lock(const char *n, int id, bool force_backtrace=false,
+                            bool recursive=false);
 extern int lockdep_locked(const char *n, int id, bool force_backtrace=false);
 extern int lockdep_will_unlock(const char *n, int id);
 extern int lockdep_dump_locks();