]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds: introduce is_ceph_vxattr() helper
authorVenky Shankar <vshankar@redhat.com>
Tue, 25 Aug 2020 01:26:12 +0000 (21:26 -0400)
committerVenky Shankar <vshankar@redhat.com>
Tue, 13 Oct 2020 04:29:38 +0000 (00:29 -0400)
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 <vshankar@redhat.com>
src/mds/Server.cc
src/mds/Server.h

index eb9e253c33fecf2ddb87ac391921237a1f03b4d3..2a90581493f4d5868234e9bec94d3f42066cdb69 100644 (file)
@@ -5821,8 +5821,8 @@ void Server::handle_client_setxattr(MDRequestRef& mdr)
   const cref_t<MClientRequest> &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<MClientRequest> &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)
index 52d4958972966387df6f4fa74a711e0a091318df..3a3305b06d5879cec3f2df0a7655f36b798d3ccb 100644 (file)
@@ -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<MClientReply> &reply);
   void flush_session(Session *session, MDSGatherBuilder& gather);