linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: Lukas Czerner <lczerner@redhat.com>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs: Allow user to kill fstrim process
Date: Thu, 27 Apr 2017 10:55:47 -0500	[thread overview]
Message-ID: <c24d118c-273c-f5f4-44c7-eeb50e3e4aba@sandeen.net> (raw)
In-Reply-To: <1493282368-32422-1-git-send-email-lczerner@redhat.com>

On 4/27/17 3:39 AM, Lukas Czerner wrote:
> 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>

Sorry for the detour while I got confused about signals.  ;)

This looks ok to me.  Thanks!

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  fs/xfs/xfs_discard.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
> index d796ffa..6a05d27 100644
> --- a/fs/xfs/xfs_discard.c
> +++ b/fs/xfs/xfs_discard.c
> @@ -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:
> @@ -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)
> 

  parent reply	other threads:[~2017-04-27 15:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-27  8:39 [PATCH] xfs: Allow user to kill fstrim process Lukas Czerner
2017-04-27 14:34 ` Eric Sandeen
2017-04-27 15:38   ` Darrick J. Wong
2017-04-27 15:46     ` Eric Sandeen
2017-04-27 15:50       ` Eric Sandeen
2017-04-28  8:22         ` Lukas Czerner
2017-04-27 15:55 ` Eric Sandeen [this message]
2017-04-27 21:04 ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c24d118c-273c-f5f4-44c7-eeb50e3e4aba@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=lczerner@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).