aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-03-22 21:10:22 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2019-03-25 11:03:29 -0400
commited79dac98c5e9f8471456afe2cc09a3912586b52 (patch)
tree8c6cc62bf32cca22fcf480f87760038d80399c73 /fs/xfs
parent4b0bce30f39b7733420bb8b28e340aa91c219bc1 (diff)
xfs: prohibit fstrim in norecovery mode
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> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_discard.c8
1 files changed, 8 insertions, 0 deletions
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(
161 return -EPERM; 161 return -EPERM;
162 if (!blk_queue_discard(q)) 162 if (!blk_queue_discard(q))
163 return -EOPNOTSUPP; 163 return -EOPNOTSUPP;
164
165 /*
166 * We haven't recovered the log, so we cannot use our bnobt-guided
167 * storage zapping commands.
168 */
169 if (mp->m_flags & XFS_MOUNT_NORECOVERY)
170 return -EROFS;
171
164 if (copy_from_user(&range, urange, sizeof(range))) 172 if (copy_from_user(&range, urange, sizeof(range)))
165 return -EFAULT; 173 return -EFAULT;
166 174