From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] gfs2: Make sure FITRIM minlen is rounded up to fs block size
Date: Tue, 22 Mar 2022 20:08:24 +0000 [thread overview]
Message-ID: <f2a5d2f7-0e10-6c55-2719-30ce9317484e@redhat.com> (raw)
In-Reply-To: <20220322190551.357960-1-anprice@redhat.com>
On 22/03/2022 19:05, Andrew Price wrote:
> Per fstrim(8) we must round up the minlen argument to the fs block size.
> The current calculation doesn't take into account devices that have a
> discard granularity and requested minlen less than 1 fs block, so the
> value can get shifted away to zero in the translation to fs blocks.
>
> The zero minlen passed to gfs2_rgrp_send_discards() then allows
> sb_issue_discard() to be called with nr_sects == 0 which returns -EINVAL
> and results in gfs2_rgrp_send_discards() returning -EIO.
Adding test results. xfstests interprets fstrim failures as "FITRIM not
supported" and doesn't run them, so I got these results:
5.17:
Ran: generic/260 generic/288 generic/537
Not run: generic/260 generic/288 generic/537
Passed all 3 tests
5.17 + patch:
Ran: generic/260 generic/288 generic/537
Passed all 3 tests
(Those 3 tests are in the ones in the 'quick' and 'trim' groups)
Andy
> Make sure minlen is never < 1 fs block by taking the max of the
> requested minlen and the fs block size before comparing to the device's
> discard granularity and shifting to fs blocks.
>
> Fixes: 076f0faa764ab ("GFS2: Fix FITRIM argument handling")
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---
> fs/gfs2/rgrp.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
> index 0fb3c01bc557..a34945cbf32a 100644
> --- a/fs/gfs2/rgrp.c
> +++ b/fs/gfs2/rgrp.c
> @@ -1415,7 +1415,8 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
>
> start = r.start >> bs_shift;
> end = start + (r.len >> bs_shift);
> - minlen = max_t(u64, r.minlen,
> + minlen = max_t(u64, r.minlen, sdp->sd_sb.sb_bsize);
> + minlen = max_t(u64, minlen,
> q->limits.discard_granularity) >> bs_shift;
>
> if (end <= start || minlen > sdp->sd_max_rg_data)
prev parent reply other threads:[~2022-03-22 20:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-22 19:05 [Cluster-devel] [PATCH] gfs2: Make sure FITRIM minlen is rounded up to fs block size Andrew Price
2022-03-22 20:08 ` Andrew Price [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=f2a5d2f7-0e10-6c55-2719-30ce9317484e@redhat.com \
--to=anprice@redhat.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).