]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: enable rmxattr on pool_namespace attrs
authorJohn Spray <john.spray@redhat.com>
Fri, 4 Nov 2016 12:48:31 +0000 (12:48 +0000)
committerJohn Spray <john.spray@redhat.com>
Fri, 4 Nov 2016 13:00:05 +0000 (13:00 +0000)
So that a user has a natural way of undoing a setxattr
which set a pool_namespace.

Fixes: http://tracker.ceph.com/issues/17797
Signed-off-by: John Spray <john.spray@redhat.com>
qa/workunits/fs/misc/layout_vxattrs.sh
src/mds/Server.cc
src/mds/Server.h

index 1858968774c55b5fb648126d849c5853fb5cb4a7..29ac407ebb4617e7a8d6851b41165cb5b9d32ece 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/bash -x
 
 set -e
+set -x
 
 # detect data pool
 datapool=
@@ -37,6 +38,8 @@ setfattr -n ceph.file.layout.pool -v $datapool file2
 getfattr -n ceph.file.layout.pool file2 | grep -q $datapool
 setfattr -n ceph.file.layout.pool_namespace -v foons file2
 getfattr -n ceph.file.layout.pool_namespace file2 | grep -q foons
+setfattr -x ceph.file.layout.pool_namespace file2
+getfattr -n ceph.file.layout.pool_namespace file2 | grep -q -v foons
 
 getfattr -n ceph.file.layout.stripe_unit file2 | grep -q 1048576
 getfattr -n ceph.file.layout.stripe_count file2 | grep -q 8
@@ -90,6 +93,7 @@ getfattr -n ceph.dir.layout.stripe_count dir | grep -q 8
 getfattr -n ceph.dir.layout.object_size dir | grep -q 10485760
 getfattr -n ceph.dir.layout.pool_namespace dir | grep -q dirns
 
+
 setfattr -n ceph.file.layout -v "stripe_count=16" file2
 getfattr -n ceph.file.layout.stripe_count file2 | grep -q 16
 setfattr -n ceph.file.layout -v "object_size=10485760 stripe_count=8 stripe_unit=1048576 pool=$datapool pool_namespace=dirns" file2
@@ -102,6 +106,9 @@ getfattr -n ceph.file.layout.stripe_count dir/file | grep -q 8
 getfattr -n ceph.file.layout.object_size dir/file | grep -q 10485760
 getfattr -n ceph.file.layout.pool_namespace dir/file | grep -q dirns
 
+setfattr -x ceph.dir.layout.pool_namespace dir
+getfattr -n ceph.dir.layout dir | grep -q -v pool_namespace=dirns
+
 setfattr -x ceph.dir.layout dir
 getfattr -n ceph.dir.layout dir     2>&1 | grep -q 'No such attribute'
 
index 9207cde01a4289a51b6962b6bdd1ea8acd56a5cc..51e5a71d4d71c6803da75cc78c0b6b51dd5af2a6 100644 (file)
@@ -4297,7 +4297,8 @@ void Server::handle_set_vxattr(MDRequestRef& mdr, CInode *cur,
     if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks))
       return;
 
-    if (cur->inode.layout.pool_id != layout.pool_id) {
+    if (cur->inode.layout.pool_id != layout.pool_id
+        || cur->inode.layout.pool_ns != layout.pool_ns) {
       if (!check_access(mdr, cur, MAY_SET_POOL)) {
         return;
       }
@@ -4379,12 +4380,16 @@ void Server::handle_set_vxattr(MDRequestRef& mdr, CInode *cur,
 }
 
 void Server::handle_remove_vxattr(MDRequestRef& mdr, CInode *cur,
+                                 file_layout_t *dir_layout,
                                  set<SimpleLock*> rdlocks,
                                  set<SimpleLock*> wrlocks,
                                  set<SimpleLock*> xlocks)
 {
   MClientRequest *req = mdr->client_request;
   string name(req->get_path2());
+
+  dout(10) << __func__ << " " << name << " on " << *cur << dendl;
+
   if (name == "ceph.dir.layout") {
     if (!cur->is_dir()) {
       respond_to_request(mdr, -ENODATA);
@@ -4419,6 +4424,14 @@ void Server::handle_remove_vxattr(MDRequestRef& mdr, CInode *cur,
 
     journal_and_reply(mdr, cur, 0, le, new C_MDS_inode_update_finish(this, mdr, cur));
     return;
+  } else if (name == "ceph.dir.layout.pool_namespace"
+          || name == "ceph.file.layout.pool_namespace") {
+    // Namespace is the only layout field that has a meaningful
+    // null/none value (empty string, means default layout).  Is equivalent
+    // to a setxattr with empty string: pass through the empty payload of
+    // the rmxattr request to do this.
+    handle_set_vxattr(mdr, cur, dir_layout, rdlocks, wrlocks, xlocks);
+    return;
   }
 
   respond_to_request(mdr, -ENODATA);
@@ -4539,7 +4552,7 @@ void Server::handle_client_removexattr(MDRequestRef& mdr)
   }
 
   if (name.compare(0, 5, "ceph.") == 0) {
-    handle_remove_vxattr(mdr, cur, rdlocks, wrlocks, xlocks);
+    handle_remove_vxattr(mdr, cur, dir_layout, rdlocks, wrlocks, xlocks);
     return;
   }
 
index de73820378753c291f419a461794a61485b93e26..d580f1f3bae4ffad51d2f04570edf9dfb23806f5 100644 (file)
@@ -187,6 +187,7 @@ public:
                         set<SimpleLock*> wrlocks,
                         set<SimpleLock*> xlocks);
   void handle_remove_vxattr(MDRequestRef& mdr, CInode *cur,
+                           file_layout_t *dir_layout,
                            set<SimpleLock*> rdlocks,
                            set<SimpleLock*> wrlocks,
                            set<SimpleLock*> xlocks);