From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752159AbbEGAdI (ORCPT ); Wed, 6 May 2015 20:33:08 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:34497 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751697AbbEGAdE (ORCPT ); Wed, 6 May 2015 20:33:04 -0400 Date: Thu, 7 May 2015 09:33:22 +0900 From: Sergey Senozhatsky To: Minchan Kim Cc: Sergey Senozhatsky , Sergey Senozhatsky , Andrew Morton , Nitin Gupta , linux-kernel@vger.kernel.org Subject: Re: [PATCHv4 00/10] add on-demand device creation Message-ID: <20150507003322.GA4153@swordfish> References: <1430743142-15854-1-git-send-email-sergey.senozhatsky@gmail.com> <20150506050114.GA29132@blaptop> <20150506052557.GA820@swordfish> <20150506070756.GC820@swordfish> <20150506072656.GA8163@blaptop> <20150506081029.GA8385@swordfish> <20150506082036.GB8163@blaptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150506082036.GB8163@blaptop> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? --- 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; }