]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: Store remote inode number in referent inode
authorKotresh HR <khiremat@redhat.com>
Tue, 4 Mar 2025 03:31:57 +0000 (09:01 +0530)
committerKotresh HR <khiremat@redhat.com>
Tue, 4 Mar 2025 06:18:11 +0000 (11:48 +0530)
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 <khiremat@redhat.com>
src/include/cephfs/types.h
src/mds/CDentry.cc
src/mds/CInode.h

index 5940621abed56f4964bcad5e43db76b9957fc85b..c9da5068924106f2de56f9887ef224e95ec8ff0c 100644 (file)
@@ -943,6 +943,8 @@ struct inode_t {
 
   optmetadata_multiton<optmetadata_singleton_server_t,Allocator> 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<template<typename> class Allocator>
 void inode_t<Allocator>::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<Allocator>::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<Allocator>::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<Allocator>::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<template<typename> class Allocator>
@@ -1272,6 +1279,7 @@ void inode_t<Allocator>::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<template<typename> class Allocator>
@@ -1317,7 +1325,8 @@ int inode_t<Allocator>::compare(const inode_t<Allocator> &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;
index b5bace01bc909e588ff80f4139f43f91616d868a..212637e82f4359e7890efaee3b32ef42c1e36950 100644 (file)
@@ -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;
index f70e01312cc3db78a9451718eabb7ed53aae0767..cd3e440d06bc7bce7598c6175f299d7c84cedef5 100644 (file)
@@ -651,8 +651,10 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CIno
   // -- accessors --
 
   inodeno_t ino() const { return get_inode()->ino; }
+  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 Counter<CIno
 
   bool is_head() const { return last == CEPH_NOSNAP; }
 
+  // set remote inode
+  void set_remote_ino(inodeno_t ino) { _get_inode()->remote_ino = ino; }
+
   // note: this overloads MDSCacheObject
   bool is_ambiguous_auth() const {
     return state_test(STATE_AMBIGUOUSAUTH) ||