]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/volumes: Inherit file quota attr to clone 44873/head
authorKotresh HR <khiremat@redhat.com>
Fri, 11 Feb 2022 08:40:16 +0000 (14:10 +0530)
committerKotresh HR <khiremat@redhat.com>
Tue, 15 Feb 2022 08:10:23 +0000 (13:40 +0530)
The file quota attribute 'ceph.quota.max_files'
is not inherited to the cloned subvolume. This
patch fixes the same.

Fixes: https://tracker.ceph.com/issues/54121
Signed-off-by: Kotresh HR <khiremat@redhat.com>
src/pybind/mgr/volumes/fs/async_cloner.py

index b319201011aa923c514afaf2b6b1fdef08be5633..810397031f52b22186b5e9bafe11b5350d5765c1 100644 (file)
@@ -203,6 +203,20 @@ def set_quota_on_clone(fs_handle, clone_volumes_pair):
         except cephfs.Error as e:
              raise VolumeException(-e.args[0], e.args[1])
 
+    quota_files = None # type: Optional[int]
+    try:
+        quota_files = int(fs_handle.getxattr(src_path, 'ceph.quota.max_files').decode('utf-8'))
+    except cephfs.NoData:
+        pass
+
+    if quota_files is not None:
+        try:
+            fs_handle.setxattr(dst_path, 'ceph.quota.max_files', str(quota_files).encode('utf-8'), 0)
+        except cephfs.InvalidValue:
+            raise VolumeException(-errno.EINVAL, "invalid file count specified: '{0}'".format(quota_files))
+        except cephfs.Error as e:
+             raise VolumeException(-e.args[0], e.args[1])
+
 def do_clone(fs_client, volspec, volname, groupname, subvolname, should_cancel):
     with open_volume_lockless(fs_client, volname) as fs_handle:
         with open_clone_subvolume_pair(fs_client, fs_handle, volspec, volname, groupname, subvolname) as clone_volumes: