Commit Graph

14 Commits (312facaf924edd4db6b81e3a1518adf56c9cd8bd)

Author SHA1 Message Date
Sergey Senozhatsky 26907840e6 staging: 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>
Reviewed-by: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-10-31 14:49:09 -07:00
Minchan Kim 130f315a17 staging: zram: remove special handle of uncompressed page
xvmalloc can't handle PAGE_SIZE page so that zram have to
handle it specially but zsmalloc can do it so let's remove
unnecessary special handling code.

Quote from Nitin
"I think page vs handle distinction was added since xvmalloc could not
handle full page allocation. Now that zsmalloc allows full page
allocation, we can just use it for both cases. This would also allow
removing the ZRAM_UNCOMPRESSED flag. The only downside will be slightly
slower code path for full page allocation but this event is anyways
supposed to be rare, so should be fine."

1. This patch reduces code very much.

 drivers/staging/zram/zram_drv.c   |  104 +++++--------------------------------
 drivers/staging/zram/zram_drv.h   |   17 +-----
 drivers/staging/zram/zram_sysfs.c |    6 +--
 3 files changed, 15 insertions(+), 112 deletions(-)

2. change pages_expand with bad_compress so it can count
   bad compression(above 75%) ratio.

3. remove zobj_header which is for back-reference for defragmentation
   because firstly, it's not used at the moment and zsmalloc can't handle
   bigger size than PAGE_SIZE so zram can't do it any more without redesign.

Cc: Seth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: Minchan Kim <minchan@kernel.org>
Acked-by: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-11 09:00:01 -07:00
Nitin Gupta 5fa5a90116 staging: zram: Rename module parameter
zram accepts number of devices to be created
as a module parameter. This was renamed from
num_devices to zram_num_devices (without updating
the documentation!) since num_devices was declared
as a non-static global variable, polluting the global
namespace. Now, we declare it as a static variable
and revert back the name change.

The documentation (zram.txt) already mentions
num_devices as the module parameter name.

Signed-off-by: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-13 20:11:54 -08:00
Nitin Gupta fd1a30dea1 staging: zram: replace xvmalloc with zsmalloc
Replaces xvmalloc with zsmalloc as the compressed page allocator
for zram

Signed-off-by: Nitin Gupta <ngupta@vflare.org>
Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-08 17:13:00 -08:00
Sergey Datsevich 04e7bbad44 Staging: zram/zram_sysfs.c: Fixed call of obsolete function strict_strtoX
As reported by checkpatch.pl strict_strtoX is obsolet and should be
replaced by kstrtoX.

Signed-off-by: Sergey Datsevich <srgdts@gmail.com>
Signed-off-by: Bjoern Meier <bjoernmeier@hotmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-12-08 14:59:48 -08:00
Jerome Marchand 0900beae17 staging: zram: fix zram locking
Currently init_lock only prevents concurrent execution of zram_init_device()
and zram_reset_device() but not zram_make_request() nor sysfs store functions.

This patch changes init_lock into a rw_semaphore. A write lock is taken by
init, reset and store functions, a read lock is taken by zram_make_request().
Also, avoids to release the lock before calling __zram_reset_device() for
cleaning after a failed init, thus preventing any concurrent task to see an
inconsistent state of zram.

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-06 16:56:15 -07:00
Noah Watkins efd54f4375 staging: zram: make global var "num_devices" use unique name
The global variable "num_devices" is too general to be
global. This patch switches the name to be "zram_num_devices".

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-23 14:34:19 -07:00
Noah Watkins 43801f6e4e staging: zram: make global var "devices" use unique name
The global variable "devices" is too general to be global.
This patch switches the name to be "zram_devices".

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-23 14:34:19 -07:00
Jerome Marchand f2da98739d Staging: zram: round up the disk size provided by user
Currently disksize_store() round down the disk size provided by user.
This is probably not what one would expect, so round up instead.

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Acked-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-01-20 16:06:18 -08:00
Jerome Marchand 2b15287346 Staging: zram: make ZRAM depends on SYSFS
We can not configure zram device without sysfs anyway, so make zram
depends on it.

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Acked-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-01-20 16:06:18 -08:00
Greg Kroah-Hartman a3d1310701 Staging: zram: fix up my fixup for some sysfs attribute permissions
They should be writable by root, not readable.
Doh, stupid me with the wrong flags.

Reported-by: Jonathan Cameron <jic23@cam.ac.uk>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-18 11:27:19 -08:00
Greg Kroah-Hartman 0281b490dd Staging: zram: fix up some sysfs attribute permissions
They should not be writable by any user

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-16 11:22:43 -08:00
Nitin Gupta 484875adbc Staging: zram: Remove need for explicit device initialization
Currently, the user has to explicitly write a positive value to
initstate sysfs node before the device can be used. This event
triggers allocation of per-device metadata like memory pool,
table array and so on.

We do not pre-initialize all zram devices since the 'table' array,
mapping disk blocks to compressed chunks, takes considerable amount
of memory (8 bytes per page). So, pre-initializing all devices will
be quite wasteful if only few or none of the devices are actually
used.

This explicit device initialization from user is an odd requirement and
can be easily avoided. We now initialize the device when first write is
done to the device.

Signed-off-by: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-08-31 15:36:36 -07:00
Nitin Gupta 33863c21e6 Staging: zram: Replace ioctls with sysfs interface
Creates per-device sysfs nodes in /sys/block/zram<id>/
Currently following stats are exported:
 - disksize
 - num_reads
 - num_writes
 - invalid_io
 - zero_pages
 - orig_data_size
 - compr_data_size
 - mem_used_total

By default, disksize is set to 0. So, to start using
a zram device, fist write a disksize value and then
initialize device by writing any positive value to
initstate. For example:

        # initialize /dev/zram0 with 50MB disksize
        echo 50*1024*1024 | bc > /sys/block/zram0/disksize
        echo 1 > /sys/block/zram0/initstate

When done using a disk, issue reset to free its memory
by writing any positive value to reset node:

        echo 1 > /sys/block/zram0/reset

This change also obviates the need for 'rzscontrol' utility.

Signed-off-by: Nitin Gupta <ngupta@vflare.org>
Acked-by: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-08-31 15:33:54 -07:00