diff options
author | Nitin Gupta <ngupta@vflare.org> | 2010-08-09 22:56:47 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-31 15:33:54 -0700 |
commit | 33863c21e69e9bd988b63580ada0b729c1d90215 (patch) | |
tree | 75b4416212d83929e519c7be058a005ea5e5a917 /drivers/staging/zram/zram_drv.h | |
parent | e1a164d7a3e05aae15eb603ee8f1b77446480a3b (diff) |
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>
Diffstat (limited to 'drivers/staging/zram/zram_drv.h')
-rw-r--r-- | drivers/staging/zram/zram_drv.h | 55 |
1 files changed, 10 insertions, 45 deletions
diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h index 945f9740442f..2ef93cc2024a 100644 --- a/drivers/staging/zram/zram_drv.h +++ b/drivers/staging/zram/zram_drv.h @@ -18,7 +18,6 @@ #include <linux/spinlock.h> #include <linux/mutex.h> -#include "zram_ioctl.h" #include "xvmalloc.h" /* @@ -85,11 +84,7 @@ struct table { } __attribute__((aligned(4))); struct zram_stats { - /* basic stats */ - size_t compr_size; /* compressed size of pages stored - - * needed to enforce memlimit */ - /* more stats */ -#if defined(CONFIG_ZRAM_STATS) + u64 compr_size; /* compressed size of pages stored */ u64 num_reads; /* failed + successful */ u64 num_writes; /* --do-- */ u64 failed_reads; /* should NEVER! happen */ @@ -100,7 +95,6 @@ struct zram_stats { u32 pages_stored; /* no. of pages currently stored */ u32 good_compress; /* % of pages with compression ratio<=50% */ u32 pages_expand; /* % of incompressible pages */ -#endif }; struct zram { @@ -118,47 +112,18 @@ struct zram { * This is the limit on amount of *uncompressed* worth of data * we can store in a disk. */ - size_t disksize; /* bytes */ + u64 disksize; /* bytes */ struct zram_stats stats; }; -/*-- */ - -/* Debugging and Stats */ -#if defined(CONFIG_ZRAM_STATS) -static void zram_stat_inc(u32 *v) -{ - *v = *v + 1; -} - -static void zram_stat_dec(u32 *v) -{ - *v = *v - 1; -} - -static void zram_stat64_inc(struct zram *zram, u64 *v) -{ - spin_lock(&zram->stat64_lock); - *v = *v + 1; - spin_unlock(&zram->stat64_lock); -} - -static u64 zram_stat64_read(struct zram *zram, u64 *v) -{ - u64 val; - - spin_lock(&zram->stat64_lock); - val = *v; - spin_unlock(&zram->stat64_lock); - - return val; -} -#else -#define zram_stat_inc(v) -#define zram_stat_dec(v) -#define zram_stat64_inc(r, v) -#define zram_stat64_read(r, v) -#endif /* CONFIG_ZRAM_STATS */ +extern struct zram *devices; +extern unsigned int num_devices; +#ifdef CONFIG_SYSFS +extern struct attribute_group zram_disk_attr_group; +#endif + +extern int zram_init_device(struct zram *zram); +extern void zram_reset_device(struct zram *zram); #endif |