swap modules
Subsystems (5)
Dear linux-mm team,
This patch is for patching the mm and fs stuff to make the Linux 2.4.21 swap code to allow a concept of modularized swap methods. This concept and swap code is originally from Justus Heine who created the NFS swap patch for 2.2 and 2.4 . I've extracted the code and modified to make it as a generic swap module code. The vanilla kernel swap code is been moved to a file fs/blkdev_swap.c which is for normal plain block device swaps. Users can configure the kernel to include the local block device swap code or compile it as a module. Developers can also develop their own swap methods instead of using the plain swap code (may be some crypto for security reasons) . I've been using this API to develop NFS swap and netswap code for a year an more. This patch has been tested for more than a year in a production environment on smp and non-smp (I think it is quite stable though). Please find it useful.
regards,
David Chow
Documentation/Configure.help +10 -0
@@ -12784,6 +12784,16 @@ If you are running Linux on an IBM iSeries system and you want to read a CD drive owned by OS/400, say Y here. +Swapping to block device and local filesystems +CONFIG_BLOCKDEV_SWAP + Say yes to enable virtual memory swap to block devices. If you have + a local disk drive and wish to use swap say 'Y', otherwise say 'N'. + + If local swaping is option to your system, say 'M' and compile it + as a module. + + If unsure, choose 'M' to compile it as a module for safe. + Quota support CONFIG_QUOTA If you say Y here, you will be able to set per user limits for disk
drivers/scsi/sim710_d.h +672 -581
2,741 lines not on this page · raw message
fs/blkdev_swap.c +327 -0
243 lines not on this page · raw message
mm/page_io.c +19 -29
48 lines not on this page · raw message
mm/swapfile.c +250 -100
350 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
(corrected) swap modules
Please ignore the previous patch, the file drivers/scsi/sim710_d.h was accidentally patched. This is the correct one instead.
regards,
David Chow
Quoted 6 lines · David Chow
Dear linux-mm team,
This patch is for patching the mm and fs stuff to make the Linux 2.4.21 swap code to allow a concept of modularized swap methods. This concept and swap code is originally from Justus Heine who created the NFS swap patch for 2.2 and 2.4 . I've extracted the code and modified to make it as a generic swap module code. The vanilla kernel swap code is been moved to a file
fs/blkdev_swap.cwhich is for normal plain block device swaps. Users can configure the kernel to include the local block device swap code or compile it as a module. Developers can also develop their own swap methods instead of using the plain swap code (may be some crypto for security reasons) . I've been using this API to develop NFS swap and netswap code for a year an more. This patch has been tested for more than a year in a production environment on smp and non-smp (I think it is quite stable though). Please find it useful.regards,
David Chow
Documentation/Configure.help +10 -0
@@ -12784,6 +12784,16 @@ If you are running Linux on an IBM iSeries system and you want to read a CD drive owned by OS/400, say Y here. +Swapping to block device and local filesystems +CONFIG_BLOCKDEV_SWAP + Say yes to enable virtual memory swap to block devices. If you have + a local disk drive and wish to use swap say 'Y', otherwise say 'N'. + + If local swaping is option to your system, say 'M' and compile it + as a module. + + If unsure, choose 'M' to compile it as a module for safe. + Quota support CONFIG_QUOTA If you say Y here, you will be able to set per user limits for disk
fs/blkdev_swap.c +327 -0
327 lines not on this page · raw message
fs/buffer.c +1 -1
@@ -737,7 +737,7 @@ bh->b_private = private; } -static void end_buffer_io_async (struct buffer_head * bh,int uptodate) +void end_buffer_io_async (struct buffer_head * bh,int uptodate) {static spinlock_t page_uptodate_lock =SPIN_LOCK_UNLOCKED ;unsigned long flags;
fs/Config.in +2 -0
@@ -4,6 +4,8 @@ mainmenu_option next_comment comment 'File systems' +tristate 'Swapping to block devices and local filesystems' CONFIG_BLOCKDEV_SWAP + bool 'Quota support' CONFIG_QUOTA tristate 'Kernel automounter support' CONFIG_AUTOFS_FS tristate 'Kernel automounter version 4 support (also supports v3)' CONFIG_AUTOFS4_FS
fs/Makefile +1 -0
@@ -82,5 +82,6 @@ # persistent filesystems obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o)) +obj-$(CONFIG_BLOCKDEV_SWAP) += blkdev_swap.o include $(TOPDIR)/Rules.make
include/linux/fs.h +1 -0
@@ -1128,6 +1128,7 @@extern void refile_buffer (struct buffer_head * buf);extern void create_empty_buffers (struct page *,kdev_t ,unsigned long );extern void end_buffer_io_sync (struct buffer_head *bh,int uptodate); +extern void end_buffer_io_async (struct buffer_head * bh,int uptodate);/* reiserfs_writepage needs this */ extern void set_buffer_async_io (struct buffer_head *bh) ;
include/linux/swap.h +24 -5
@@ -58,15 +58,29 @@#define SWAP_MAP_MAX 0x7fff#define SWAP_MAP_BAD 0x8000 +struct swap_ops { +int (*open)(struct file *swapf,void **data); +int (*release)(struct file *swapf,void *data); +int (*rw_page)(int rw, +struct page *page,unsigned long offset,void *data); +}; + +struct swap_method { +struct swap_method *next; +char * name; +struct swap_ops *ops; +int use_count; +}; +/* * The in-memory structure used to track swap areas. */ struct swap_info_struct {unsigned int flags; -kdev_t swap_device; +struct file *swap_file; +struct swap_method *method; +void *data;spinlock_t sdev_lock; -struct dentry * swap_file; -struct vfsmount *swap_vfsmnt;unsigned short * swap_map;unsigned int lowest_bit;unsigned int highest_bit;
@@ -142,10 +156,15 @@extern unsigned int nr_swapfiles;extern struct swap_info_struct swap_info[];extern int is_swap_partition (kdev_t ); +extern int register_swap_method (char *name,struct swap_ops *ops); +extern int unregister_swap_method (char *name); +extern int swap_run_test (int (*test_fct)(unsigned int flags, +struct file *swap_file, +void *testdata),void *testdata);extern void si_swapinfo (struct sysinfo *);extern swp_entry_t get_swap_page (void ); -extern void get_swaphandle_info (swp_entry_t ,unsigned long *,kdev_t *, -struct inode **); +struct swap_method *get_swaphandle_info (swp_entry_t entry, +unsigned long *offset,void **data);extern int swap_duplicate (swp_entry_t );extern int valid_swaphandles (swp_entry_t ,unsigned long *);extern void swap_free (swp_entry_t );
kernel/ksyms.c +5 -0
@@ -41,6 +41,7 @@#include <linux/mm.h> #include <linux/capability.h> #include <linux/highuid.h> +#include <linux/swapctl.h> #include <linux/brlock.h> #include <linux/fs.h> #include <linux/tty.h>
@@ -93,6 +94,10 @@EXPORT_SYMBOL (kallsyms_symbol_to_address);EXPORT_SYMBOL (kallsyms_address_to_symbol);#endif +EXPORT_SYMBOL (nr_free_pages); +EXPORT_SYMBOL (register_swap_method); +EXPORT_SYMBOL (unregister_swap_method); +EXPORT_SYMBOL (swap_run_test);/* process memory management */ EXPORT_SYMBOL (do_mmap_pgoff);
mm/page_io.c +19 -29
65 lines not on this page · raw message
mm/swapfile.c +250 -100
510 lines not on this page · raw message