linux/Documentation
Mel Gorman 62c230bc17 mm: add support for a filesystem to activate swap files and use direct_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.

[a.p.zijlstra@chello.nl: Original patch]
Signed-off-by: Mel Gorman <mgorman@suse.de>
Acked-by: Rik van Riel <riel@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Eric B Munson <emunson@mgebm.net>
Cc: Eric Paris <eparis@redhat.com>
Cc: James Morris <jmorris@namei.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Mike Christie <michaelc@cs.wisc.edu>
Cc: Neil Brown <neilb@suse.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Xiaotian Feng <dfeng@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-07-31 18:42:47 -07:00
..
ABI mm: prepare for removal of obsolete /proc/sys/vm/nr_pdflush_threads 2012-07-31 18:42:40 -07:00
DocBook Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 2012-07-30 19:03:41 -07:00
EDID
PCI
RCU rcu: Update documentation to cover call_srcu() and srcu_barrier(). 2012-07-02 12:34:03 -07:00
accounting
acpi
aoe
arm Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2012-07-24 13:34:56 -07:00
auxdisplay
backlight
blackfin
block
blockdev
cdrom
cgroups mm/memcg: complete documentation for tcp memcg files 2012-07-31 18:42:43 -07:00
connector connector: Move cn_test.c away from NLMSG_PUT(). 2012-06-26 21:19:02 -07:00
console
cpu-freq
cpuidle
cris
crypto
development-process
device-mapper dm thin: add read only and fail io modes 2012-07-27 15:08:16 +01:00
devicetree MFD bits for the 3.6 merge window. 2012-07-30 12:41:17 -07:00
driver-model
dvb Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 2012-07-30 19:03:41 -07:00
early-userspace
extcon
fault-injection fault-injection: add tool to run command with failslab or fail_page_alloc 2012-07-30 17:25:22 -07:00
fb
filesystems mm: add support for a filesystem to activate swap files and use direct_IO for writing swap pages 2012-07-31 18:42:47 -07:00
firmware_class
frv
hid HID: uhid: add documentation 2012-06-18 13:42:03 +02:00
hwmon hwmon: Honeywell Humidicon HIH-6130/HIH-6131 humidity and temperature sensor driver 2012-07-21 21:48:44 -07:00
i2c i2c-i801: Enable IRQ for SMBus transactions 2012-07-24 14:13:58 +02:00
i2o
ia64
ide
infiniband
input Input: add driver for FT5x06 based EDT displays 2012-07-24 23:55:03 -07:00
ioctl
isdn
ja_JP
kbuild
kdump kexec: update URL of kexec homepage 2012-07-18 18:35:57 -07:00
ko_KR
laptops Documentation: asus-laptop.txt references an obsolete Kconfig item 2012-06-28 12:04:16 +02:00
leds LEDS: add BlinkM RGB LED driver, documentation and update MAINTAINERS 2012-07-24 16:00:51 +08:00
m68k
make
memory-devices
mips
misc-devices
mmc
mn10300
mtd
namespaces
netlabel
networking net-next: minor cleanups for bonding documentation 2012-07-22 12:44:01 -07:00
nfc NFC: Error management documentation 2012-07-09 16:42:11 -04:00
parisc
pcmcia
power Merge branch 'pm-doc' 2012-07-19 00:03:46 +02:00
powerpc
pps
prctl security: Minor improvements to no_new_privs documentation 2012-07-08 00:25:48 +10:00
pti
ptp
rapidio
s390
scheduler
scsi
security
serial
sh
sound Sound update for 3.6-rc1 2012-07-24 13:37:37 -07:00
spi
sysctl mm, oom: replace some information in tasklist dump 2012-07-31 18:42:42 -07:00
target
telephony
thermal Thermal: Documentation update 2012-07-24 23:20:40 -04:00
timers
trace
usb
vDSO
video4linux Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 2012-07-30 19:03:41 -07:00
virtual KVM updates for the 3.6 merge window 2012-07-24 12:01:20 -07:00
vm mm/frontswap: cleanup doc and comment error 2012-07-23 11:16:20 -04:00
w1
watchdog
wimax
x86 Merge branch 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-07-26 13:13:25 -07:00
zh_CN
.gitignore
00-INDEX
BUG-HUNTING
Changes
CodingStyle
DMA-API-HOWTO.txt
DMA-API.txt
DMA-ISA-LPC.txt
DMA-attributes.txt common: DMA-mapping: add DMA_ATTR_SKIP_CPU_SYNC attribute 2012-07-30 12:25:47 +02:00
HOWTO
IPMI.txt
IRQ-affinity.txt
IRQ-domain.txt
IRQ.txt
Intel-IOMMU.txt
Makefile
ManagementStyle Documentation: ManagementStyle: fixed typo 2012-06-28 12:03:15 +02:00
SAK.txt
SM501.txt
SecurityBugs
SubmitChecklist
SubmittingDrivers
SubmittingPatches
VGA-softcursor.txt
applying-patches.txt
atomic_ops.txt
bad_memory.txt
basic_profiling.txt
binfmt_misc.txt
braille-console.txt
bt8xxgpio.txt
btmrvl.txt
bus-virt-phys-mapping.txt
cachetlb.txt
circular-buffers.txt
clk.txt
coccinelle.txt
cpu-hotplug.txt
cpu-load.txt
cputopology.txt
crc32.txt
dcdbas.txt
debugging-modules.txt
debugging-via-ohci1394.txt
dell_rbu.txt
devices.txt
digsig.txt
dma-buf-sharing.txt
dmaengine.txt
dontdiff kconfig: remove lkc_defs.h from .gitignore and dontdiff 2012-07-13 15:08:25 +02:00
dynamic-debug-howto.txt
edac.txt Merge branch 'devel' 2012-07-29 21:11:05 -03:00
eisa.txt
email-clients.txt
feature-removal-schedule.txt mm: prepare for removal of obsolete /proc/sys/vm/nr_pdflush_threads 2012-07-31 18:42:40 -07:00
flexible-arrays.txt
futex-requeue-pi.txt
gcov.txt
gpio.txt
highuid.txt
hw_random.txt
hwspinlock.txt
init.txt
initrd.txt
intel_txt.txt
io-mapping.txt
io_ordering.txt
iostats.txt
irqflags-tracing.txt
isapnp.txt
java.txt
kernel-doc-nano-HOWTO.txt
kernel-docs.txt
kernel-parameters.txt Merge branch 'for-linus-for-3.6-rc1' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping 2012-07-30 10:11:31 -07:00
kmemcheck.txt
kmemleak.txt
kobject.txt
kprobes.txt
kref.txt
ldm.txt
local_ops.txt
lockdep-design.txt
lockstat.txt
lockup-watchdogs.txt
logo.gif
logo.txt
magic-number.txt
md.txt
media-framework.txt
memory-barriers.txt
memory-hotplug.txt
memory.txt
mono.txt
mutex-design.txt
nommu-mmap.txt
numastat.txt
oops-tracing.txt
padata.txt
parport-lowlevel.txt
parport.txt
pi-futex.txt
pinctrl.txt
pnp.txt
preempt-locking.txt
printk-formats.txt vsprintf: add support of '%*ph[CDN]' 2012-07-30 17:25:14 -07:00
prio_tree.txt
pwm.txt
ramoops.txt pstore/ram: Add ftrace messages handling 2012-07-17 10:14:17 -07:00
rbtree.txt
remoteproc.txt remoteproc: adopt the driver core's alloc/add/del/put naming 2012-07-06 00:53:27 +03:00
rfkill.txt
robust-futex-ABI.txt
robust-futexes.txt
rpmsg.txt
rt-mutex-design.txt
rt-mutex.txt
rtc.txt
serial-console.txt
sgi-ioc4.txt
sgi-visws.txt
sparse.txt
spinlocks.txt
stable_api_nonsense.txt
stable_kernel_rules.txt stable: Allow merging of backports for serious user-visible performance issues 2012-06-25 12:11:58 -07:00
static-keys.txt
svga.txt
sysfs-rules.txt
sysrq.txt
unaligned-memory-access.txt
unicode.txt
unshare.txt
vgaarbiter.txt
video-output.txt
vme_api.txt
volatile-considered-harmful.txt
workqueue.txt workqueue: reimplement WQ_HIGHPRI using a separate worker_pool 2012-07-13 22:24:45 -07:00
xz.txt
zorro.txt