From: Venky Shankar Date: Wed, 8 Jan 2020 06:07:03 +0000 (-0500) Subject: mgr/volumes: periodically check if clone operations should be canceled X-Git-Tag: v15.2.0~26^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=2f93b3beb421f6be4611ffab8d1fb7fbe3fb856c;p=ceph.git mgr/volumes: periodically check if clone operations should be canceled Signed-off-by: Venky Shankar --- diff --git a/src/pybind/mgr/volumes/fs/async_cloner.py b/src/pybind/mgr/volumes/fs/async_cloner.py index 961faa583030b..1bd575a133f8b 100644 --- a/src/pybind/mgr/volumes/fs/async_cloner.py +++ b/src/pybind/mgr/volumes/fs/async_cloner.py @@ -66,7 +66,10 @@ def get_clone_source(clone_subvolume): def handle_clone_pending(volume_client, volname, index, groupname, subvolname, should_cancel): try: - next_state = OpSm.get_next_state("clone", "pending", 0) + if should_cancel(): + next_state = OpSm.get_next_state("clone", "pending", -errno.EINTR) + else: + next_state = OpSm.get_next_state("clone", "pending", 0) except OpSmException as oe: raise VolumeException(oe.errno, oe.error_str) return (next_state, False) @@ -91,7 +94,7 @@ def bulk_copy(fs_handle, source_path, dst_path, should_cancel): try: with fs_handle.opendir(src_root_path) as dir_handle: d = fs_handle.readdir(dir_handle) - while d: + while d and not should_cancel(): if d.d_name not in (b".", b".."): log.debug("d={0}".format(d)) d_full_src = os.path.join(src_root_path, d.d_name) @@ -139,6 +142,8 @@ def bulk_copy(fs_handle, source_path, dst_path, should_cancel): if not e.args[0] == errno.ENOENT: raise VolumeException(-e.args[0], e.args[1]) cptree(source_path, dst_path) + if should_cancel(): + raise VolumeException(-errno.EINTR, "clone operation interrupted") def do_clone(volume_client, volname, groupname, subvolname, should_cancel): with open_volume_lockless(volume_client, volname) as fs_handle: @@ -155,7 +160,7 @@ def handle_clone_in_progress(volume_client, volname, index, groupname, subvolnam next_state = OpSm.get_next_state("clone", "in-progress", 0) except VolumeException as ve: # jump to failed state - next_state = OpSm.get_next_state("clone", "in-progress", -1) + next_state = OpSm.get_next_state("clone", "in-progress", ve.errno) except OpSmException as oe: raise VolumeException(oe.errno, oe.error_str) return (next_state, False)