]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
xfs: Allow user to kill fstrim process
authorLukas Czerner <lczerner@redhat.com>
Thu, 27 Apr 2017 15:59:36 +0000 (08:59 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Thu, 27 Apr 2017 17:45:34 +0000 (10:45 -0700)
fstrim can take really long time on big, slow device or on file system
with a lots of allocation groups. Currently there is no way for the user
to cancell the operation. This patch makes it possible for the user to
kill fstrim pocess by adding the check for fatal_signal_pending() in
xfs_trim_extents().

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/xfs_discard.c

index d796ffac729690ab5273a6007380e76170602cef..6a05d278da64f666e525ca96dfae306face43565 100644 (file)
@@ -132,6 +132,11 @@ next_extent:
                error = xfs_btree_decrement(cur, 0, &i);
                if (error)
                        goto out_del_cursor;
+
+               if (fatal_signal_pending(current)) {
+                       error = -ERESTARTSYS;
+                       goto out_del_cursor;
+               }
        }
 
 out_del_cursor:
@@ -196,8 +201,11 @@ xfs_ioc_trim(
        for (agno = start_agno; agno <= end_agno; agno++) {
                error = xfs_trim_extents(mp, agno, start, end, minlen,
                                          &blocks_trimmed);
-               if (error)
+               if (error) {
                        last_error = error;
+                       if (error == -ERESTARTSYS)
+                               break;
+               }
        }
 
        if (last_error)