linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sandeen <esandeen@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>,
	xfs <linux-xfs@vger.kernel.org>
Cc: fstests <fstests@vger.kernel.org>, Eryu Guan <guaneryu@gmail.com>,
	linux-ext4 <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH] xfs: prohibit fstrim in norecovery mode
Date: Mon, 25 Mar 2019 09:55:17 -0500	[thread overview]
Message-ID: <3fa32770-f55d-514e-a969-7d7a0b64df5b@redhat.com> (raw)
In-Reply-To: <20190323003720.GQ1183@magnolia>

On 3/22/19 7:37 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> The xfs fstrim implementation uses the free space btrees to find free
> space that can be discarded.  If we haven't recovered the log, the bnobt
> will be stale and we absolutely *cannot* use stale metadata to zap the
> underlying storage.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/xfs/xfs_discard.c |    8 ++++++++
>  1 file changed, 8 insertions(+)

Yikes...

Looks good to me (I briefly thought about a norecovery mount with a clean log,
but then decided I didn't care about that)

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

> diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
> index 93f07edafd81..9ee2a7d02e70 100644
> --- a/fs/xfs/xfs_discard.c
> +++ b/fs/xfs/xfs_discard.c
> @@ -161,6 +161,14 @@ xfs_ioc_trim(
>  		return -EPERM;
>  	if (!blk_queue_discard(q))
>  		return -EOPNOTSUPP;
> +
> +	/*
> +	 * We haven't recovered the log, so we cannot use our bnobt-guided
> +	 * storage zapping commands.
> +	 */
> +	if (mp->m_flags & XFS_MOUNT_NORECOVERY)
> +		return -EROFS;
> +
>  	if (copy_from_user(&range, urange, sizeof(range)))
>  		return -EFAULT;
>  
> 

  reply	other threads:[~2019-03-25 14:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-23  0:35 [PATCH] generic: prohibit fstrim on journalled filesystems with norecovery Darrick J. Wong
2019-03-23  0:37 ` [PATCH] xfs: prohibit fstrim in norecovery mode Darrick J. Wong
2019-03-25 14:55   ` Eric Sandeen [this message]
2019-03-23  0:38 ` [PATCH] ext4: " Darrick J. Wong
2019-03-23 16:13   ` Theodore Ts'o
2019-03-26 12:21 ` [PATCH] generic: prohibit fstrim on journalled filesystems with norecovery Filipe David Manana
2019-03-27  3:26   ` Darrick J. Wong
2019-03-30 10:09     ` Eryu Guan
2019-03-30 10:11   ` Eryu Guan

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=3fa32770-f55d-514e-a969-7d7a0b64df5b@redhat.com \
    --to=esandeen@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@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).