Home Home > GIT Browse > stable
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-01-18 07:53:27 +0100
committerJiri Slaby <jslaby@suse.cz>2019-01-18 07:53:40 +0100
commit4122b4dce4db192eecd2816822d60be6f046321f (patch)
tree2ab1100ca873029527d69c5317d4c95ef82d8de1
parenteb716db3eaa06bf55fa4abfbdafb3fc970bbb399 (diff)
rbd: don't return 0 on unmap if RBD_DEV_FLAG_REMOVING is set
-rw-r--r--patches.kernel.org/4.20.3-046-rbd-don-t-return-0-on-unmap-if-RBD_DEV_FLAG_RE.patch65
-rw-r--r--series.conf1
2 files changed, 66 insertions, 0 deletions
diff --git a/patches.kernel.org/4.20.3-046-rbd-don-t-return-0-on-unmap-if-RBD_DEV_FLAG_RE.patch b/patches.kernel.org/4.20.3-046-rbd-don-t-return-0-on-unmap-if-RBD_DEV_FLAG_RE.patch
new file mode 100644
index 0000000000..9f7f63be7c
--- /dev/null
+++ b/patches.kernel.org/4.20.3-046-rbd-don-t-return-0-on-unmap-if-RBD_DEV_FLAG_RE.patch
@@ -0,0 +1,65 @@
+From: Ilya Dryomov <idryomov@gmail.com>
+Date: Tue, 8 Jan 2019 19:47:38 +0100
+Subject: [PATCH] rbd: don't return 0 on unmap if RBD_DEV_FLAG_REMOVING is set
+References: bnc#1012628
+Patch-mainline: 4.20.3
+Git-commit: 85f5a4d666fd9be73856ed16bb36c5af5b406b29
+
+commit 85f5a4d666fd9be73856ed16bb36c5af5b406b29 upstream.
+
+There is a window between when RBD_DEV_FLAG_REMOVING is set and when
+the device is removed from rbd_dev_list. During this window, we set
+"already" and return 0.
+
+Returning 0 from write(2) can confuse userspace tools because
+0 indicates that nothing was written. In particular, "rbd unmap"
+will retry the write multiple times a second:
+
+ 10:28:05.463299 write(4, "0", 1) = 0
+ 10:28:05.463509 write(4, "0", 1) = 0
+ 10:28:05.463720 write(4, "0", 1) = 0
+ 10:28:05.463942 write(4, "0", 1) = 0
+ 10:28:05.464155 write(4, "0", 1) = 0
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
+Tested-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ drivers/block/rbd.c | 9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
+index 8e5140bbf241..1e92b61d0bd5 100644
+--- a/drivers/block/rbd.c
++++ b/drivers/block/rbd.c
+@@ -5986,7 +5986,6 @@ static ssize_t do_rbd_remove(struct bus_type *bus,
+ struct list_head *tmp;
+ int dev_id;
+ char opt_buf[6];
+- bool already = false;
+ bool force = false;
+ int ret;
+
+@@ -6019,13 +6018,13 @@ static ssize_t do_rbd_remove(struct bus_type *bus,
+ spin_lock_irq(&rbd_dev->lock);
+ if (rbd_dev->open_count && !force)
+ ret = -EBUSY;
+- else
+- already = test_and_set_bit(RBD_DEV_FLAG_REMOVING,
+- &rbd_dev->flags);
++ else if (test_and_set_bit(RBD_DEV_FLAG_REMOVING,
++ &rbd_dev->flags))
++ ret = -EINPROGRESS;
+ spin_unlock_irq(&rbd_dev->lock);
+ }
+ spin_unlock(&rbd_dev_list_lock);
+- if (ret < 0 || already)
++ if (ret)
+ return ret;
+
+ if (force) {
+--
+2.20.1
+
diff --git a/series.conf b/series.conf
index a6790beaac..c6269768bc 100644
--- a/series.conf
+++ b/series.conf
@@ -283,6 +283,7 @@
patches.kernel.org/4.20.3-043-drm-i915-Unwind-failure-on-pinning-the-gen7-pp.patch
patches.kernel.org/4.20.3-044-drm-amdgpu-Don-t-ignore-rc-from-drm_dp_mst_top.patch
patches.kernel.org/4.20.3-045-drm-amdgpu-Don-t-fail-resume-process-if-resumi.patch
+ patches.kernel.org/4.20.3-046-rbd-don-t-return-0-on-unmap-if-RBD_DEV_FLAG_RE.patch
########################################################
# Build fixes that apply to the vanilla kernel too.