]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MCacheExpire.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / messages / MCacheExpire.h
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 */
14
15 #ifndef CEPH_MCACHEEXPIRE_H
16 #define CEPH_MCACHEEXPIRE_H
17
18 #include "mds/mdstypes.h"
19
20 class MCacheExpire : public Message {
21 __s32 from;
22
23 public:
24 /*
25 group things by realm (auth delgation root), since that's how auth is determined.
26 that makes it less work to process when exports are in progress.
27 */
28 struct realm {
29 map<vinodeno_t, uint32_t> inodes;
30 map<dirfrag_t, uint32_t> dirs;
31 map<dirfrag_t, map<pair<string,snapid_t>,uint32_t> > dentries;
32
33 void merge(realm& o) {
34 inodes.insert(o.inodes.begin(), o.inodes.end());
35 dirs.insert(o.dirs.begin(), o.dirs.end());
36 for (map<dirfrag_t,map<pair<string,snapid_t>,uint32_t> >::iterator p = o.dentries.begin();
37 p != o.dentries.end();
38 ++p) {
39 if (dentries.count(p->first) == 0)
40 dentries[p->first] = p->second;
41 else
42 dentries[p->first].insert(p->second.begin(), p->second.end());
43 }
44 }
45
46 void encode(bufferlist &bl) const {
47 ::encode(inodes, bl);
48 ::encode(dirs, bl);
49 ::encode(dentries, bl);
50 }
51 void decode(bufferlist::iterator &bl) {
52 ::decode(inodes, bl);
53 ::decode(dirs, bl);
54 ::decode(dentries, bl);
55 }
56 };
57 WRITE_CLASS_ENCODER(realm)
58
59 map<dirfrag_t, realm> realms;
60
61 int get_from() { return from; }
62
63 MCacheExpire() : Message(MSG_MDS_CACHEEXPIRE), from(-1) {}
64 MCacheExpire(int f) :
65 Message(MSG_MDS_CACHEEXPIRE),
66 from(f) { }
67 private:
68 ~MCacheExpire() override {}
69
70 public:
71 const char *get_type_name() const override { return "cache_expire";}
72
73 void add_inode(dirfrag_t r, vinodeno_t vino, unsigned nonce) {
74 realms[r].inodes[vino] = nonce;
75 }
76 void add_dir(dirfrag_t r, dirfrag_t df, unsigned nonce) {
77 realms[r].dirs[df] = nonce;
78 }
79 void add_dentry(dirfrag_t r, dirfrag_t df, const string& dn, snapid_t last, unsigned nonce) {
80 realms[r].dentries[df][pair<string,snapid_t>(dn,last)] = nonce;
81 }
82
83 void add_realm(dirfrag_t df, realm& r) {
84 if (realms.count(df) == 0)
85 realms[df] = r;
86 else
87 realms[df].merge(r);
88 }
89
90 void decode_payload() override {
91 bufferlist::iterator p = payload.begin();
92 ::decode(from, p);
93 ::decode(realms, p);
94 }
95
96 void encode_payload(uint64_t features) override {
97 ::encode(from, payload);
98 ::encode(realms, payload);
99 }
100 };
101
102 WRITE_CLASS_ENCODER(MCacheExpire::realm)
103
104 #endif