]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: correct quota check in Client::_rename() 50127/head
authorRishabh Dave <ridave@redhat.com>
Wed, 15 Feb 2023 13:19:10 +0000 (18:49 +0530)
committerRishabh Dave <ridave@redhat.com>
Wed, 22 Feb 2023 16:30:47 +0000 (22:00 +0530)
Client::_rename() only checks for max files quota. As a result, max
bytes quota is not enforced. Thus the following code (copied from
qa/workunits/fs/quota/quota.sh), runs successfully instead of exiting
with error "Disk quota exceeded" -

mkdir files limit
setfattr limit -n ceph.quota.max_bytes -v 1000
truncate filles/file1 -s 1M
mv files limit

This patch makes Client::_rename() enforce both kinds of quota which
leads command "mv files limit" from above script to fail with "Disk
quota exceeded" error. This is the expected behaviour in this case.

Introduced-by: dde1a19d4105f1db41477752a71d8fe40c45cd7f
Fixes: https://tracker.ceph.com/issues/58220
Signed-off-by: Rishabh Dave <ridave@redhat.com>
src/client/Client.cc

index dd06dfcad2d9057338a6416bb5747163d8de514a..8d7cca8225c7b208a5aed2b4fe5d63613467c514 100644 (file)
@@ -14121,11 +14121,13 @@ int Client::_rename(Inode *fromdir, const char *fromname, Inode *todir, const ch
     else
       return -CEPHFS_EROFS;
   }
+
+  // don't allow cross-quota renames
   if (cct->_conf.get_val<bool>("client_quota") && fromdir != todir) {
     Inode *fromdir_root =
-      fromdir->quota.is_enabled(QUOTA_MAX_FILES) ? fromdir : get_quota_root(fromdir, perm, QUOTA_MAX_FILES);
+      fromdir->quota.is_enabled() ? fromdir : get_quota_root(fromdir, perm);
     Inode *todir_root =
-      todir->quota.is_enabled(QUOTA_MAX_FILES) ? todir : get_quota_root(todir, perm, QUOTA_MAX_FILES);
+      todir->quota.is_enabled() ? todir : get_quota_root(todir, perm);
     if (fromdir_root != todir_root) {
       return -CEPHFS_EXDEV;
     }