]>
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 <string_view>
19 #include "mds/mdstypes.h"
20 #include "messages/MMDSOp.h"
22 class MCacheExpire final
: public MMDSOp
{
28 group things by realm (auth delgation root), since that's how auth is determined.
29 that makes it less work to process when exports are in progress.
32 std::map
<vinodeno_t
, uint32_t> inodes
;
33 std::map
<dirfrag_t
, uint32_t> dirs
;
34 std::map
<dirfrag_t
, std::map
<std::pair
<std::string
,snapid_t
>,uint32_t> > dentries
;
36 void merge(const realm
& o
) {
37 inodes
.insert(o
.inodes
.begin(), o
.inodes
.end());
38 dirs
.insert(o
.dirs
.begin(), o
.dirs
.end());
39 for (const auto &p
: o
.dentries
) {
40 auto em
= dentries
.emplace(std::piecewise_construct
, std::forward_as_tuple(p
.first
), std::forward_as_tuple(p
.second
));
42 em
.first
->second
.insert(p
.second
.begin(), p
.second
.end());
47 void encode(ceph::buffer::list
&bl
) const {
53 void decode(ceph::buffer::list::const_iterator
&bl
) {
60 WRITE_CLASS_ENCODER(realm
)
62 std::map
<dirfrag_t
, realm
> realms
;
64 int get_from() const { return from
; }
67 MCacheExpire() : MMDSOp
{MSG_MDS_CACHEEXPIRE
}, from(-1) {}
69 MMDSOp
{MSG_MDS_CACHEEXPIRE
},
71 ~MCacheExpire() final
{}
74 std::string_view
get_type_name() const override
{ return "cache_expire";}
76 void add_inode(dirfrag_t r
, vinodeno_t vino
, unsigned nonce
) {
77 realms
[r
].inodes
[vino
] = nonce
;
79 void add_dir(dirfrag_t r
, dirfrag_t df
, unsigned nonce
) {
80 realms
[r
].dirs
[df
] = nonce
;
82 void add_dentry(dirfrag_t r
, dirfrag_t df
, std::string_view dn
, snapid_t last
, unsigned nonce
) {
83 realms
[r
].dentries
[df
][std::pair
<std::string
,snapid_t
>(dn
,last
)] = nonce
;
86 void add_realm(dirfrag_t df
, const realm
& r
) {
87 auto em
= realms
.emplace(std::piecewise_construct
, std::forward_as_tuple(df
), std::forward_as_tuple(r
));
89 em
.first
->second
.merge(r
);
93 void decode_payload() override
{
95 auto p
= payload
.cbegin();
100 void encode_payload(uint64_t features
) override
{
102 encode(from
, payload
);
103 encode(realms
, payload
);
106 template<class T
, typename
... Args
>
107 friend boost::intrusive_ptr
<T
> ceph::make_message(Args
&&... args
);
108 template<class T
, typename
... Args
>
109 friend MURef
<T
> crimson::make_message(Args
&&... args
);
112 WRITE_CLASS_ENCODER(MCacheExpire::realm
)