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: v16.2.5~33^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=31f1c3348fbfeb99957ec14be6c13f8aad166c56;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) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index ffd38b5bf8ee..819518cfb1a1 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -161,7 +161,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; } @@ -4565,7 +4565,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. @@ -4578,10 +4578,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 4fa9c6938558..f03a6f378ef1 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -168,7 +168,7 @@ struct Inode { bool fscrypt = false; // fscrypt enabled ? - 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 f0cac9e1a0db..eb73efa03663 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 177e02d06320..fcf215c709bb 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -647,7 +647,7 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counterino; } vinodeno_t vino() const { return vinodeno_t(ino(), last); } int d_type() const { return IFTODT(get_inode()->mode); } - bool is_root() const { return ino() == MDS_INO_ROOT; } + bool is_root() const { return ino() == CEPH_INO_ROOT; } bool is_stray() const { return MDS_INO_IS_STRAY(ino()); } mds_rank_t get_stray_owner() const { return (mds_rank_t)MDS_INO_STRAY_OWNER(ino()); diff --git a/src/mds/DamageTable.cc b/src/mds/DamageTable.cc index c474b078b21d..150ad5764825 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 37a36179fd62..f54bd4f98150 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -268,7 +268,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; @@ -409,7 +409,7 @@ CInode *MDCache::create_system_inode(inodeno_t ino, int mode) CInode *MDCache::create_root_inode() { - CInode *in = create_system_inode(MDS_INO_ROOT, S_IFDIR|0755); + CInode *in = create_system_inode(CEPH_INO_ROOT, S_IFDIR|0755); auto _inode = in->_get_inode(); _inode->uid = g_conf()->mds_root_ino_uid; _inode->gid = g_conf()->mds_root_ino_gid; @@ -610,10 +610,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()); } } @@ -1039,7 +1039,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]; @@ -9722,7 +9722,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; } @@ -10732,7 +10732,7 @@ void MDCache::decode_replica_inode(CInode *&in, bufferlist::const_iterator& p, C in->_decode_base(p); in->_decode_locks_state_for_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; @@ -11334,7 +11334,7 @@ bool MDCache::can_fragment(CInode *diri, const std::vector& dirs) dout(7) << "can_fragment: i won't merge|split anything in stray" << dendl; return false; } - if (diri->is_mdsdir() || diri->ino() == MDS_INO_CEPH) { + if (diri->is_mdsdir() || diri->ino() == CEPH_INO_CEPH) { dout(7) << "can_fragment: i won't fragment mdsdir or .ceph" << dendl; return false; } @@ -12417,7 +12417,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/Server.cc b/src/mds/Server.cc index 30425d47cf87..782c34e7e09d 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -3916,7 +3916,7 @@ void Server::handle_client_lookup_ino(MDRequestRef& mdr, * * [1] https://tracker.ceph.com/issues/49922 */ - if (_ino < MDS_INO_SYSTEM_BASE && _ino != MDS_INO_ROOT) { + if (_ino < MDS_INO_SYSTEM_BASE && _ino != CEPH_INO_ROOT) { respond_to_request(mdr, -CEPHFS_ESTALE); return; } diff --git a/src/mds/SnapRealm.cc b/src/mds/SnapRealm.cc index a8d683c26b1b..09ddd9181edb 100644 --- a/src/mds/SnapRealm.cc +++ b/src/mds/SnapRealm.cc @@ -55,7 +55,7 @@ ostream& operator<<(ostream& out, const SnapRealm& realm) SnapRealm::SnapRealm(MDCache *c, CInode *in) : mdcache(c), inode(in), inodes_with_caps(member_offset(CInode, item_caps)) { - global = (inode->ino() == MDS_INO_GLOBAL_SNAPREALM); + global = (inode->ino() == CEPH_INO_GLOBAL_SNAPREALM); } /* diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index 91dce0ad6982..5e9fb7d04fb0 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -23,6 +23,7 @@ #include "include/interval_set.h" #include "include/compact_set.h" #include "include/fs_types.h" +#include "include/ceph_fs.h" #include "inode_backtrace.h" @@ -41,13 +42,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) @@ -66,7 +61,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 34504fd4dca9..649e96b15ad3 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/CDentry.h" #include "mds/CInode.h" @@ -370,7 +371,7 @@ int MetadataDriver::inject_unlinked_inode( // be ignoring dirfrags that exist inode_data.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_data.snap_blob); @@ -411,7 +412,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; } @@ -431,7 +432,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; } @@ -897,8 +898,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()