]>
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 "mds/mdstypes.h"
20 class MCacheExpire
: public Message
{
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.
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
;
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();
39 if (dentries
.count(p
->first
) == 0)
40 dentries
[p
->first
] = p
->second
;
42 dentries
[p
->first
].insert(p
->second
.begin(), p
->second
.end());
46 void encode(bufferlist
&bl
) const {
49 ::encode(dentries
, bl
);
51 void decode(bufferlist::iterator
&bl
) {
54 ::decode(dentries
, bl
);
57 WRITE_CLASS_ENCODER(realm
)
59 map
<dirfrag_t
, realm
> realms
;
61 int get_from() { return from
; }
63 MCacheExpire() : Message(MSG_MDS_CACHEEXPIRE
), from(-1) {}
65 Message(MSG_MDS_CACHEEXPIRE
),
68 ~MCacheExpire() override
{}
71 const char *get_type_name() const override
{ return "cache_expire";}
73 void add_inode(dirfrag_t r
, vinodeno_t vino
, unsigned nonce
) {
74 realms
[r
].inodes
[vino
] = nonce
;
76 void add_dir(dirfrag_t r
, dirfrag_t df
, unsigned nonce
) {
77 realms
[r
].dirs
[df
] = nonce
;
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
;
83 void add_realm(dirfrag_t df
, realm
& r
) {
84 if (realms
.count(df
) == 0)
90 void decode_payload() override
{
91 bufferlist::iterator p
= payload
.begin();
96 void encode_payload(uint64_t features
) override
{
97 ::encode(from
, payload
);
98 ::encode(realms
, payload
);
102 WRITE_CLASS_ENCODER(MCacheExpire::realm
)