mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-04 16:15:11 +00:00
rbd: don't return 0 on unmap if RBD_DEV_FLAG_REMOVING is set
commit 85f5a4d666
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>
This commit is contained in:
parent
57cd3fad76
commit
f710ce8ad2
1 changed files with 4 additions and 5 deletions
|
@ -6346,7 +6346,6 @@ static ssize_t do_rbd_remove(struct bus_type *bus,
|
||||||
struct list_head *tmp;
|
struct list_head *tmp;
|
||||||
int dev_id;
|
int dev_id;
|
||||||
char opt_buf[6];
|
char opt_buf[6];
|
||||||
bool already = false;
|
|
||||||
bool force = false;
|
bool force = false;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -6379,13 +6378,13 @@ static ssize_t do_rbd_remove(struct bus_type *bus,
|
||||||
spin_lock_irq(&rbd_dev->lock);
|
spin_lock_irq(&rbd_dev->lock);
|
||||||
if (rbd_dev->open_count && !force)
|
if (rbd_dev->open_count && !force)
|
||||||
ret = -EBUSY;
|
ret = -EBUSY;
|
||||||
else
|
else if (test_and_set_bit(RBD_DEV_FLAG_REMOVING,
|
||||||
already = test_and_set_bit(RBD_DEV_FLAG_REMOVING,
|
&rbd_dev->flags))
|
||||||
&rbd_dev->flags);
|
ret = -EINPROGRESS;
|
||||||
spin_unlock_irq(&rbd_dev->lock);
|
spin_unlock_irq(&rbd_dev->lock);
|
||||||
}
|
}
|
||||||
spin_unlock(&rbd_dev_list_lock);
|
spin_unlock(&rbd_dev_list_lock);
|
||||||
if (ret < 0 || already)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (force) {
|
if (force) {
|
||||||
|
|
Loading…
Reference in a new issue