From 72671c8ead126fdbcb39a2f179c001fb1fe43fe5 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Fri, 11 Feb 2022 14:10:16 +0530 Subject: [PATCH] mgr/volumes: Inherit file quota attr to clone 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 --- src/pybind/mgr/volumes/fs/async_cloner.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/pybind/mgr/volumes/fs/async_cloner.py b/src/pybind/mgr/volumes/fs/async_cloner.py index b319201011aa9..810397031f52b 100644 --- a/src/pybind/mgr/volumes/fs/async_cloner.py +++ b/src/pybind/mgr/volumes/fs/async_cloner.py @@ -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: -- 2.39.5