From 1e396102bcf2a9213aa5029ea84814684e4d4cc5 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Tue, 26 Apr 2022 12:46:45 +0530 Subject: [PATCH] client: Makes quota optional 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 (cherry picked from commit f365a9a5fe465b5d5cc81e5d4dd136bd8989cc20) Conflicts: src/common/options/mds-client.yaml.in - pacific release not having yamls to store config hence added option in src/common/options.cc --- src/client/Client.cc | 15 +++++++++++---- src/common/options.cc | 6 ++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 680421da982ff..12cccdee5acf7 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -11015,9 +11015,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("client_quota") == false || quota_root != nullptr); if (quota_root && cct->_conf->client_quota_df && quota_root->quota.max_bytes) { @@ -13794,7 +13794,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("client_quota") && fromdir != todir) { Inode *fromdir_root = fromdir->quota.is_enable() ? fromdir : get_quota_root(fromdir, perm); Inode *todir_root = @@ -15208,6 +15208,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("client_quota")) + return NULL; + while (realm) { ldout(cct, 10) << __func__ << " realm " << realm->ino << dendl; if (realm->ino != in->ino) { @@ -15233,6 +15237,9 @@ Inode *Client::get_quota_root(Inode *in, const UserPerm& perms) bool Client::check_quota_condition(Inode *in, const UserPerm& perms, std::function test) { + if (!cct->_conf.get_val("client_quota")) + return false; + while (true) { ceph_assert(in != NULL); if (test(*in)) { diff --git a/src/common/options.cc b/src/common/options.cc index 06d300b5c2bd6..e6a0895bbe4cb 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -9205,6 +9205,12 @@ std::vector