From: Xiubo Li Date: Tue, 20 Apr 2021 01:08:20 +0000 (+0800) Subject: mds: move the inos 1,2 and 3 macros to ceph_fs.h X-Git-Tag: v14.2.22~35^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b92162e4df1581c8a7aabbb6f0149aebfe34844e;p=ceph.git mds: move the inos 1,2 and 3 macros to ceph_fs.h For inos 1 and 2 there has two places are defining them, to make sure we won't miss any one of them, let's define them in only one header file. Fixes: https://tracker.ceph.com/issues/50216 Signed-off-by: Xiubo Li (cherry picked from commit 8615807237458e8cebf9497a7431097cdc56c784) Conflicts: src/client/Inode.h src/mds/CInode.h src/mds/MDCache.cc src/mds/Server.cc src/mds/SnapServer.h - change MDS_INO_ROOT to CEPH_INO_ROOT in src/mds/SnapServer.h (nautilus-only) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index dfe2a23a6a78e..7a94f37fc3fb6 100755 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -132,7 +132,7 @@ void client_flush_set_callback(void *p, ObjectCacher::ObjectSet *oset) } bool Client::is_reserved_vino(vinodeno_t &vino) { - if (vino.ino < MDS_INO_SYSTEM_BASE && vino.ino != MDS_INO_ROOT) { + if (vino.ino < MDS_INO_SYSTEM_BASE && vino.ino != CEPH_INO_ROOT) { ldout(cct, -1) << __func__ << "attempt to access reserved inode number " << vino << dendl; return true; } @@ -4338,7 +4338,7 @@ void Client::trim_caps(MetaSession *s, uint64_t max) ++q; if (dn->lru_is_expireable()) { if (can_invalidate_dentries && - dn->dir->parent_inode->ino == MDS_INO_ROOT) { + dn->dir->parent_inode->ino == CEPH_INO_ROOT) { // Only issue one of these per DN for inodes in root: handle // others more efficiently by calling for root-child DNs at // the end of this function. @@ -4351,10 +4351,10 @@ void Client::trim_caps(MetaSession *s, uint64_t max) all = false; } } - if (in->ll_ref == 1 && in->ino != MDS_INO_ROOT) { + if (in->ll_ref == 1 && in->ino != CEPH_INO_ROOT) { _schedule_ino_release_callback(in.get()); } - if (all && in->ino != MDS_INO_ROOT) { + if (all && in->ino != CEPH_INO_ROOT) { ldout(cct, 20) << __func__ << " counting as trimmed: " << *in << dendl; trimmed++; } diff --git a/src/client/Inode.h b/src/client/Inode.h index b918e6b0f41ff..1b5862885a3bf 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -163,7 +163,7 @@ struct Inode { version_t inline_version; bufferlist inline_data; - bool is_root() const { return ino == MDS_INO_ROOT; } + bool is_root() const { return ino == CEPH_INO_ROOT; } bool is_symlink() const { return (mode & S_IFMT) == S_IFLNK; } bool is_dir() const { return (mode & S_IFMT) == S_IFDIR; } bool is_file() const { return (mode & S_IFMT) == S_IFREG; } diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index 1c73ff377bc08..f132b79eb2450 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -47,9 +47,15 @@ #define CEPH_MONC_PROTOCOL 15 /* server/client */ -#define CEPH_INO_ROOT 1 -#define CEPH_INO_CEPH 2 /* hidden .ceph dir */ -#define CEPH_INO_LOST_AND_FOUND 4 /* reserved ino for use in recovery */ +#define CEPH_INO_ROOT 1 +/* + * hidden .ceph dir, which is no longer created but + * recognised in existing filesystems so that we + * don't try to fragment it. + */ +#define CEPH_INO_CEPH 2 +#define CEPH_INO_GLOBAL_SNAPREALM 3 +#define CEPH_INO_LOST_AND_FOUND 4 /* reserved ino for use in recovery */ /* arbitrary limit on max # of monitors (cluster of 3 is typical) */ #define CEPH_MAX_MON 31 diff --git a/src/mds/CInode.h b/src/mds/CInode.h index cbe8779a20188..ff872b3bacefb 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -743,7 +743,7 @@ public: // -- accessors -- - bool is_root() const { return inode.ino == MDS_INO_ROOT; } + bool is_root() const { return ino() == CEPH_INO_ROOT; } bool is_stray() const { return MDS_INO_IS_STRAY(inode.ino); } mds_rank_t get_stray_owner() const { return (mds_rank_t)MDS_INO_STRAY_OWNER(inode.ino); diff --git a/src/mds/DamageTable.cc b/src/mds/DamageTable.cc index c474b078b21d1..150ad57648257 100644 --- a/src/mds/DamageTable.cc +++ b/src/mds/DamageTable.cc @@ -164,11 +164,8 @@ bool DamageTable::notify_dirfrag(inodeno_t ino, frag_t frag, { // Special cases: damage to these dirfrags is considered fatal to // the MDS rank that owns them. - if ( - (MDS_INO_IS_STRAY(ino) && MDS_INO_STRAY_OWNER(ino) == rank) - || - (ino == MDS_INO_ROOT) - ) { + if ((MDS_INO_IS_STRAY(ino) && MDS_INO_STRAY_OWNER(ino) == rank) + || (ino == CEPH_INO_ROOT)) { derr << "Damage to fragment " << frag << " of ino " << ino << " is fatal because it is a system directory for this rank" << dendl; return true; diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 83497ff06dfc2..01415447cadcc 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -248,7 +248,7 @@ void MDCache::add_inode(CInode *in) } if (in->ino() < MDS_INO_SYSTEM_BASE) { - if (in->ino() == MDS_INO_ROOT) + if (in->ino() == CEPH_INO_ROOT) root = in; else if (in->ino() == MDS_INO_MDSDIR(mds->get_nodeid())) myin = in; @@ -387,7 +387,7 @@ CInode *MDCache::create_system_inode(inodeno_t ino, int mode) CInode *MDCache::create_root_inode() { - CInode *i = create_system_inode(MDS_INO_ROOT, S_IFDIR|0755); + CInode *i = create_system_inode(CEPH_INO_ROOT, S_IFDIR|0755); i->inode.uid = g_conf()->mds_root_ino_uid; i->inode.gid = g_conf()->mds_root_ino_gid; i->inode.layout = default_file_layout; @@ -580,10 +580,10 @@ void MDCache::open_root_inode(MDSContext *c) { if (mds->get_nodeid() == mds->mdsmap->get_root()) { CInode *in; - in = create_system_inode(MDS_INO_ROOT, S_IFDIR|0755); // initially inaccurate! + in = create_system_inode(CEPH_INO_ROOT, S_IFDIR|0755); // initially inaccurate! in->fetch(c); } else { - discover_base_ino(MDS_INO_ROOT, c, mds->mdsmap->get_root()); + discover_base_ino(CEPH_INO_ROOT, c, mds->mdsmap->get_root()); } } @@ -980,7 +980,7 @@ void MDCache::adjust_bounded_subtree_auth(CDir *dir, const set& bounds, m show_subtrees(); CDir *root; - if (dir->ino() == MDS_INO_ROOT) { + if (dir->ino() == CEPH_INO_ROOT) { root = dir; // bootstrap hack. if (subtrees.count(root) == 0) { subtrees[root]; @@ -9549,7 +9549,7 @@ void MDCache::request_kill(MDRequestRef& mdr) void MDCache::create_global_snaprealm() { CInode *in = new CInode(this); // dummy inode - create_unlinked_system_inode(in, MDS_INO_GLOBAL_SNAPREALM, S_IFDIR|0755); + create_unlinked_system_inode(in, CEPH_INO_GLOBAL_SNAPREALM, S_IFDIR|0755); add_inode(in); global_snaprealm = in->snaprealm; } @@ -10532,7 +10532,7 @@ CInode *MDCache::add_replica_inode(bufferlist::const_iterator& p, CDentry *dn, M in = new CInode(this, false, 1, last); in->decode_replica(p, true); add_inode(in); - if (in->ino() == MDS_INO_ROOT) + if (in->ino() == CEPH_INO_ROOT) in->inode_auth.first = 0; else if (in->is_mdsdir()) in->inode_auth.first = in->ino() - MDS_INO_MDSDIR_OFFSET; @@ -11088,7 +11088,7 @@ bool MDCache::can_fragment(CInode *diri, list& dirs) dout(7) << "can_fragment: i won't merge|split anything in stray" << dendl; return false; } - if (diri->is_mdsdir() || diri->is_stray() || diri->ino() == MDS_INO_CEPH) { + if (diri->is_mdsdir() || diri->is_stray() || diri->ino() == CEPH_INO_CEPH) { dout(7) << "can_fragment: i won't fragment the mdsdir or straydir or .ceph" << dendl; return false; } @@ -12170,7 +12170,7 @@ void MDCache::show_subtrees(int dbl, bool force_print) dout(ceph::dout::need_dynamic(dbl)) << indent << "|_" << pad << s << " " << auth << *dir << dendl; - if (dir->ino() == MDS_INO_ROOT) + if (dir->ino() == CEPH_INO_ROOT) ceph_assert(dir->inode == root); if (dir->ino() == MDS_INO_MDSDIR(mds->get_nodeid())) ceph_assert(dir->inode == myin); diff --git a/src/mds/SnapRealm.cc b/src/mds/SnapRealm.cc index 4ef775dc69711..44abfb45a175d 100644 --- a/src/mds/SnapRealm.cc +++ b/src/mds/SnapRealm.cc @@ -68,7 +68,7 @@ SnapRealm::SnapRealm(MDCache *c, CInode *in) : mdcache(c), inode(in), parent(nullptr), num_open_past_parents(0), inodes_with_caps(0) { - global = (inode->ino() == MDS_INO_GLOBAL_SNAPREALM); + global = (inode->ino() == CEPH_INO_GLOBAL_SNAPREALM); } void SnapRealm::add_open_past_parent(SnapRealm *parent, snapid_t last) diff --git a/src/mds/SnapServer.h b/src/mds/SnapServer.h index f0a92ce8b558b..0ab2ccfea5c1d 100644 --- a/src/mds/SnapServer.h +++ b/src/mds/SnapServer.h @@ -119,7 +119,7 @@ public: void check_osd_map(bool force); void mark_base_recursively_scrubbed(inodeno_t ino) { - if (ino == MDS_INO_ROOT) + if (ino == CEPH_INO_ROOT) root_scrubbed = true; else if (ino == MDS_INO_MDSDIR(rank)) mdsdir_scrubbed = true; diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index d241030a4c169..33f9496e77d4a 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -23,6 +23,7 @@ #include "include/compact_map.h" #include "include/compact_set.h" #include "include/fs_types.h" +#include "include/ceph_fs.h" #include "inode_backtrace.h" @@ -40,13 +41,7 @@ #define MAX_MDS 0x100 #define NUM_STRAY 10 -#define MDS_INO_ROOT 1 - -// No longer created but recognised in existing filesystems -// so that we don't try to fragment it. -#define MDS_INO_CEPH 2 - -#define MDS_INO_GLOBAL_SNAPREALM 3 +// Inode numbers 1,2 and 4 please see CEPH_INO_* in include/ceph_fs.h #define MDS_INO_MDSDIR_OFFSET (1*MAX_MDS) #define MDS_INO_STRAY_OFFSET (6*MAX_MDS) @@ -65,7 +60,7 @@ #define MDS_INO_IS_STRAY(i) ((i) >= MDS_INO_STRAY_OFFSET && (i) < (MDS_INO_STRAY_OFFSET+(MAX_MDS*NUM_STRAY))) #define MDS_INO_IS_MDSDIR(i) ((i) >= MDS_INO_MDSDIR_OFFSET && (i) < (MDS_INO_MDSDIR_OFFSET+MAX_MDS)) #define MDS_INO_MDSDIR_OWNER(i) (signed ((unsigned (i)) - MDS_INO_MDSDIR_OFFSET)) -#define MDS_INO_IS_BASE(i) ((i) == MDS_INO_ROOT || (i) == MDS_INO_GLOBAL_SNAPREALM || MDS_INO_IS_MDSDIR(i)) +#define MDS_INO_IS_BASE(i) ((i) == CEPH_INO_ROOT || (i) == CEPH_INO_GLOBAL_SNAPREALM || MDS_INO_IS_MDSDIR(i)) #define MDS_INO_STRAY_OWNER(i) (signed (((unsigned (i)) - MDS_INO_STRAY_OFFSET) / NUM_STRAY)) #define MDS_INO_STRAY_INDEX(i) (((unsigned (i)) - MDS_INO_STRAY_OFFSET) % NUM_STRAY) diff --git a/src/tools/cephfs/DataScan.cc b/src/tools/cephfs/DataScan.cc index 8fb670ad08e62..64974b59fc00f 100644 --- a/src/tools/cephfs/DataScan.cc +++ b/src/tools/cephfs/DataScan.cc @@ -17,6 +17,7 @@ #include "common/ceph_argparse.h" #include #include "include/util.h" +#include "include/ceph_fs.h" #include "mds/CInode.h" #include "mds/InoTable.h" @@ -368,7 +369,7 @@ int MetadataDriver::inject_unlinked_inode( // be ignoring dirfrags that exist inode.damage_flags |= (DAMAGE_STATS | DAMAGE_RSTATS | DAMAGE_FRAGTREE); - if (inono == MDS_INO_ROOT || MDS_INO_IS_MDSDIR(inono)) { + if (inono == CEPH_INO_ROOT || MDS_INO_IS_MDSDIR(inono)) { sr_t srnode; srnode.seq = 1; encode(srnode, inode.snap_blob); @@ -409,7 +410,7 @@ int MetadataDriver::root_exists(inodeno_t ino, bool *result) int MetadataDriver::init_roots(int64_t data_pool_id) { int r = 0; - r = inject_unlinked_inode(MDS_INO_ROOT, S_IFDIR|0755, data_pool_id); + r = inject_unlinked_inode(CEPH_INO_ROOT, S_IFDIR|0755, data_pool_id); if (r != 0) { return r; } @@ -429,7 +430,7 @@ int MetadataDriver::init_roots(int64_t data_pool_id) int MetadataDriver::check_roots(bool *result) { int r; - r = root_exists(MDS_INO_ROOT, result); + r = root_exists(CEPH_INO_ROOT, result); if (r != 0) { return r; } @@ -895,8 +896,8 @@ bool DataScan::valid_ino(inodeno_t ino) const return (ino >= inodeno_t((1ull << 40))) || (MDS_INO_IS_STRAY(ino)) || (MDS_INO_IS_MDSDIR(ino)) - || ino == MDS_INO_ROOT - || ino == MDS_INO_CEPH; + || ino == CEPH_INO_ROOT + || ino == CEPH_INO_CEPH; } int DataScan::scan_links()