Skip to content

Commit

Permalink
mon: add new configuration to limit filesystem xattrs size
Browse files Browse the repository at this point in the history
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 ceph#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 <lhenriques@suse.de>
  • Loading branch information
luis-henrix committed Mar 1, 2023
1 parent 0ad6038 commit 7b8def5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/mds/MDSMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -939,6 +942,7 @@ void MDSMap::decode(bufferlist::const_iterator& p)
}

if (ev >= 17) {
decode(max_xattr_size, p);
decode(bal_rank_mask, p);
}

Expand Down
11 changes: 11 additions & 0 deletions src/mds/MDSMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -196,6 +202,9 @@ class MDSMap {
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) {
Expand Down Expand Up @@ -620,6 +629,8 @@ class MDSMap {
__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<int64_t> data_pools; // file data pools available to clients (via an ioctl). first is the default.
Expand Down
11 changes: 11 additions & 0 deletions src/mon/FSCommands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,17 @@ class SetHandler : public FileSystemCommandHandler
{
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<Filesystem> 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);
Expand Down
2 changes: 1 addition & 1 deletion src/mon/MonCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7b8def5

Please sign in to comment.