From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: 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: [PATCH] xfs: prohibit fstrim in norecovery mode
Date: Fri, 22 Mar 2019 17:37:20 -0700 [thread overview]
Message-ID: <20190323003720.GQ1183@magnolia> (raw)
In-Reply-To: <20190323003532.GB1180@magnolia>
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(+)
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;
next prev parent reply other threads:[~2019-03-23 0:37 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 ` Darrick J. Wong [this message]
2019-03-25 14:55 ` [PATCH] xfs: prohibit fstrim in norecovery mode Eric Sandeen
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=20190323003720.GQ1183@magnolia \
--to=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 \
/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