diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 80bee0bfbc9f6ad08a0995aad9295a5a2b197cb6..d79cf63d9c0f5c472311c753a46cd1cd3fc1c828 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -1004,6 +1004,13 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) if (!blk_queue_discard(q)) return -EOPNOTSUPP; + /* + * We haven't replayed the journal, so we cannot use our + * block-bitmap-guided storage zapping commands. + */ + if (test_opt(sb, NOLOAD) && ext4_has_feature_journal(sb)) + return -EROFS; + if (copy_from_user(&range, (struct fstrim_range __user *)arg, sizeof(range))) return -EFAULT;