From: Kotresh HR Date: Tue, 4 Mar 2025 03:31:57 +0000 (+0530) Subject: mds: Store remote inode number in referent inode X-Git-Tag: v20.3.0~377^2~48 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3c034df67942085854f0a5a7b123282c7d9b2e8a;p=ceph.git mds: Store remote inode number in referent inode Hardlink referent inode plumbing continues. The remote inode information contains the following. 1. remote_ino - remote inode number 2. d_type 3. alternate_name With the introduction of the referent inode as a full blown CInode for the hardlink, these information needs to be part of the inode. Hence add 'remote_ino' field to the inode. The exisiting 'd_type' and 'alternate_name' fields could be used. Fixes: https://tracker.ceph.com/issues/54205 Signed-off-by: Kotresh HR --- diff --git a/src/include/cephfs/types.h b/src/include/cephfs/types.h index 5940621abed..c9da5068924 100644 --- a/src/include/cephfs/types.h +++ b/src/include/cephfs/types.h @@ -943,6 +943,8 @@ struct inode_t { optmetadata_multiton optmetadata; + inodeno_t remote_ino = 0; // referent inode - remote inode link + private: bool older_is_consistent(const inode_t &other) const; }; @@ -951,7 +953,7 @@ private: template class Allocator> void inode_t::encode(ceph::buffer::list &bl, uint64_t features) const { - ENCODE_START(20, 6, bl); + ENCODE_START(21, 6, bl); encode(ino, bl); encode(rdev, bl); @@ -1013,6 +1015,7 @@ void inode_t::encode(ceph::buffer::list &bl, uint64_t features) const encode(optmetadata, bl, features); + encode(remote_ino, bl); ENCODE_FINISH(bl); } @@ -1135,6 +1138,9 @@ void inode_t::decode(ceph::buffer::list::const_iterator &p) decode(optmetadata, p); } + if (struct_v >= 21) { + decode(remote_ino, p); + } DECODE_FINISH(p); } @@ -1213,6 +1219,7 @@ void inode_t::dump(ceph::Formatter *f) const f->dump_stream("last_scrub_stamp") << last_scrub_stamp; f->dump_unsigned("last_scrub_version", last_scrub_version); + f->dump_unsigned("remote_ino", remote_ino); } template class Allocator> @@ -1272,6 +1279,7 @@ void inode_t::decode_json(JSONObj *obj) JSONDecoder::decode_json("quota", quota, obj, true); JSONDecoder::decode_json("last_scrub_stamp", last_scrub_stamp, obj, true); JSONDecoder::decode_json("last_scrub_version", last_scrub_version, obj, true); + JSONDecoder::decode_json("remote_ino", remote_ino.val, obj, true); } template class Allocator> @@ -1317,7 +1325,8 @@ int inode_t::compare(const inode_t &other, bool *divergent !(accounted_rstat == other.accounted_rstat) || file_data_version != other.file_data_version || xattr_version != other.xattr_version || - backtrace_version != other.backtrace_version) { + backtrace_version != other.backtrace_version || + remote_ino != other.remote_ino) { *divergent = true; } return 0; diff --git a/src/mds/CDentry.cc b/src/mds/CDentry.cc index b5bace01bc9..212637e82f4 100644 --- a/src/mds/CDentry.cc +++ b/src/mds/CDentry.cc @@ -272,6 +272,7 @@ void CDentry::link_remote(CDentry::linkage_t *dnl, CInode *remote_in, CInode *re dnl->inode = remote_in; if (referent_in) { + ceph_assert(referent_in->get_remote_ino() == dnl->get_remote_ino()); dnl->referent_inode = referent_in; dnl->referent_ino = referent_in->ino(); } @@ -314,6 +315,7 @@ void CDentry::push_projected_linkage(CInode *referent_inode, inodeno_t remote_in linkage_t *p = _project_linkage(); p->referent_inode = referent_inode; referent_inode->push_projected_parent(this); + referent_inode->set_remote_ino(remote_ino); p->referent_ino = referent_ino; p->remote_ino = remote_ino; diff --git a/src/mds/CInode.h b/src/mds/CInode.h index f70e01312cc..cd3e440d06b 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -651,8 +651,10 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counterino; } + inodeno_t get_remote_ino() const { return get_inode()->remote_ino; } vinodeno_t vino() const { return vinodeno_t(ino(), last); } int d_type() const { return IFTODT(get_inode()->mode); } + bool is_referent_remote() const { return get_remote_ino() != 0; } 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 { @@ -671,6 +673,9 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counterremote_ino = ino; } + // note: this overloads MDSCacheObject bool is_ambiguous_auth() const { return state_test(STATE_AMBIGUOUSAUTH) ||