X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fmessages%2FMCacheExpire.h;fp=src%2Fceph%2Fsrc%2Fmessages%2FMCacheExpire.h;h=a6014fcadd94607b9b93bec264c2f6ad58078a3c;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/messages/MCacheExpire.h b/src/ceph/src/messages/MCacheExpire.h new file mode 100644 index 0000000..a6014fc --- /dev/null +++ b/src/ceph/src/messages/MCacheExpire.h @@ -0,0 +1,104 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2004-2006 Sage Weil + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#ifndef CEPH_MCACHEEXPIRE_H +#define CEPH_MCACHEEXPIRE_H + +#include "mds/mdstypes.h" + +class MCacheExpire : public Message { + __s32 from; + +public: + /* + group things by realm (auth delgation root), since that's how auth is determined. + that makes it less work to process when exports are in progress. + */ + struct realm { + map inodes; + map dirs; + map,uint32_t> > dentries; + + void merge(realm& o) { + inodes.insert(o.inodes.begin(), o.inodes.end()); + dirs.insert(o.dirs.begin(), o.dirs.end()); + for (map,uint32_t> >::iterator p = o.dentries.begin(); + p != o.dentries.end(); + ++p) { + if (dentries.count(p->first) == 0) + dentries[p->first] = p->second; + else + dentries[p->first].insert(p->second.begin(), p->second.end()); + } + } + + void encode(bufferlist &bl) const { + ::encode(inodes, bl); + ::encode(dirs, bl); + ::encode(dentries, bl); + } + void decode(bufferlist::iterator &bl) { + ::decode(inodes, bl); + ::decode(dirs, bl); + ::decode(dentries, bl); + } + }; + WRITE_CLASS_ENCODER(realm) + + map realms; + + int get_from() { return from; } + + MCacheExpire() : Message(MSG_MDS_CACHEEXPIRE), from(-1) {} + MCacheExpire(int f) : + Message(MSG_MDS_CACHEEXPIRE), + from(f) { } +private: + ~MCacheExpire() override {} + +public: + const char *get_type_name() const override { return "cache_expire";} + + void add_inode(dirfrag_t r, vinodeno_t vino, unsigned nonce) { + realms[r].inodes[vino] = nonce; + } + void add_dir(dirfrag_t r, dirfrag_t df, unsigned nonce) { + realms[r].dirs[df] = nonce; + } + void add_dentry(dirfrag_t r, dirfrag_t df, const string& dn, snapid_t last, unsigned nonce) { + realms[r].dentries[df][pair(dn,last)] = nonce; + } + + void add_realm(dirfrag_t df, realm& r) { + if (realms.count(df) == 0) + realms[df] = r; + else + realms[df].merge(r); + } + + void decode_payload() override { + bufferlist::iterator p = payload.begin(); + ::decode(from, p); + ::decode(realms, p); + } + + void encode_payload(uint64_t features) override { + ::encode(from, payload); + ::encode(realms, payload); + } +}; + +WRITE_CLASS_ENCODER(MCacheExpire::realm) + +#endif