linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Wang Shilong <wangshilong1991@gmail.com>
Cc: linux-xfs@vger.kernel.org, Wang Shilong <wshilong@ddn.com>
Subject: Re: [PATCH] xfs,fstrim: fix to return correct minlen
Date: Mon, 15 Apr 2019 17:11:10 -0700	[thread overview]
Message-ID: <20190416001110.GH4752@magnolia> (raw)
In-Reply-To: <1554885748-7071-1-git-send-email-wshilong1991@gmail.com>

On Wed, Apr 10, 2019 at 05:42:28PM +0900, Wang Shilong wrote:
> From: Wang Shilong <wshilong@ddn.com>
> 
> This patch tries to address two problems:
> 
> 1) return @minlen we used to trim to
> user space.
> 
> 2) return EINVAL if granularity is larger than
> avg size, even most of cases, granularity is small(4K),
> but if devices return a lager granularity for some reaons
> (testing, bugs etc), fstrim should return failure directly.
> 
> Signed-off-by: Wang Shilong <wshilong@ddn.com>

Ok, well, I guess all the other filesystems do this, so we should too...

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_discard.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
> index 93f07edafd81..66702b03587a 100644
> --- a/fs/xfs/xfs_discard.c
> +++ b/fs/xfs/xfs_discard.c
> @@ -164,6 +164,8 @@ xfs_ioc_trim(
>  	if (copy_from_user(&range, urange, sizeof(range)))
>  		return -EFAULT;
>  
> +	range.minlen = max_t(u64, granularity, range.minlen);
> +	minlen = BTOBB(range.minlen);
>  	/*
>  	 * Truncating down the len isn't actually quite correct, but using
>  	 * BBTOB would mean we trivially get overflows for values
> @@ -178,7 +180,6 @@ xfs_ioc_trim(
>  
>  	start = BTOBB(range.start);
>  	end = start + BTOBBT(range.len) - 1;
> -	minlen = BTOBB(max_t(u64, granularity, range.minlen));
>  
>  	if (end > XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks) - 1)
>  		end = XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)- 1;
> -- 
> 2.20.1
> 

      parent reply	other threads:[~2019-04-16  0:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-10  8:42 [PATCH] xfs,fstrim: fix to return correct minlen Wang Shilong
2019-04-11  1:54 ` Darrick J. Wong
2019-04-11  2:05   ` 回复: " Wang Shilong
2019-04-12  0:21     ` Darrick J. Wong
2019-04-16  0:11 ` Darrick J. Wong [this message]

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=20190416001110.GH4752@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=wangshilong1991@gmail.com \
    --cc=wshilong@ddn.com \
    /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).