Home Home > GIT Browse > openSUSE-15.0
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
commitf1cd52b27711538b6c3d081325198f6e63e8de8a (patch)
tree67f9871fe49431189f43a71f2d7fee426a4d9bf7
parent63667421a17dcb5dfa85284c5d4c87fbc2e38b45 (diff)
Btrfs: do not allow trimming when a fs is mounted with the
nologreplay option (bsc#1135758).
-rw-r--r--patches.suse/btrfs-do-not-allow-trimming-when-a-fs-is-mounted-wit.patch55
-rw-r--r--series.conf1
2 files changed, 56 insertions, 0 deletions
diff --git a/patches.suse/btrfs-do-not-allow-trimming-when-a-fs-is-mounted-wit.patch b/patches.suse/btrfs-do-not-allow-trimming-when-a-fs-is-mounted-wit.patch
new file mode 100644
index 0000000000..7d30e89d69
--- /dev/null
+++ b/patches.suse/btrfs-do-not-allow-trimming-when-a-fs-is-mounted-wit.patch
@@ -0,0 +1,55 @@
+From: Filipe Manana <fdmanana@suse.com>
+Date: Tue, 26 Mar 2019 10:49:56 +0000
+Git-commit: f35f06c35560a86e841631f0243b83a984dc11a9
+Patch-mainline: 5.1
+Subject: [PATCH] Btrfs: do not allow trimming when a fs is mounted with
+ the nologreplay option
+References: bsc#1135758
+
+Whan a filesystem is mounted with the nologreplay mount option, 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).
+
+So do not allow the fitrim ioctl to do anything when the filesystem is
+mounted with the nologreplay option, because later it can be mounted RW
+without that option, which causes log replay to happen and result in
+either a failure to replay the log trees (leading to a mount failure), a
+crash or some silent corruption.
+
+Reported-by: Darrick J. Wong <darrick.wong@oracle.com>
+Fixes: 96da09192cda ("btrfs: Introduce new mount option to disable tree log replay")
+CC: stable@vger.kernel.org # 4.9+
+Reviewed-by: Nikolay Borisov <nborisov@suse.com>
+Signed-off-by: Filipe Manana <fdmanana@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/ioctl.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+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) {
+--
+2.19.0
+
diff --git a/series.conf b/series.conf
index d2575074e8..d43f83700f 100644
--- a/series.conf
+++ b/series.conf
@@ -21761,6 +21761,7 @@
patches.drivers/Bluetooth-btusb-request-wake-pin-with-NOAUTOEN.patch
patches.fixes/virtio_pci-fix-a-NULL-pointer-reference-in-vp_del_vq.patch
patches.fixes/virtio-Honour-may_reduce_num-in-vring_create_virtque.patch
+ patches.suse/btrfs-do-not-allow-trimming-when-a-fs-is-mounted-wit.patch
patches.drm/0001-drm-udl-add-a-release-method-and-delay-modeset-teard.patch
patches.drm/0003-drm-mediatek-Fix-an-error-code-in-mtk_hdmi_dt_parse_.patch
patches.drm/drm-mediatek-fix-possible-object-reference-leak.patch