]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
7c673cae FG |
14 | |
15 | #include "common/mutex_debug.h" | |
16 | #include "common/perf_counters.h" | |
17 | #include "common/ceph_context.h" | |
18 | #include "common/config.h" | |
7c673cae FG |
19 | |
20 | namespace ceph { | |
21 | namespace mutex_debug_detail { | |
22 | enum { | |
23 | l_mutex_first = 999082, | |
24 | l_mutex_wait, | |
25 | l_mutex_last | |
26 | }; | |
27 | ||
9f95a23c TL |
28 | mutex_debugging_base::mutex_debugging_base(std::string group, bool ld, bool bt) |
29 | : group(std::move(group)), | |
30 | lockdep(ld), | |
31 | backtrace(bt) | |
11fdf7f2 | 32 | { |
9f95a23c | 33 | if (_enable_lockdep()) { |
7c673cae | 34 | _register(); |
9f95a23c | 35 | } |
7c673cae FG |
36 | } |
37 | ||
38 | mutex_debugging_base::~mutex_debugging_base() { | |
11fdf7f2 | 39 | ceph_assert(nlock == 0); |
9f95a23c | 40 | if (_enable_lockdep()) { |
7c673cae FG |
41 | lockdep_unregister(id); |
42 | } | |
43 | } | |
44 | ||
45 | void mutex_debugging_base::_register() { | |
9f95a23c | 46 | id = lockdep_register(group.c_str()); |
7c673cae | 47 | } |
11fdf7f2 | 48 | void mutex_debugging_base::_will_lock(bool recursive) { // about to lock |
9f95a23c | 49 | id = lockdep_will_lock(group.c_str(), id, backtrace, recursive); |
7c673cae FG |
50 | } |
51 | void mutex_debugging_base::_locked() { // just locked | |
9f95a23c | 52 | id = lockdep_locked(group.c_str(), id, backtrace); |
7c673cae FG |
53 | } |
54 | void mutex_debugging_base::_will_unlock() { // about to unlock | |
9f95a23c | 55 | id = lockdep_will_unlock(group.c_str(), id); |
7c673cae FG |
56 | } |
57 | ||
7c673cae FG |
58 | } // namespace mutex_debug_detail |
59 | } // namespace ceph |