From: Kotresh HR Date: Wed, 19 Feb 2025 16:44:30 +0000 (+0530) Subject: mds: Make referent inodes a optional feature X-Git-Tag: v20.3.0~377^2~44 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=72613db034c8e58b825c343e26ed615c3508e7b9;p=ceph.git mds: Make referent inodes a optional feature 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 --- diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index f10189dd09f..a5c53be6151 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -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) diff --git a/src/mds/MDSMap.cc b/src/mds/MDSMap.cc index 1ca27331ef1..4376fe9313f 100644 --- a/src/mds/MDSMap.cc +++ b/src/mds/MDSMap.cc @@ -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 >& summary, diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index b81e8b9a9cc..05c2a5f67af 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -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) diff --git a/src/mon/FSCommands.cc b/src/mon/FSCommands.cc index c83f7f7de05..ac5b87a3c71 100644 --- a/src/mon/FSCommands.cc +++ b/src/mon/FSCommands.cc @@ -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."; diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index eeb547b505d..a53d1adce9e 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -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 "