On (05/06/15 16:28), Minchan Kim wrote:
> > 
> > from your logs:
> > ...
> > [ 98.756017] zram: Removed device: zram2
> > [ 98.757087] ------------[ cut here ]------------
> > ...
> > 
> > locked zram_index_mutex, removed zram2, unlocked zram_index_mutex,
> > locked zram_index_mutex, attempted to create zram2: zram2 sysfs already 
> > exist.
> > 
> > 
> > hm... need to think. zram hot/remove is serialized.
> 
> I never look at the code but I doubt others(ex, some admin process on my 
> machine)
> holds a ref so kobj doesn't disapper yet but zram_add try to create it?
> 

well, something like this is certainly happening. hm, if this is the
case, then a very quick thing I can think of is to stop re-using previously
used zram ids. add_disk() doesn't give us a chance to handle any errors and
testing for sysfs leftovers in zram_add() looks weird.


btw, do you also want me to rename zram-control sysfs handlers?
zram_add -> zram_hot_add() ? i think zram_add()/zram_remove() is just
ok.



can you please test this patch?

---

 drivers/block/zram/zram_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index e6c4316..b31f0c20 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1184,7 +1184,7 @@ static int zram_add(void)
        if (!zram)
                return -ENOMEM;
 
-       ret = idr_alloc(&zram_index_idr, zram, 0, 0, GFP_KERNEL);
+       ret = idr_alloc_cyclic(&zram_index_idr, zram, 0, 0, GFP_KERNEL);
        if (ret < 0)
                goto out_free_dev;
        device_id = ret;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to