All of lore.kernel.org
 help / color / mirror / Atom feed
From: Minchan Kim <minchan@kernel.org>
To: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Nitin Gupta <ngupta@vflare.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCHv4 00/10] add on-demand device creation
Date: Thu, 7 May 2015 16:41:59 +0900	[thread overview]
Message-ID: <20150507074159.GA3624@blaptop> (raw)
In-Reply-To: <20150507003322.GA4153@swordfish>

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

  reply	other threads:[~2015-05-07  7:42 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-04 12:38 [PATCHv4 00/10] add on-demand device creation Sergey Senozhatsky
2015-05-04 12:38 ` [PATCHv4 01/10] zram: add `compact` sysfs entry to documentation Sergey Senozhatsky
2015-05-04 12:38 ` [PATCHv4 02/10] zram: cosmetic ZRAM_ATTR_RO code formatting tweak Sergey Senozhatsky
2015-05-04 12:38 ` [PATCHv4 03/10] zram: use idr instead of `zram_devices' array Sergey Senozhatsky
2015-05-04 12:38 ` [PATCHv4 04/10] zram: reorganize code layout Sergey Senozhatsky
2015-05-04 12:38 ` [PATCHv4 05/10] zram: remove max_num_devices limitation Sergey Senozhatsky
2015-05-04 12:38 ` [PATCHv4 06/10] zram: report every added and removed device Sergey Senozhatsky
2015-05-04 12:38 ` [PATCHv4 07/10] zram: trivial: correct flag operations comment Sergey Senozhatsky
2015-05-04 12:39 ` [PATCHv4 08/10] zram: return zram device_id from zram_add() Sergey Senozhatsky
2015-05-04 12:39 ` [PATCHv4 09/10] zram: close race by open overriding Sergey Senozhatsky
2015-05-04 12:39 ` [PATCHv4 10/10] zram: add dynamic device add/remove functionality Sergey Senozhatsky
2015-05-06  5:01 ` [PATCHv4 00/10] add on-demand device creation Minchan Kim
2015-05-06  5:25   ` Sergey Senozhatsky
2015-05-06  6:52     ` Minchan Kim
2015-05-06  7:07     ` Sergey Senozhatsky
2015-05-06  7:28       ` Minchan Kim
2015-05-06  8:10         ` Sergey Senozhatsky
2015-05-06  8:20           ` Minchan Kim
2015-05-07  0:33             ` Sergey Senozhatsky
2015-05-07  7:41               ` Minchan Kim [this message]
2015-05-07 12:09                 ` Sergey Senozhatsky
2015-05-07 13:04                   ` Sergey Senozhatsky
2015-05-07 15:11                     ` Minchan Kim
2015-05-08  0:15                       ` Sergey Senozhatsky
2015-05-10  8:47                       ` Sergey Senozhatsky
2015-05-06  5:31 ` Sergey Senozhatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150507074159.GA3624@blaptop \
    --to=minchan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ngupta@vflare.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=sergey.senozhatsky@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.