public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Geliang Tang <geliangtang@163.com>
Cc: Minchan Kim <minchan@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	linux-kernel@vger.kernel.org,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: Re: [PATCH] zram: move init_done check to the beginning of disksize_store
Date: Mon, 2 Nov 2015 08:43:58 +0900	[thread overview]
Message-ID: <20151101234358.GA4783@swordfish> (raw)
In-Reply-To: <b159080b26efe0d962dc51144dcafba7cac7af43.1446302806.git.geliangtang@163.com>

On (10/31/15 22:50), Geliang Tang wrote:
> 
> If we set disksize when disksize has been set, we will get the following
> error report: "write error: Cannot allocate memory". This is because
> disksize_store fails at zram_meta_alloc.

Those things are not connected, absolutely. zram_meta_alloc() can fail
even on un-initialized device. In any case disksize_store() does not end
up changing the state of the device and reports the error back, so I don't
see any real value in this change. Seems that we come across this change
something like once a year (this patch is not the first).

I believe it has to stay the way it is, see https://lkml.org/lkml/2014/2/27/674

	-ss

> This is not what we expect.
> To solve this problem, this patch moves init_done check to the beginning
> of disksize_store.
> 
> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
>  drivers/block/zram/zram_drv.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index 81a557c..609fc2b 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -1028,6 +1028,14 @@ static ssize_t disksize_store(struct device *dev,
>  	struct zram *zram = dev_to_zram(dev);
>  	int err;
>  
> +	down_read(&zram->init_lock);
> +	if (init_done(zram)) {
> +		up_read(&zram->init_lock);
> +		pr_info("Cannot change disksize for initialized device\n");
> +		return -EBUSY;
> +	}
> +	up_read(&zram->init_lock);
> +
>  	disksize = memparse(buf, NULL);
>  	if (!disksize)
>  		return -EINVAL;
> @@ -1046,12 +1054,6 @@ static ssize_t disksize_store(struct device *dev,
>  	}
>  
>  	down_write(&zram->init_lock);
> -	if (init_done(zram)) {
> -		pr_info("Cannot change disksize for initialized device\n");
> -		err = -EBUSY;
> -		goto out_destroy_comp;
> -	}
> -
>  	init_waitqueue_head(&zram->io_done);
>  	atomic_set(&zram->refcount, 1);
>  	zram->meta = meta;
> @@ -1069,9 +1071,6 @@ static ssize_t disksize_store(struct device *dev,
>  
>  	return len;
>  
> -out_destroy_comp:
> -	up_write(&zram->init_lock);
> -	zcomp_destroy(comp);
>  out_free_meta:
>  	zram_meta_free(meta, disksize);
>  	return err;
> -- 
> 2.4.3
> 
> 

  reply	other threads:[~2015-11-01 23:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-31 14:50 [PATCH] zram: move init_done check to the beginning of disksize_store Geliang Tang
2015-11-01 23:43 ` Sergey Senozhatsky [this message]
2015-11-02 13:53   ` Geliang Tang
2015-11-03  0:18     ` 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=20151101234358.GA4783@swordfish \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=geliangtang@163.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox