1 From 92a88a05446bd66749f21ab2afd75e7e17183810 Mon Sep 17 00:00:00 2001
2 From: "Darrick J. Wong" <darrick.wong@oracle.com>
3 Date: Sat, 23 Mar 2019 12:10:29 -0400
4 Subject: ext4: prohibit fstrim in norecovery mode
6 [ Upstream commit 18915b5873f07e5030e6fb108a050fa7c71c59fb ]
8 The ext4 fstrim implementation uses the block bitmaps to find free space
9 that can be discarded. If we haven't replayed the journal, the bitmaps
10 will be stale and we absolutely *cannot* use stale metadata to zap the
13 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
14 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
15 Signed-off-by: Sasha Levin <sashal@kernel.org>
17 fs/ext4/ioctl.c | 7 +++++++
18 1 file changed, 7 insertions(+)
20 diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
21 index 2880e017cd0a..2ce73287b53c 100644
24 @@ -749,6 +749,13 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
25 if (!blk_queue_discard(q))
29 + * We haven't replayed the journal, so we cannot use our
30 + * block-bitmap-guided storage zapping commands.
32 + if (test_opt(sb, NOLOAD) && ext4_has_feature_journal(sb))
35 if (copy_from_user(&range, (struct fstrim_range __user *)arg,