]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: check if mds create snaprealm when setting quota
authorYan, Zheng <zyan@redhat.com>
Wed, 4 Apr 2018 09:43:10 +0000 (17:43 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 5 Apr 2018 03:12:16 +0000 (11:12 +0800)
If mds does not, return -EOPNOTSUPP

Fixes: http://tracker.ceph.com/issues/23491
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/client/Client.cc

index 29703137c1763fa9a4ba71c6bf358334d64d4d85..689a3733fa4a9511a83dcb99ad7158c6bc2061c4 100644 (file)
@@ -11097,6 +11097,8 @@ int Client::_setxattr(Inode *in, const char *name, const void *value,
       !posix_acl_xattr)
     return -EOPNOTSUPP;
 
+  bool check_realm = false;
+
   if (posix_acl_xattr) {
     if (!strcmp(name, ACL_EA_ACCESS)) {
       mode_t new_mode = in->mode;
@@ -11133,11 +11135,23 @@ int Client::_setxattr(Inode *in, const char *name, const void *value,
     }
   } else {
     const VXattr *vxattr = _match_vxattr(in, name);
-    if (vxattr && vxattr->readonly)
-      return -EOPNOTSUPP;
+    if (vxattr) {
+      if (vxattr->readonly)
+       return -EOPNOTSUPP;
+      if (vxattr->name.compare(0, 10, "ceph.quota") == 0 && value)
+       check_realm = true;
+    }
   }
 
-  return _do_setxattr(in, name, value, size, flags, perms);
+  int ret = _do_setxattr(in, name, value, size, flags, perms);
+  if (ret >= 0 && check_realm) {
+    // check if snaprealm was created for quota inode
+    if (in->quota.is_enable() &&
+       !(in->snaprealm && in->snaprealm->ino == in->ino))
+      ret = -EOPNOTSUPP;
+  }
+
+  return ret;
 }
 
 int Client::_setxattr(InodeRef &in, const char *name, const void *value,
@@ -11308,7 +11322,8 @@ int Client::ll_removexattr(Inode *in, const char *name, const UserPerm& perms)
 
 bool Client::_vxattrcb_quota_exists(Inode *in)
 {
-  return in->quota.is_enable();
+  return in->quota.is_enable() &&
+        in->snaprealm && in->snaprealm->ino == in->ino;
 }
 size_t Client::_vxattrcb_quota(Inode *in, char *val, size_t size)
 {