]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Makes quota optional
authorKotresh HR <khiremat@redhat.com>
Tue, 26 Apr 2022 07:16:45 +0000 (12:46 +0530)
committerNikhilkumar Shelke <nshelke@redhat.com>
Tue, 14 Jun 2022 09:19:29 +0000 (14:49 +0530)
Make quota optional. This commit basically reverts the
commit da9f1d829484fe35e6d5839c19afa371e444c194

This is done to give 'mgr' libcephfs connection right to bypass
quota. The mgr/volumes plugin maintains configuration files
with in the directory where the user has enforced quota. So
when the quota is met, certain mgr/volumes apis don't work as
intended. e.g., When subvolumegroup quota is met, the group's
subvolume removal with '--retain-snapshots' fails.

Fixes: https://tracker.ceph.com/issues/53509
Signed-off-by: Kotresh HR <khiremat@redhat.com>
(cherry picked from commit f365a9a5fe465b5d5cc81e5d4dd136bd8989cc20)

src/client/Client.cc
src/common/options/mds-client.yaml.in

index 33253ed10c0d1ae5e726e367ee39a1f157d3277b..4c087d8b72131467a9a8e98343930b67630a4c12 100644 (file)
@@ -11001,9 +11001,9 @@ int Client::statfs(const char *path, struct statvfs *stbuf,
   ceph_assert(root != nullptr);
   InodeRef quota_root = root->quota.is_enable() ? root : get_quota_root(root.get(), perms);
 
-  // get_quota_root should always give us something
-  // because client quotas are always enabled
-  ceph_assert(quota_root != nullptr);
+  // get_quota_root should always give us something if client quotas are
+  // enabled
+  ceph_assert(cct->_conf.get_val<bool>("client_quota") == false || quota_root != nullptr);
 
   if (quota_root && cct->_conf->client_quota_df && quota_root->quota.max_bytes) {
 
@@ -13819,7 +13819,7 @@ int Client::_rename(Inode *fromdir, const char *fromname, Inode *todir, const ch
     else
       return -CEPHFS_EROFS;
   }
-  if (fromdir != todir) {
+  if (cct->_conf.get_val<bool>("client_quota") && fromdir != todir) {
     Inode *fromdir_root =
       fromdir->quota.is_enable() ? fromdir : get_quota_root(fromdir, perm);
     Inode *todir_root =
@@ -15222,6 +15222,10 @@ Inode *Client::get_quota_root(Inode *in, const UserPerm& perms)
 {
   Inode *quota_in = root_ancestor;
   SnapRealm *realm = in->snaprealm;
+
+  if (!cct->_conf.get_val<bool>("client_quota"))
+    return NULL;
+
   while (realm) {
     ldout(cct, 10) << __func__ << " realm " << realm->ino << dendl;
     if (realm->ino != in->ino) {
@@ -15247,6 +15251,9 @@ Inode *Client::get_quota_root(Inode *in, const UserPerm& perms)
 bool Client::check_quota_condition(Inode *in, const UserPerm& perms,
                                   std::function<bool (const Inode &in)> test)
 {
+  if (!cct->_conf.get_val<bool>("client_quota"))
+    return false;
+
   while (true) {
     ceph_assert(in != NULL);
     if (test(*in)) {
index 1881130f8316f0abf12d35b7bed2f306cd417561..5812ddec321ece991196fc27e87bcc9d61625e35 100644 (file)
@@ -559,3 +559,13 @@ options:
   - mds_client
   flags:
   - runtime
+- name: client_quota
+  type: bool
+  level: advanced
+  desc: Enable quota enforcement
+  long_desc: Enable quota_bytes and quota_files enforcement for the client.
+  default: true
+  services:
+  - mds_client
+  flags:
+  - runtime