]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: Add fs option use_global_snaprealm
authorKotresh HR <khiremat@redhat.com>
Fri, 7 Mar 2025 10:36:42 +0000 (16:06 +0530)
committerKotresh HR <khiremat@redhat.com>
Fri, 7 Mar 2025 10:46:15 +0000 (16:16 +0530)
The fs option use_global_snaprealm is introduced
to handle upgrade scenario of referent inode feature [1]
This option is enabled be default which exhibits
the existing behaviour i.e. snapshots will use
global snaprealm. This option is used along with
'allow_referent_inodes' on the new filesystems to
disable global snaprealm.

[1] https://tracker.ceph.com/issues/54205

Fixes: https://tracker.ceph.com/issues/69336
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 a5c53be61515fe34cd9ca145fffac62806b713a3..0b61ec3b76cbf4e82c81703e780727f8d8259d84 100644 (file)
@@ -294,8 +294,10 @@ struct ceph_mon_subscribe_ack {
                                                             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_GLOBAL_SNAPREALM             (1<<10)  /* use global snaprealm for hardlink snapshots */
 #define CEPH_MDSMAP_DEFAULTS (CEPH_MDSMAP_ALLOW_SNAPS | \
-                             CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS)
+                             CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS | \
+                             CEPH_MDSMAP_GLOBAL_SNAPREALM)
 
 /*
  * mds states
index 4376fe9313fa3227dab5da95433949a3c6865fcd..b7d82b7df88b1152e822acf5b9663f5abb1fe9ae 100644 (file)
@@ -252,6 +252,7 @@ void MDSMap::dump_flags_state(Formatter *f) const
     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->dump_bool(flag_display.at(CEPH_MDSMAP_GLOBAL_SNAPREALM), use_global_snaprealm());
     f->close_section();
 }
 
@@ -401,6 +402,8 @@ void MDSMap::print_flags(std::ostream& out) const {
     out << " " << flag_display.at(CEPH_MDSMAP_BALANCE_AUTOMATE);
   if (allow_referent_inodes())
     out << " " << flag_display.at(CEPH_MDSMAP_REFERENT_INODES);
+  if (use_global_snaprealm())
+    out << " " << flag_display.at(CEPH_MDSMAP_GLOBAL_SNAPREALM);
 }
 
 void MDSMap::get_health(list<pair<health_status_t,string> >& summary,
index 05c2a5f67af869ac319bc4e21e3eaf8497c155b3..11e272264b99846bac45a7a9ce67c6a79893a674 100644 (file)
@@ -247,6 +247,15 @@ public:
   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_global_snaprealm() {
+    set_flag(CEPH_MDSMAP_GLOBAL_SNAPREALM);
+    ever_allowed_features |= CEPH_MDSMAP_GLOBAL_SNAPREALM;
+    explicitly_allowed_features |= CEPH_MDSMAP_GLOBAL_SNAPREALM;
+  }
+  void clear_global_snaprealm() { clear_flag(CEPH_MDSMAP_GLOBAL_SNAPREALM); }
+  bool use_global_snaprealm() const { return test_flag(CEPH_MDSMAP_GLOBAL_SNAPREALM); }
+  bool was_global_snaprealm_ever_used() const { return ever_allowed_features & CEPH_MDSMAP_GLOBAL_SNAPREALM; }
+
   void set_standby_replay_allowed() {
     set_flag(CEPH_MDSMAP_ALLOW_STANDBY_REPLAY);
     ever_allowed_features |= CEPH_MDSMAP_ALLOW_STANDBY_REPLAY;
@@ -729,7 +738,8 @@ private:
     {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_REFERENT_INODES, "allow_referent_inodes"}
+    {CEPH_MDSMAP_REFERENT_INODES, "allow_referent_inodes"},
+    {CEPH_MDSMAP_GLOBAL_SNAPREALM, "use_global_snaprealm"}
   };
 };
 WRITE_CLASS_ENCODER_FEATURES(MDSMap::mds_info_t)
index ac5b87a3c715a997a2f6d54e72cb3be157d9c892..7f795235a4ff7ae23089de17e509830970fda560 100644 (file)
@@ -620,6 +620,28 @@ int FileSystemCommandHandler::set_val(Monitor *mon, FSMap& fsmap, MonOpRequestRe
         });
        ss << "Enabled creation of referent inodes for hardlinks to store backtrace";
       }
+    } else if (var == "use_global_snaprealm") {
+      bool use_global_snaprealm = false;
+      int r = parse_bool(val, &use_global_snaprealm, ss);
+      if (r != 0) {
+        return r;
+      }
+
+      if (!use_global_snaprealm) {
+        modify_filesystem(fsmap, fsv,
+            [](auto&& fs)
+        {
+          fs.get_mds_map().clear_global_snaprealm();
+        });
+       ss << "Disable global snaprealm for hardlink snapshot";
+      } else {
+        modify_filesystem(fsmap, fsv,
+            [](auto&& fs)
+        {
+          fs.get_mds_map().set_global_snaprealm();
+        });
+       ss << "Use global snaprealm for hardlink snapshot";
+      }
     } else if (var == "allow_dirfrags") {
         ss << "Directory fragmentation is now permanently enabled."
            << " This command is DEPRECATED and will be REMOVED from future releases.";
index a53d1adce9e2adc49263585d9cbb189670251961..cdb4258c3db98fda2edb017286e2277af2d89d86 100644 (file)
@@ -408,6 +408,7 @@ COMMAND("fs set "
           "|session_timeout"
           "|standby_count_wanted"
           "|allow_referent_inodes"
+          "|use_global_snaprealm"
           " "
        "name=val,type=CephString "
        "name=yes_i_really_mean_it,type=CephBool,req=false "