Please sign in to comment.
mm: add support for a filesystem to activate swap files and use direc…
…t_IO for writing swap pages Currently swapfiles are managed entirely by the core VM by using ->bmap to allocate space and write to the blocks directly. This effectively ensures that the underlying blocks are allocated and avoids the need for the swap subsystem to locate what physical blocks store offsets within a file. If the swap subsystem is to use the filesystem information to locate the blocks, it is critical that information such as block groups, block bitmaps and the block descriptor table that map the swap file were resident in memory. This patch adds address_space_operations that the VM can call when activating or deactivating swap backed by a file. int swap_activate(struct file *); int swap_deactivate(struct file *); The ->swap_activate() method is used to communicate to the file that the VM relies on it, and the address_space should take adequate measures such as reserving space in the underlying device, reserving memory for mempools and pinning information such as the block descriptor table in memory. The ->swap_deactivate() method is called on sys_swapoff() if ->swap_activate() returned success. After a successful swapfile ->swap_activate, the swapfile is marked SWP_FILE and swapper_space.a_ops will proxy to sis->swap_file->f_mappings->a_ops using ->direct_io to write swapcache pages and ->readpage to read. It is perfectly possible that direct_IO be used to read the swap pages but it is an unnecessary complication. Similarly, it is possible that ->writepage be used instead of direct_io to write the pages but filesystem developers have stated that calling writepage from the VM is undesirable for a variety of reasons and using direct_IO opens up the possibility of writing back batches of swap pages in the future. [email@example.com: Original patch] Signed-off-by: Mel Gorman <firstname.lastname@example.org> Acked-by: Rik van Riel <email@example.com> Cc: Christoph Hellwig <firstname.lastname@example.org> Cc: David S. Miller <email@example.com> Cc: Eric B Munson <firstname.lastname@example.org> Cc: Eric Paris <email@example.com> Cc: James Morris <firstname.lastname@example.org> Cc: Mel Gorman <email@example.com> Cc: Mike Christie <firstname.lastname@example.org> Cc: Neil Brown <email@example.com> Cc: Peter Zijlstra <firstname.lastname@example.org> Cc: Sebastian Andrzej Siewior <email@example.com> Cc: Trond Myklebust <Trond.Myklebust@netapp.com> Cc: Xiaotian Feng <firstname.lastname@example.org> Signed-off-by: Andrew Morton <email@example.com> Signed-off-by: Linus Torvalds <firstname.lastname@example.org>
- Loading branch information...
Showing with 105 additions and 3 deletions.