Home Home > GIT Browse > SLE15
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2019-05-21 11:43:55 +0100
committerFilipe Manana <fdmanana@suse.com>2019-05-21 11:43:55 +0100
commit3cc6bc7ac06a5fdb4e76d1e702795ecd6a81d9e1 (patch)
treed677683e1afe64352a57bdd523eb60377cd4226e
parent975e9e263cfc9feefa8eef1225b50d0d87130190 (diff)
Btrfs: do not allow trimming when a fs is mounted with the
nologreplay option (bsc#1135758). suse-commit: f1cd52b27711538b6c3d081325198f6e63e8de8a
-rw-r--r--fs/btrfs/ioctl.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index d0264f604588..5090594a8310 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -387,6 +387,16 @@ static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg)
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
+ /*
+ * If the fs is mounted with nologreplay, which requires it to be
+ * mounted in RO mode as well, we can not allow discard on free space
+ * inside block groups, because log trees refer to extents that are not
+ * pinned in a block group's free space cache (pinning the extents is
+ * precisely the first phase of replaying a log tree).
+ */
+ if (btrfs_test_opt(fs_info, NOLOGREPLAY))
+ return -EROFS;
+
rcu_read_lock();
list_for_each_entry_rcu(device, &fs_info->fs_devices->devices,
dev_list) {