From 6b6a83aaa055f855d26bcedd8a5b58e7adf4618b Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Mon, 24 Aug 2020 21:26:12 -0400 Subject: [PATCH] mds: introduce is_ceph_vxattr() helper Not all ceph.* xattrs are virtual -- virtual in the sense that such xattrs have entries in the inode structure (inode_t) rather than in xattr_map. There could be cases where an xattr is in ceph namespace but does not necessarily need to be stored for each inode -- so filter such xattrs individually rather than treating all ceph.* xattrs as virtual. Signed-off-by: Venky Shankar --- src/mds/Server.cc | 7 ++++--- src/mds/Server.h | 10 ++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/mds/Server.cc b/src/mds/Server.cc index eb9e253c33f..2a90581493f 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -5821,8 +5821,8 @@ void Server::handle_client_setxattr(MDRequestRef& mdr) const cref_t &req = mdr->client_request; string name(req->get_path2()); - // magic ceph.* namespace? - if (name.compare(0, 5, "ceph.") == 0) { + // is a ceph virtual xattr? + if (is_ceph_vxattr(name)) { // can't use rdlock_path_pin_ref because we need to xlock snaplock/policylock CInode *cur = try_get_auth_inode(mdr, req->get_filepath().get_ino()); if (!cur) @@ -5923,7 +5923,8 @@ void Server::handle_client_removexattr(MDRequestRef& mdr) const cref_t &req = mdr->client_request; std::string name(req->get_path2()); - if (name.compare(0, 5, "ceph.") == 0) { + // is a ceph virtual xattr? + if (is_ceph_vxattr(name)) { // can't use rdlock_path_pin_ref because we need to xlock snaplock/policylock CInode *cur = try_get_auth_inode(mdr, req->get_filepath().get_ino()); if (!cur) diff --git a/src/mds/Server.h b/src/mds/Server.h index 52d49589729..3a3305b06d5 100644 --- a/src/mds/Server.h +++ b/src/mds/Server.h @@ -318,6 +318,16 @@ private: friend class ServerLogContext; friend class Batch_Getattr_Lookup; + static bool is_ceph_vxattr(std::string_view xattr_name) { + return xattr_name.rfind("ceph.dir.layout", 0) == 0 || + xattr_name.rfind("ceph.file.layout", 0) == 0 || + xattr_name.rfind("ceph.quota", 0) == 0 || + xattr_name == "ceph.dir.subvolume"sv || + xattr_name == "ceph.dir.pin"sv || + xattr_name == "ceph.dir.pin.random"sv || + xattr_name == "ceph.dir.pin.distributed"sv; + } + void reply_client_request(MDRequestRef& mdr, const ref_t &reply); void flush_session(Session *session, MDSGatherBuilder& gather); -- 2.39.5