1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
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.
16 #ifndef CEPH_LOCALLOCK_H
17 #define CEPH_LOCALLOCK_H
19 #include "SimpleLock.h"
21 class LocalLockC
: public SimpleLock
{
23 LocalLockC(MDSCacheObject
*o
, LockType
*t
) :
25 set_state(LOCK_LOCK
); // always.
28 bool is_locallock() const override
{
32 bool can_xlock_local() const {
33 return !is_wrlocked() && (get_xlock_by() == MutationRef());
36 bool can_wrlock() const {
39 void get_wrlock(client_t client
) {
40 ceph_assert(can_wrlock());
41 SimpleLock::get_wrlock();
42 last_wrlock_client
= client
;
45 SimpleLock::put_wrlock();
46 if (get_num_wrlocks() == 0)
47 last_wrlock_client
= client_t();
49 client_t
get_last_wrlock_client() const {
50 return last_wrlock_client
;
53 void print(std::ostream
& out
) const override
{
56 if (last_wrlock_client
>= 0)
57 out
<< " last_client=" << last_wrlock_client
;
62 client_t last_wrlock_client
;