]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: Make referent inodes a optional feature
authorKotresh HR <khiremat@redhat.com>
Wed, 19 Feb 2025 16:44:30 +0000 (22:14 +0530)
committerKotresh HR <khiremat@redhat.com>
Tue, 4 Mar 2025 06:20:47 +0000 (11:50 +0530)
Hardlink referent inode plumbing work continues.
Add a fs option 'allow_referent_inodes'. Enabling the option,
allows the creation of referent inodes for the hardlinks
to store backtrace and viceversa. The option is disabled
by default so that it doesn't affect existing filesystems.

The option is introduced to handle upgrade as there is no
easy way to trace all the hardlinks of a file on existing
file systems to create referent inodes and update backtrace
online. So the feature is enabled only on new filesystems

Fixes: https://tracker.ceph.com/issues/54205
Signed-off-by: Kotresh HR <khiremat@redhat.com>
src/include/ceph_fs.h
src/mds/MDSMap.cc
src/mds/MDSMap.h
src/mon/FSCommands.cc
src/mon/MonCommands.h

index f10189dd09f00e5bd0b959278d49283afb753fbf..a5c53be61515fe34cd9ca145fffac62806b713a3 100644 (file)
@@ -293,6 +293,7 @@ struct ceph_mon_subscribe_ack {
 #define CEPH_MDSMAP_REFUSE_STANDBY_FOR_ANOTHER_FS (1<<7) /* fs is forbidden to use standby
                                                             for another fs */
 #define CEPH_MDSMAP_BALANCE_AUTOMATE             (1<<8)  /* automate metadata balancing */
+#define CEPH_MDSMAP_REFERENT_INODES              (1<<9)  /* create referent inode for hardlinks to store backtrace */
 #define CEPH_MDSMAP_DEFAULTS (CEPH_MDSMAP_ALLOW_SNAPS | \
                              CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS)
 
index 1ca27331ef1ba25586625e7de8f5da7fc38a2ef0..4376fe9313fa3227dab5da95433949a3c6865fcd 100644 (file)
@@ -251,6 +251,7 @@ void MDSMap::dump_flags_state(Formatter *f) const
     f->dump_bool(flag_display.at(CEPH_MDSMAP_REFUSE_CLIENT_SESSION), test_flag(CEPH_MDSMAP_REFUSE_CLIENT_SESSION));
     f->dump_bool(flag_display.at(CEPH_MDSMAP_REFUSE_STANDBY_FOR_ANOTHER_FS), test_flag(CEPH_MDSMAP_REFUSE_STANDBY_FOR_ANOTHER_FS));
     f->dump_bool(flag_display.at(CEPH_MDSMAP_BALANCE_AUTOMATE), test_flag(CEPH_MDSMAP_BALANCE_AUTOMATE));
+    f->dump_bool(flag_display.at(CEPH_MDSMAP_REFERENT_INODES), allow_referent_inodes());
     f->close_section();
 }
 
@@ -398,6 +399,8 @@ void MDSMap::print_flags(std::ostream& out) const {
     out << " " << flag_display.at(CEPH_MDSMAP_REFUSE_STANDBY_FOR_ANOTHER_FS);
   if (test_flag(CEPH_MDSMAP_BALANCE_AUTOMATE))
     out << " " << flag_display.at(CEPH_MDSMAP_BALANCE_AUTOMATE);
+  if (allow_referent_inodes())
+    out << " " << flag_display.at(CEPH_MDSMAP_REFERENT_INODES);
 }
 
 void MDSMap::get_health(list<pair<health_status_t,string> >& summary,
index b81e8b9a9cc43681a505b4108216b2246a7e1779..05c2a5f67af869ac319bc4e21e3eaf8497c155b3 100644 (file)
@@ -238,6 +238,15 @@ public:
   bool allows_snaps() const { return test_flag(CEPH_MDSMAP_ALLOW_SNAPS); }
   bool was_snaps_ever_allowed() const { return ever_allowed_features & CEPH_MDSMAP_ALLOW_SNAPS; }
 
+  void set_referent_inodes() {
+    set_flag(CEPH_MDSMAP_REFERENT_INODES);
+    ever_allowed_features |= CEPH_MDSMAP_REFERENT_INODES;
+    explicitly_allowed_features |= CEPH_MDSMAP_REFERENT_INODES;
+  }
+  void clear_referent_inodes() { clear_flag(CEPH_MDSMAP_REFERENT_INODES); }
+  bool allow_referent_inodes() const { return test_flag(CEPH_MDSMAP_REFERENT_INODES); }
+  bool was_referent_inodes_ever_used() const { return ever_allowed_features & CEPH_MDSMAP_REFERENT_INODES; }
+
   void set_standby_replay_allowed() {
     set_flag(CEPH_MDSMAP_ALLOW_STANDBY_REPLAY);
     ever_allowed_features |= CEPH_MDSMAP_ALLOW_STANDBY_REPLAY;
@@ -719,7 +728,8 @@ private:
     {CEPH_MDSMAP_ALLOW_STANDBY_REPLAY, "allow_standby_replay"},
     {CEPH_MDSMAP_REFUSE_CLIENT_SESSION, "refuse_client_session"},
     {CEPH_MDSMAP_REFUSE_STANDBY_FOR_ANOTHER_FS, "refuse_standby_for_another_fs"},
-    {CEPH_MDSMAP_BALANCE_AUTOMATE, "balance_automate"}
+    {CEPH_MDSMAP_BALANCE_AUTOMATE, "balance_automate"},
+    {CEPH_MDSMAP_REFERENT_INODES, "allow_referent_inodes"}
   };
 };
 WRITE_CLASS_ENCODER_FEATURES(MDSMap::mds_info_t)
index c83f7f7de0582e55537043add641b2acc4904f7e..ac5b87a3c715a997a2f6d54e72cb3be157d9c892 100644 (file)
@@ -598,6 +598,28 @@ int FileSystemCommandHandler::set_val(Monitor *mon, FSMap& fsmap, MonOpRequestRe
          fs.get_mds_map().clear_multimds_snaps_allowed();
         });
       }
+    } else if (var == "allow_referent_inodes") {
+      bool allow_referent_inodes = false;
+      int r = parse_bool(val, &allow_referent_inodes, ss);
+      if (r != 0) {
+        return r;
+      }
+
+      if (!allow_referent_inodes) {
+        modify_filesystem(fsmap, fsv,
+            [](auto&& fs)
+        {
+          fs.get_mds_map().clear_referent_inodes();
+        });
+       ss << "Disabled creation of referent inodes for hardlinks to store backtrace";
+      } else {
+        modify_filesystem(fsmap, fsv,
+            [](auto&& fs)
+        {
+          fs.get_mds_map().set_referent_inodes();
+        });
+       ss << "Enabled creation of referent inodes for hardlinks to store backtrace";
+      }
     } else if (var == "allow_dirfrags") {
         ss << "Directory fragmentation is now permanently enabled."
            << " This command is DEPRECATED and will be REMOVED from future releases.";
index eeb547b505de785376116516a70ca08206e11786..a53d1adce9e2adc49263585d9cbb189670251961 100644 (file)
@@ -407,6 +407,7 @@ COMMAND("fs set "
           "|session_autoclose"
           "|session_timeout"
           "|standby_count_wanted"
+          "|allow_referent_inodes"
           " "
        "name=val,type=CephString "
        "name=yes_i_really_mean_it,type=CephBool,req=false "