]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.9-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 3 Apr 2022 12:39:09 +0000 (14:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 3 Apr 2022 12:39:09 +0000 (14:39 +0200)
added patches:
gfs2-make-sure-fitrim-minlen-is-rounded-up-to-fs-block-size.patch

queue-4.9/gfs2-make-sure-fitrim-minlen-is-rounded-up-to-fs-block-size.patch [new file with mode: 0644]
queue-4.9/series

diff --git a/queue-4.9/gfs2-make-sure-fitrim-minlen-is-rounded-up-to-fs-block-size.patch b/queue-4.9/gfs2-make-sure-fitrim-minlen-is-rounded-up-to-fs-block-size.patch
new file mode 100644 (file)
index 0000000..42731e4
--- /dev/null
@@ -0,0 +1,42 @@
+From 27ca8273fda398638ca994a207323a85b6d81190 Mon Sep 17 00:00:00 2001
+From: Andrew Price <anprice@redhat.com>
+Date: Tue, 22 Mar 2022 19:05:51 +0000
+Subject: gfs2: Make sure FITRIM minlen is rounded up to fs block size
+
+From: Andrew Price <anprice@redhat.com>
+
+commit 27ca8273fda398638ca994a207323a85b6d81190 upstream.
+
+Per fstrim(8) we must round up the minlen argument to the fs block size.
+The current calculation doesn't take into account devices that have a
+discard granularity and requested minlen less than 1 fs block, so the
+value can get shifted away to zero in the translation to fs blocks.
+
+The zero minlen passed to gfs2_rgrp_send_discards() then allows
+sb_issue_discard() to be called with nr_sects == 0 which returns -EINVAL
+and results in gfs2_rgrp_send_discards() returning -EIO.
+
+Make sure minlen is never < 1 fs block by taking the max of the
+requested minlen and the fs block size before comparing to the device's
+discard granularity and shifting to fs blocks.
+
+Fixes: 076f0faa764ab ("GFS2: Fix FITRIM argument handling")
+Signed-off-by: Andrew Price <anprice@redhat.com>
+Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/gfs2/rgrp.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/fs/gfs2/rgrp.c
++++ b/fs/gfs2/rgrp.c
+@@ -1390,7 +1390,8 @@ int gfs2_fitrim(struct file *filp, void
+       start = r.start >> bs_shift;
+       end = start + (r.len >> bs_shift);
+-      minlen = max_t(u64, r.minlen,
++      minlen = max_t(u64, r.minlen, sdp->sd_sb.sb_bsize);
++      minlen = max_t(u64, minlen,
+                      q->limits.discard_granularity) >> bs_shift;
+       if (end <= start || minlen > sdp->sd_max_rg_data)
index 63d2fe9c6546ed49f3d3bff99a78ccc601281996..cc7b11b6ea65e462b5997897f44ba8c85675a1c2 100644 (file)
@@ -150,3 +150,4 @@ scsi-qla2xxx-fix-incorrect-reporting-of-task-management-failure.patch
 kvm-prevent-module-exit-until-all-vms-are-freed.patch
 ubifs-add-missing-iput-if-do_tmpfile-failed-in-rename-whiteout.patch
 ubifs-setflags-make-dirtied_ino_d-8-bytes-aligned.patch
+gfs2-make-sure-fitrim-minlen-is-rounded-up-to-fs-block-size.patch