Re: zram hot_add device busy

From: Sergey Senozhatsky
Date: Sun Jun 25 2017 - 22:58:23 EST


On (06/26/17 11:39), Sergey Senozhatsky wrote:
[..]
> ok... I don't think I see what we can do in zram about the
> issue in question.

... check init_done() in reset_store() and avoid the whole ->bd_openers
branch if the device is already reset?

// not compile tested. just a sketch. //

---

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index debee952dcc1..79b1a957a6bd 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1047,6 +1047,14 @@ static ssize_t reset_store(struct device *dev,
return -EINVAL;

zram = dev_to_zram(dev);
+
+ down_write(&zram->init_lock);
+ if (!init_done(zram)) {
+ up_write(&zram->init_lock);
+ return len;
+ }
+ up_write(&zram->init_lock);
+
bdev = bdget_disk(zram->disk, 0);
if (!bdev)
return -ENOMEM;

---

-ss