Commit 97a06382 authored by Nitin Gupta's avatar Nitin Gupta Committed by Greg Kroah-Hartman

Staging: ramzswap: Remove backing swap support

Currently, each ramzswap device can be assigned
a separate 'backing swap' file/partition. The ramzswap
driver forwards swap I/O requests to this backing swap
whenever an incompressible page is found.

This feature adds nearly 700 lines of code and it
also duplicates much of the swapon() functionality
(for example, finding swap extents and so on). Removing
this code makes the driver much simpler and should
help its transition from staging to stable drivers
area (drivers/block/).

Similar functionality may be implemented if we can
implement migrating pages across swap devices but the
details have not yet been worked out.

Support for _partitions_ as backing swap could be
retained as it requires a few lines of code only.
This part can be re-introduced later if above swap
migration method turns out to be infeasible.

More cleanups and code comments will be added soon.
Signed-off-by: default avatarNitin Gupta <ngupta@vflare.org>
Acked-by: default avatarPekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 3cdec554
This diff is collapsed.
......@@ -31,8 +31,7 @@ static const unsigned max_num_devices = 32;
* Stored at beginning of each compressed object.
*
* It stores back-reference to table entry which points to this
* object. This is required to support memory defragmentation or
* migrating compressed pages to backing swap disk.
* object. This is required to support memory defragmentation.
*/
struct zobj_header {
#if 0
......@@ -44,27 +43,17 @@ struct zobj_header {
/* Default ramzswap disk size: 25% of total RAM */
static const unsigned default_disksize_perc_ram = 25;
static const unsigned default_memlimit_perc_ram = 15;
/*
* Max compressed page size when backing device is provided.
* Pages that compress to size greater than this are sent to
* physical swap disk.
*/
static const unsigned max_zpage_size_bdev = PAGE_SIZE / 2;
/*
* Max compressed page size when there is no backing dev.
* Pages that compress to size greater than this are stored
* uncompressed in memory.
*/
static const unsigned max_zpage_size_nobdev = PAGE_SIZE / 4 * 3;
static const unsigned max_zpage_size = PAGE_SIZE / 4 * 3;
/*
* NOTE: max_zpage_size_{bdev,nobdev} sizes must be
* less than or equal to:
* NOTE: max_zpage_size must be less than or equal to:
* XV_MAX_ALLOC_SIZE - sizeof(struct zobj_header)
* since otherwise xv_malloc would always return failure.
* otherwise, xv_malloc() would always return failure.
*/
/*-- End of configurable params */
......@@ -98,15 +87,6 @@ struct table {
u8 flags;
} __attribute__((aligned(4)));
/*
* Swap extent information in case backing swap is a regular
* file. These extent entries must fit exactly in a page.
*/
struct ramzswap_backing_extent {
pgoff_t phy_pagenum;
pgoff_t num_pages;
} __attribute__((aligned(4)));
struct ramzswap_stats {
/* basic stats */
size_t compr_size; /* compressed size of pages stored -
......@@ -123,8 +103,6 @@ struct ramzswap_stats {
u32 pages_stored; /* no. of pages currently stored */
u32 good_compress; /* % of pages with compression ratio<=50% */
u32 pages_expand; /* % of incompressible pages */
u64 bdev_num_reads; /* no. of reads on backing dev */
u64 bdev_num_writes; /* no. of writes on backing dev */
#endif
};
......@@ -138,11 +116,6 @@ struct ramzswap {
struct request_queue *queue;
struct gendisk *disk;
int init_done;
/*
* This is limit on compressed data size (stats.compr_size)
* Its applicable only when backing swap device is present.
*/
size_t memlimit; /* bytes */
/*
* This is limit on amount of *uncompressed* worth of data
* we can hold. When backing swap device is provided, it is
......@@ -151,14 +124,6 @@ struct ramzswap {
size_t disksize; /* bytes */
struct ramzswap_stats stats;
/* backing swap device info */
struct ramzswap_backing_extent *curr_extent;
struct list_head backing_swap_extent_list;
unsigned long num_extents;
char backing_swap_name[MAX_SWAP_NAME_LEN];
struct block_device *backing_swap;
struct file *swap_file;
};
/*-- */
......@@ -182,13 +147,6 @@ static void rzs_stat64_inc(struct ramzswap *rzs, u64 *v)
spin_unlock(&rzs->stat64_lock);
}
static void rzs_stat64_dec(struct ramzswap *rzs, u64 *v)
{
spin_lock(&rzs->stat64_lock);
*v = *v - 1;
spin_unlock(&rzs->stat64_lock);
}
static u64 rzs_stat64_read(struct ramzswap *rzs, u64 *v)
{
u64 val;
......@@ -203,7 +161,6 @@ static u64 rzs_stat64_read(struct ramzswap *rzs, u64 *v)
#define rzs_stat_inc(v)
#define rzs_stat_dec(v)
#define rzs_stat64_inc(r, v)
#define rzs_stat64_dec(r, v)
#define rzs_stat64_read(r, v)
#endif /* CONFIG_RAMZSWAP_STATS */
......
......@@ -15,11 +15,7 @@
#ifndef _RAMZSWAP_IOCTL_H_
#define _RAMZSWAP_IOCTL_H_
#define MAX_SWAP_NAME_LEN 128
struct ramzswap_ioctl_stats {
char backing_swap_name[MAX_SWAP_NAME_LEN];
u64 memlimit; /* only applicable if backing swap present */
u64 disksize; /* user specified or equal to backing swap
* size (if present) */
u64 num_reads; /* failed + successful */
......@@ -36,15 +32,11 @@ struct ramzswap_ioctl_stats {
u64 orig_data_size;
u64 compr_data_size;
u64 mem_used_total;
u64 bdev_num_reads; /* no. of reads on backing dev */
u64 bdev_num_writes; /* no. of writes on backing dev */
} __attribute__ ((packed, aligned(4)));
#define RZSIO_SET_DISKSIZE_KB _IOW('z', 0, size_t)
#define RZSIO_SET_MEMLIMIT_KB _IOW('z', 1, size_t)
#define RZSIO_SET_BACKING_SWAP _IOW('z', 2, unsigned char[MAX_SWAP_NAME_LEN])
#define RZSIO_GET_STATS _IOR('z', 3, struct ramzswap_ioctl_stats)
#define RZSIO_INIT _IO('z', 4)
#define RZSIO_RESET _IO('z', 5)
#define RZSIO_GET_STATS _IOR('z', 1, struct ramzswap_ioctl_stats)
#define RZSIO_INIT _IO('z', 2)
#define RZSIO_RESET _IO('z', 3)
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment