* [PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter
@ 2012-10-27 16:03 Sergey Senozhatsky
2012-10-29 17:21 ` Nitin Gupta
0 siblings, 1 reply; 6+ messages in thread
From: Sergey Senozhatsky @ 2012-10-27 16:03 UTC (permalink / raw)
To: Nitin Gupta; +Cc: Greg Kroah-Hartman, linux-kernel
zram: handle mem suffixes in disk size zram_sysfs parameter
Use memparse() to allow mem suffixes in disksize sysfs number.
Examples:
echo 256K > /sys/block/zram0/disksize
echo 512M > /sys/block/zram0/disksize
echo 1G > /sys/block/zram0/disksize
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
drivers/staging/zram/zram_sysfs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c
index edb0ed4..6be318e 100644
--- a/drivers/staging/zram/zram_sysfs.c
+++ b/drivers/staging/zram/zram_sysfs.c
@@ -15,6 +15,7 @@
#include <linux/device.h>
#include <linux/genhd.h>
#include <linux/mm.h>
+#include <linux/kernel.h>
#include "zram_drv.h"
@@ -54,13 +55,12 @@ static ssize_t disksize_show(struct device *dev,
static ssize_t disksize_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len)
{
- int ret;
u64 disksize;
struct zram *zram = dev_to_zram(dev);
- ret = kstrtoull(buf, 10, &disksize);
- if (ret)
- return ret;
+ disksize = memparse(buf, NULL);
+ if (disksize < 1)
+ return -EINVAL;
down_write(&zram->init_lock);
if (zram->init_done) {
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter
2012-10-27 16:03 [PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter Sergey Senozhatsky
@ 2012-10-29 17:21 ` Nitin Gupta
2012-10-29 17:30 ` Sergey Senozhatsky
2012-10-29 17:41 ` [PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter (v2) Sergey Senozhatsky
0 siblings, 2 replies; 6+ messages in thread
From: Nitin Gupta @ 2012-10-29 17:21 UTC (permalink / raw)
To: Sergey Senozhatsky; +Cc: Greg Kroah-Hartman, linux-kernel
On 10/27/2012 09:03 AM, Sergey Senozhatsky wrote:
> zram: handle mem suffixes in disk size zram_sysfs parameter
>
> Use memparse() to allow mem suffixes in disksize sysfs number.
> Examples:
> echo 256K > /sys/block/zram0/disksize
> echo 512M > /sys/block/zram0/disksize
> echo 1G > /sys/block/zram0/disksize
>
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
>
> ---
>
> drivers/staging/zram/zram_sysfs.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c
> index edb0ed4..6be318e 100644
> --- a/drivers/staging/zram/zram_sysfs.c
> +++ b/drivers/staging/zram/zram_sysfs.c
> @@ -15,6 +15,7 @@
> #include <linux/device.h>
> #include <linux/genhd.h>
> #include <linux/mm.h>
> +#include <linux/kernel.h>
>
> #include "zram_drv.h"
>
> @@ -54,13 +55,12 @@ static ssize_t disksize_show(struct device *dev,
> static ssize_t disksize_store(struct device *dev,
> struct device_attribute *attr, const char *buf, size_t len)
> {
> - int ret;
> u64 disksize;
> struct zram *zram = dev_to_zram(dev);
>
> - ret = kstrtoull(buf, 10, &disksize);
> - if (ret)
> - return ret;
> + disksize = memparse(buf, NULL);
> + if (disksize < 1)
> + return -EINVAL;
>
or, just: if (!disksize) ...
Thanks,
Nitin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter
2012-10-29 17:21 ` Nitin Gupta
@ 2012-10-29 17:30 ` Sergey Senozhatsky
2012-10-29 17:41 ` [PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter (v2) Sergey Senozhatsky
1 sibling, 0 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2012-10-29 17:30 UTC (permalink / raw)
To: Nitin Gupta; +Cc: Greg Kroah-Hartman, linux-kernel
On (10/29/12 10:21), Nitin Gupta wrote:
> >+#include <linux/kernel.h>
> >
> > #include "zram_drv.h"
> >
> >@@ -54,13 +55,12 @@ static ssize_t disksize_show(struct device *dev,
> > static ssize_t disksize_store(struct device *dev,
> > struct device_attribute *attr, const char *buf, size_t len)
> > {
> >- int ret;
> > u64 disksize;
> > struct zram *zram = dev_to_zram(dev);
> >
> >- ret = kstrtoull(buf, 10, &disksize);
> >- if (ret)
> >- return ret;
> >+ disksize = memparse(buf, NULL);
> >+ if (disksize < 1)
> >+ return -EINVAL;
> >
>
> or, just: if (!disksize) ...
>
will resend shortly.
-ss
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter (v2)
2012-10-29 17:21 ` Nitin Gupta
2012-10-29 17:30 ` Sergey Senozhatsky
@ 2012-10-29 17:41 ` Sergey Senozhatsky
2012-10-29 18:33 ` Nitin Gupta
1 sibling, 1 reply; 6+ messages in thread
From: Sergey Senozhatsky @ 2012-10-29 17:41 UTC (permalink / raw)
To: Nitin Gupta; +Cc: Greg Kroah-Hartman, linux-kernel
zram: handle mem suffixes in disk size zram_sysfs parameter
Use memparse() to allow mem suffixes in disksize sysfs number.
Examples:
echo 256K > /sys/block/zram0/disksize
echo 512M > /sys/block/zram0/disksize
echo 1G > /sys/block/zram0/disksize
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
drivers/staging/zram/zram_sysfs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c
index edb0ed4..de1eacf 100644
--- a/drivers/staging/zram/zram_sysfs.c
+++ b/drivers/staging/zram/zram_sysfs.c
@@ -15,6 +15,7 @@
#include <linux/device.h>
#include <linux/genhd.h>
#include <linux/mm.h>
+#include <linux/kernel.h>
#include "zram_drv.h"
@@ -54,13 +55,12 @@ static ssize_t disksize_show(struct device *dev,
static ssize_t disksize_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len)
{
- int ret;
u64 disksize;
struct zram *zram = dev_to_zram(dev);
- ret = kstrtoull(buf, 10, &disksize);
- if (ret)
- return ret;
+ disksize = memparse(buf, NULL);
+ if (!disksize)
+ return -EINVAL;
down_write(&zram->init_lock);
if (zram->init_done) {
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter (v2)
2012-10-29 17:41 ` [PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter (v2) Sergey Senozhatsky
@ 2012-10-29 18:33 ` Nitin Gupta
0 siblings, 0 replies; 6+ messages in thread
From: Nitin Gupta @ 2012-10-29 18:33 UTC (permalink / raw)
To: Sergey Senozhatsky; +Cc: Greg Kroah-Hartman, linux-kernel
On Mon, Oct 29, 2012 at 10:41 AM, Sergey Senozhatsky
<sergey.senozhatsky@gmail.com> wrote:
> zram: handle mem suffixes in disk size zram_sysfs parameter
>
> Use memparse() to allow mem suffixes in disksize sysfs number.
> Examples:
> echo 256K > /sys/block/zram0/disksize
> echo 512M > /sys/block/zram0/disksize
> echo 1G > /sys/block/zram0/disksize
>
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
>
FWIW,
Reviewed-by: Nitin Gupta <ngupta@vflare.org>
Thanks,
Nitin
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter
2012-10-30 18:04 ` Greg Kroah-Hartman
@ 2012-10-30 19:00 ` Sergey Senozhatsky
0 siblings, 0 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2012-10-30 19:00 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Nitin Gupta, linux-kernel
zram: handle mem suffixes in disk size zram_sysfs parameter
Use memparse() to allow mem suffixes in disksize sysfs number.
Examples:
echo 256K > /sys/block/zram0/disksize
echo 512M > /sys/block/zram0/disksize
echo 1G > /sys/block/zram0/disksize
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
drivers/staging/zram/zram_sysfs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c
index edb0ed4..de1eacf 100644
--- a/drivers/staging/zram/zram_sysfs.c
+++ b/drivers/staging/zram/zram_sysfs.c
@@ -15,6 +15,7 @@
#include <linux/device.h>
#include <linux/genhd.h>
#include <linux/mm.h>
+#include <linux/kernel.h>
#include "zram_drv.h"
@@ -54,13 +55,12 @@ static ssize_t disksize_show(struct device *dev,
static ssize_t disksize_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len)
{
- int ret;
u64 disksize;
struct zram *zram = dev_to_zram(dev);
- ret = kstrtoull(buf, 10, &disksize);
- if (ret)
- return ret;
+ disksize = memparse(buf, NULL);
+ if (!disksize)
+ return -EINVAL;
down_write(&zram->init_lock);
if (zram->init_done) {
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-10-30 19:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-27 16:03 [PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter Sergey Senozhatsky
2012-10-29 17:21 ` Nitin Gupta
2012-10-29 17:30 ` Sergey Senozhatsky
2012-10-29 17:41 ` [PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter (v2) Sergey Senozhatsky
2012-10-29 18:33 ` Nitin Gupta
2012-10-30 9:03 [PATCH 2/2] zram: permit sleeping while in pool zs_malloc() Sergey Senozhatsky
2012-10-30 18:04 ` Greg Kroah-Hartman
2012-10-30 19:00 ` [PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter Sergey Senozhatsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).