Staging: hv: remove OnIsr vmbus_driver callback
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / zram / zram_drv.h
bloba48155112b1e68a736cd8018f0b504860e20b8c3
1 /*
2 * Compressed RAM block device
4 * Copyright (C) 2008, 2009, 2010 Nitin Gupta
6 * This code is released using a dual license strategy: BSD/GPL
7 * You can choose the licence that better fits your requirements.
9 * Released under the terms of 3-clause BSD License
10 * Released under the terms of GNU General Public License Version 2.0
12 * Project home: http://compcache.googlecode.com
15 #ifndef _ZRAM_DRV_H_
16 #define _ZRAM_DRV_H_
18 #include <linux/spinlock.h>
19 #include <linux/mutex.h>
21 #include "xvmalloc.h"
24 * Some arbitrary value. This is just to catch
25 * invalid value for num_devices module parameter.
27 static const unsigned max_num_devices = 32;
30 * Stored at beginning of each compressed object.
32 * It stores back-reference to table entry which points to this
33 * object. This is required to support memory defragmentation.
35 struct zobj_header {
36 #if 0
37 u32 table_idx;
38 #endif
41 /*-- Configurable parameters */
43 /* Default zram disk size: 25% of total RAM */
44 static const unsigned default_disksize_perc_ram = 25;
47 * Pages that compress to size greater than this are stored
48 * uncompressed in memory.
50 static const unsigned max_zpage_size = PAGE_SIZE / 4 * 3;
53 * NOTE: max_zpage_size must be less than or equal to:
54 * XV_MAX_ALLOC_SIZE - sizeof(struct zobj_header)
55 * otherwise, xv_malloc() would always return failure.
58 /*-- End of configurable params */
60 #define SECTOR_SHIFT 9
61 #define SECTOR_SIZE (1 << SECTOR_SHIFT)
62 #define SECTORS_PER_PAGE_SHIFT (PAGE_SHIFT - SECTOR_SHIFT)
63 #define SECTORS_PER_PAGE (1 << SECTORS_PER_PAGE_SHIFT)
65 /* Flags for zram pages (table[page_no].flags) */
66 enum zram_pageflags {
67 /* Page is stored uncompressed */
68 ZRAM_UNCOMPRESSED,
70 /* Page consists entirely of zeros */
71 ZRAM_ZERO,
73 __NR_ZRAM_PAGEFLAGS,
76 /*-- Data structures */
78 /* Allocated for each disk page */
79 struct table {
80 struct page *page;
81 u16 offset;
82 u8 count; /* object ref count (not yet used) */
83 u8 flags;
84 } __attribute__((aligned(4)));
86 struct zram_stats {
87 u64 compr_size; /* compressed size of pages stored */
88 u64 num_reads; /* failed + successful */
89 u64 num_writes; /* --do-- */
90 u64 failed_reads; /* should NEVER! happen */
91 u64 failed_writes; /* can happen when memory is too low */
92 u64 invalid_io; /* non-page-aligned I/O requests */
93 u64 notify_free; /* no. of swap slot free notifications */
94 u32 pages_zero; /* no. of zero filled pages */
95 u32 pages_stored; /* no. of pages currently stored */
96 u32 good_compress; /* % of pages with compression ratio<=50% */
97 u32 pages_expand; /* % of incompressible pages */
100 struct zram {
101 struct xv_pool *mem_pool;
102 void *compress_workmem;
103 void *compress_buffer;
104 struct table *table;
105 spinlock_t stat64_lock; /* protect 64-bit stats */
106 struct mutex lock; /* protect compression buffers against
107 * concurrent writes */
108 struct request_queue *queue;
109 struct gendisk *disk;
110 int init_done;
111 /* Prevent concurrent execution of device init and reset */
112 struct mutex init_lock;
114 * This is the limit on amount of *uncompressed* worth of data
115 * we can store in a disk.
117 u64 disksize; /* bytes */
119 struct zram_stats stats;
122 extern struct zram *devices;
123 extern unsigned int num_devices;
124 #ifdef CONFIG_SYSFS
125 extern struct attribute_group zram_disk_attr_group;
126 #endif
128 extern int zram_init_device(struct zram *zram);
129 extern void zram_reset_device(struct zram *zram);
131 #endif