From: Luís Henriques Date: Wed, 1 Jun 2022 16:02:13 +0000 (+0100) Subject: mon: add new configuration to limit filesystem xattrs size X-Git-Tag: v18.2.4~396^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fa30f894de4376916bde9c19dba476b80c057930;p=ceph.git mon: add new configuration to limit filesystem xattrs size This new configuration option will allow to define the maximum size for a filesystem xattrs blob. This is a filesystem-wide knob that will replace the per-MDS mds_max_xattr_pairs_size option. Note: The kernel client patch to handle this new configuration was merged before the corresponding ceph-side pull-request. This was unfortunate because in the meantime PR #43284 was merged and the encoding/decoding of 'bal_rank_mask' got in between. Hence the 'max_xattr_size' is being encoding/decoded before 'bal_rank_mask'. URL: https://tracker.ceph.com/issues/55725 Signed-off-by: Luís Henriques (cherry picked from commit 7b8def5c30b92ec642209f6ab1af312e49343c01) --- diff --git a/src/mds/MDSMap.cc b/src/mds/MDSMap.cc index 6433d08c5d256..6ea1de533de7c 100644 --- a/src/mds/MDSMap.cc +++ b/src/mds/MDSMap.cc @@ -177,6 +177,7 @@ void MDSMap::dump(Formatter *f) const cephfs_dump_features(f, required_client_features); f->close_section(); f->dump_int("max_file_size", max_file_size); + f->dump_int("max_xattr_size", max_xattr_size); f->dump_int("last_failure", last_failure); f->dump_int("last_failure_osd_epoch", last_failure_osd_epoch); f->open_object_section("compat"); @@ -268,6 +269,7 @@ void MDSMap::print(ostream& out) const out << "session_timeout\t" << session_timeout << "\n" << "session_autoclose\t" << session_autoclose << "\n"; out << "max_file_size\t" << max_file_size << "\n"; + out << "max_xattr_size\t" << max_xattr_size << "\n"; out << "required_client_features\t" << cephfs_stringify_features(required_client_features) << "\n"; out << "last_failure\t" << last_failure << "\n" << "last_failure_osd_epoch\t" << last_failure_osd_epoch << "\n"; @@ -790,6 +792,7 @@ void MDSMap::encode(bufferlist& bl, uint64_t features) const encode(min_compat_client, bl); } encode(required_client_features, bl); + encode(max_xattr_size, bl); encode(bal_rank_mask, bl); ENCODE_FINISH(bl); } @@ -939,6 +942,7 @@ void MDSMap::decode(bufferlist::const_iterator& p) } if (ev >= 17) { + decode(max_xattr_size, p); decode(bal_rank_mask, p); } diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index 75c44e27c5f00..7e1814e5977a4 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -50,6 +50,12 @@ static inline const auto MDS_FEATURE_INCOMPAT_SNAPREALM_V2 = CompatSet::Feature( #define MDS_FS_NAME_DEFAULT "cephfs" +/* + * Maximum size of xattrs the MDS can handle per inode by default. This + * includes the attribute name and 4+4 bytes for the key/value sizes. + */ +#define MDS_MAX_XATTR_SIZE (1<<16) /* 64K */ + class health_check_map_t; class MDSMap { @@ -196,6 +202,9 @@ public: uint64_t get_max_filesize() const { return max_file_size; } void set_max_filesize(uint64_t m) { max_file_size = m; } + uint64_t get_max_xattr_size() const { return max_xattr_size; } + void set_max_xattr_size(uint64_t m) { max_xattr_size = m; } + void set_min_compat_client(ceph_release_t version); void add_required_client_feature(size_t bit) { @@ -620,6 +629,8 @@ protected: __u32 session_autoclose = 300; uint64_t max_file_size = 1ULL<<40; /* 1TB */ + uint64_t max_xattr_size = MDS_MAX_XATTR_SIZE; + feature_bitset_t required_client_features; std::vector data_pools; // file data pools available to clients (via an ioctl). first is the default. diff --git a/src/mon/FSCommands.cc b/src/mon/FSCommands.cc index 65d2c356b687b..df78639e09923 100644 --- a/src/mon/FSCommands.cc +++ b/src/mon/FSCommands.cc @@ -461,6 +461,17 @@ public: { fs->mds_map.set_max_filesize(n); }); + } else if (var == "max_xattr_size") { + if (interr.length()) { + ss << var << " requires an integer value"; + return -EINVAL; + } + fsmap.modify_filesystem( + fs->fscid, + [n](std::shared_ptr fs) + { + fs->mds_map.set_max_xattr_size(n); + }); } else if (var == "allow_new_snaps") { bool enable_snaps = false; int r = parse_bool(val, &enable_snaps, ss); diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 52af09c8c7c57..bce63182e317e 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -378,7 +378,7 @@ COMMAND("fs set " "|allow_new_snaps|inline_data|cluster_down|allow_dirfrags|balancer" "|standby_count_wanted|session_timeout|session_autoclose" "|allow_standby_replay|down|joinable|min_compat_client|bal_rank_mask" - "|refuse_client_session " + "|refuse_client_session|max_xattr_size " "name=val,type=CephString " "name=yes_i_really_mean_it,type=CephBool,req=false " "name=yes_i_really_really_mean_it,type=CephBool,req=false",