]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/volumes: periodically check if copy operations should be canceled
authorVenky Shankar <vshankar@redhat.com>
Wed, 8 Jan 2020 06:00:20 +0000 (01:00 -0500)
committerRamana Raja <rraja@redhat.com>
Thu, 19 Mar 2020 12:59:24 +0000 (18:29 +0530)
Signed-off-by: Venky Shankar <vshankar@redhat.com>
(cherry picked from commit 9a0507acb62249e904d54c5ed11ef106f3239bd8)

src/pybind/mgr/volumes/fs/async_cloner.py
src/pybind/mgr/volumes/fs/fs_util.py

index a0802fb928122777d513506ce20f70de3db0d0b0..963fa34a6f1dd0613ca65edff8382ab67b16214f 100644 (file)
@@ -83,9 +83,7 @@ def sync_attrs(fs_handle, target_path, source_statx):
 def bulk_copy(fs_handle, source_path, dst_path, should_cancel):
     """
     bulk copy data from source to destination -- only directories, symlinks
-    and regular files are synced. note that @should_cancel is not used right
-    now but would be required when implementing cancelation for in-progress
-    clone operations.
+    and regular files are synced.
     """
     log.info("copying data from {0} to {1}".format(source_path, dst_path))
     def cptree(src_root_path, dst_root_path):
@@ -125,7 +123,7 @@ def bulk_copy(fs_handle, source_path, dst_path, should_cancel):
                                     raise
                         elif stat.S_ISREG(stx["mode"]):
                             log.debug("cptree: (REG) {0}".format(d_full_src))
-                            copy_file(fs_handle, d_full_src, d_full_dst, mo)
+                            copy_file(fs_handle, d_full_src, d_full_dst, mo, cancel_check=should_cancel)
                         else:
                             handled = False
                             log.warn("cptree: (IGNORE) {0}".format(d_full_src))
index 79c0fa9c092383ca404e210ab84f30047438cf7f..baf6dae6243a8272128abc537ccb3ccc7abd00b5 100644 (file)
@@ -86,7 +86,7 @@ def list_one_entry_at_a_time(fs, dirpath):
     except cephfs.Error as e:
         raise VolumeException(-e.args[0], e.args[1])
 
-def copy_file(fs, src, dst, mode):
+def copy_file(fs, src, dst, mode, cancel_check=None):
     """
     Copy a regular file from @src to @dst. @dst is overwritten if it exists.
     """
@@ -104,6 +104,8 @@ def copy_file(fs, src, dst, mode):
     IO_SIZE = 8 * 1024 * 1024
     try:
         while True:
+            if cancel_check and cancel_check():
+                raise VolumeException(-errno.EINTR, "copy operation interrupted")
             data = fs.read(src_fd, -1, IO_SIZE)
             if not len(data):
                 break