]>
git.proxmox.com Git - ceph.git/blob - 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
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.
15 #ifndef CEPH_MCACHEEXPIRE_H
16 #define CEPH_MCACHEEXPIRE_H
18 #include <boost/utility/string_view.hpp>
20 #include "mds/mdstypes.h"
22 class MCacheExpire
: public Message
{
27 group things by realm (auth delgation root), since that's how auth is determined.
28 that makes it less work to process when exports are in progress.
31 map
<vinodeno_t
, uint32_t> inodes
;
32 map
<dirfrag_t
, uint32_t> dirs
;
33 map
<dirfrag_t
, map
<pair
<string
,snapid_t
>,uint32_t> > dentries
;
35 void merge(realm
& o
) {
36 inodes
.insert(o
.inodes
.begin(), o
.inodes
.end());
37 dirs
.insert(o
.dirs
.begin(), o
.dirs
.end());
38 for (map
<dirfrag_t
,map
<pair
<string
,snapid_t
>,uint32_t> >::iterator p
= o
.dentries
.begin();
39 p
!= o
.dentries
.end();
41 if (dentries
.count(p
->first
) == 0)
42 dentries
[p
->first
] = p
->second
;
44 dentries
[p
->first
].insert(p
->second
.begin(), p
->second
.end());
48 void encode(bufferlist
&bl
) const {
51 ::encode(dentries
, bl
);
53 void decode(bufferlist::iterator
&bl
) {
56 ::decode(dentries
, bl
);
59 WRITE_CLASS_ENCODER(realm
)
61 map
<dirfrag_t
, realm
> realms
;
63 int get_from() { return from
; }
65 MCacheExpire() : Message(MSG_MDS_CACHEEXPIRE
), from(-1) {}
67 Message(MSG_MDS_CACHEEXPIRE
),
70 ~MCacheExpire() override
{}
73 const char *get_type_name() const override
{ return "cache_expire";}
75 void add_inode(dirfrag_t r
, vinodeno_t vino
, unsigned nonce
) {
76 realms
[r
].inodes
[vino
] = nonce
;
78 void add_dir(dirfrag_t r
, dirfrag_t df
, unsigned nonce
) {
79 realms
[r
].dirs
[df
] = nonce
;
81 void add_dentry(dirfrag_t r
, dirfrag_t df
, boost::string_view dn
, snapid_t last
, unsigned nonce
) {
82 realms
[r
].dentries
[df
][pair
<string
,snapid_t
>(std::string(dn
),last
)] = nonce
;
85 void add_realm(dirfrag_t df
, realm
& r
) {
86 if (realms
.count(df
) == 0)
92 void decode_payload() override
{
93 bufferlist::iterator p
= payload
.begin();
98 void encode_payload(uint64_t features
) override
{
99 ::encode(from
, payload
);
100 ::encode(realms
, payload
);
104 WRITE_CLASS_ENCODER(MCacheExpire::realm
)