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.
19 #include "msg/Message.h"
20 #include "mds/locks.h"
22 class MLock : public Message {
23 int32_t action; // action type
24 int32_t asker; // who is initiating this request
25 metareqid_t reqid; // for remote lock requests
27 __u16 lock_type; // lock object type
28 MDSCacheObjectInfo object_info;
30 bufferlist lockdata; // and possibly some data
33 bufferlist& get_data() { return lockdata; }
34 int get_asker() { return asker; }
35 int get_action() { return action; }
36 metareqid_t get_reqid() { return reqid; }
38 int get_lock_type() { return lock_type; }
39 MDSCacheObjectInfo &get_object_info() { return object_info; }
41 MLock() : Message(MSG_MDS_LOCK) {}
42 MLock(int ac, int as) :
43 Message(MSG_MDS_LOCK),
44 action(ac), asker(as),
46 MLock(SimpleLock *lock, int ac, int as) :
47 Message(MSG_MDS_LOCK),
48 action(ac), asker(as),
49 lock_type(lock->get_type()) {
50 lock->get_parent()->set_object_info(object_info);
52 MLock(SimpleLock *lock, int ac, int as, bufferlist& bl) :
53 Message(MSG_MDS_LOCK),
54 action(ac), asker(as), lock_type(lock->get_type()) {
55 lock->get_parent()->set_object_info(object_info);
62 const char *get_type_name() const override { return "ILock"; }
63 void print(ostream& out) const override {
64 out << "lock(a=" << get_lock_action_name(action)
65 << " " << get_lock_type_name(lock_type)
70 void set_reqid(metareqid_t ri) { reqid = ri; }
71 void set_data(const bufferlist& lockdata) {
72 this->lockdata = lockdata;
75 void decode_payload() override {
76 bufferlist::iterator p = payload.begin();
80 ::decode(lock_type, p);
81 ::decode(object_info, p);
82 ::decode(lockdata, p);
84 void encode_payload(uint64_t features) override {
85 ::encode(asker, payload);
86 ::encode(action, payload);
87 ::encode(reqid, payload);
88 ::encode(lock_type, payload);
89 ::encode(object_info, payload);
90 ::encode(lockdata, payload);