From: Kotresh HR Date: Thu, 10 Feb 2022 05:34:41 +0000 (+0530) Subject: mgr/volumes: Fix clone uid/gid mismatch X-Git-Tag: v15.2.17~108^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d9213e0b11e5ec059febda07d392f619c7dfe43c;p=ceph.git mgr/volumes: Fix clone uid/gid mismatch This is the regression caused by commit 18b85c53a. The 'set_attrs' function sets the uid/gid of the group to the subvolume if uid/gid is not passed. The attrs of the clone should match the source snapshot. Hence, don't use the 'set_attrs' function to set only the quota attrs for the clone. Fixes: https://tracker.ceph.com/issues/54066 Signed-off-by: Kotresh HR (cherry picked from commit b3c9e6b50cf4264538e4c41d19e7ebb8b2900c3a) --- diff --git a/src/pybind/mgr/volumes/fs/async_cloner.py b/src/pybind/mgr/volumes/fs/async_cloner.py index df3cb93582e91..802a43f413b40 100644 --- a/src/pybind/mgr/volumes/fs/async_cloner.py +++ b/src/pybind/mgr/volumes/fs/async_cloner.py @@ -4,7 +4,7 @@ import time import errno import logging from contextlib import contextmanager -from typing import Dict, Union +from typing import Optional import cephfs @@ -186,18 +186,21 @@ def bulk_copy(fs_handle, source_path, dst_path, should_cancel): raise VolumeException(-errno.EINTR, "clone operation interrupted") def set_quota_on_clone(fs_handle, clone_volumes_pair): - attrs = {} # type: Dict[str, Union[int, str, None]] src_path = clone_volumes_pair[1].snapshot_data_path(clone_volumes_pair[2]) dst_path = clone_volumes_pair[0].path + quota = None # type: Optional[int] try: - attrs["quota"] = int(fs_handle.getxattr(src_path, - 'ceph.quota.max_bytes' - ).decode('utf-8')) + quota = int(fs_handle.getxattr(src_path, 'ceph.quota.max_bytes').decode('utf-8')) except cephfs.NoData: - attrs["quota"] = None + pass - if attrs["quota"] is not None: - clone_volumes_pair[0].set_attrs(dst_path, attrs) + if quota is not None: + try: + fs_handle.setxattr(dst_path, 'ceph.quota.max_bytes', str(quota).encode('utf-8'), 0) + except cephfs.InvalidValue: + raise VolumeException(-errno.EINVAL, "invalid size specified: '{0}'".format(quota)) + 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: