On Thu, May 07, 2015 at 09:33:22AM +0900, Sergey Senozhatsky wrote:
> On (05/06/15 17:20), Minchan Kim wrote:
> > I'm fine, too.
> > 
> > > 
> > > 
> > > 
> > > can you please test this patch?
> > 
> > I tested it and couldn't reproduce it during 5 minutes so it seems
> > we are correct about culpit.
> > However, it's trick and we should find a right way. :)
> > 
> 
> well, I can't reproduce this race.
> 
> btw, just for info. your script does
> 
> zram_add
> dd &
> zram_remove
> 
> by the time dd starts writing zramX device may be gone, so along with
> block devices we can see regular files in /dev/
> 
> [..]
> brw-rw---- 1 root disk   254, 0 May  7 09:16 /dev/zram0
> -rw-r--r-- 1 root root 10485760 May  7 09:17 /dev/zram1
> -rw-r--r-- 1 root root 10485760 May  7 09:20 /dev/zram10
> [..]
> 
> 
> can you please test thit patch?

Hello Sergey,

Unfortunately, I can reproduce in a few second with this patch.

> 
> ---
> 
>  drivers/block/zram/zram_drv.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index e6c4316..1e99d9f 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -1278,6 +1278,8 @@ out_free_dev:
>  static int zram_remove(struct zram *zram)
>  {
>       struct block_device *bdev;
> +     struct request_queue *q;
> +     int device_id;
>  
>       bdev = bdget_disk(zram->disk, 0);
>       if (!bdev)
> @@ -1306,14 +1308,18 @@ static int zram_remove(struct zram *zram)
>       /* Make sure all the pending I/O are finished */
>       fsync_bdev(bdev);
>       zram_reset_device(zram);
> -     bdput(bdev);
> +
> +     q = zram->disk->queue;
> +     device_id = zram->disk->first_minor;
>  
>       pr_info("Removed device: %s\n", zram->disk->disk_name);
>  
> -     idr_remove(&zram_index_idr, zram->disk->first_minor);
> -     blk_cleanup_queue(zram->disk->queue);
>       del_gendisk(zram->disk);
>       put_disk(zram->disk);
> +     blk_cleanup_queue(q);
> +     bdput(bdev);
> +
> +     idr_remove(&zram_index_idr, device_id);
>       kfree(zram);
>       return 0;
>  }

-- 
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
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