Skip to content

Commit

Permalink
xfs: Allow user to kill fstrim process
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reported-by: Zdenek Kabelac <[email protected]>
Reviewed-by: Eric Sandeen <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Signed-off-by: Darrick J. Wong <[email protected]>
  • Loading branch information
Lukas Czerner authored and djwong committed Apr 27, 2017
1 parent c4cf1ac commit 3c37819
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fs/xfs/xfs_discard.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ xfs_trim_extents(
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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3c37819

Please sign in to comment.