62c230bc17
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> |
||
---|---|---|
.. | ||
ABI | ||
DocBook | ||
EDID | ||
PCI | ||
RCU | ||
accounting | ||
acpi | ||
aoe | ||
arm | ||
auxdisplay | ||
backlight | ||
blackfin | ||
block | ||
blockdev | ||
cdrom | ||
cgroups | ||
connector | ||
console | ||
cpu-freq | ||
cpuidle | ||
cris | ||
crypto | ||
development-process | ||
device-mapper | ||
devicetree | ||
driver-model | ||
dvb | ||
early-userspace | ||
extcon | ||
fault-injection | ||
fb | ||
filesystems | ||
firmware_class | ||
frv | ||
hid | ||
hwmon | ||
i2c | ||
i2o | ||
ia64 | ||
ide | ||
infiniband | ||
input | ||
ioctl | ||
isdn | ||
ja_JP | ||
kbuild | ||
kdump | ||
ko_KR | ||
laptops | ||
leds | ||
m68k | ||
make | ||
memory-devices | ||
mips | ||
misc-devices | ||
mmc | ||
mn10300 | ||
mtd | ||
namespaces | ||
netlabel | ||
networking | ||
nfc | ||
parisc | ||
pcmcia | ||
power | ||
powerpc | ||
pps | ||
prctl | ||
pti | ||
ptp | ||
rapidio | ||
s390 | ||
scheduler | ||
scsi | ||
security | ||
serial | ||
sh | ||
sound | ||
spi | ||
sysctl | ||
target | ||
telephony | ||
thermal | ||
timers | ||
trace | ||
usb | ||
vDSO | ||
video4linux | ||
virtual | ||
vm | ||
w1 | ||
watchdog | ||
wimax | ||
x86 | ||
zh_CN | ||
.gitignore | ||
00-INDEX | ||
BUG-HUNTING | ||
Changes | ||
CodingStyle | ||
DMA-API-HOWTO.txt | ||
DMA-API.txt | ||
DMA-ISA-LPC.txt | ||
DMA-attributes.txt | ||
HOWTO | ||
IPMI.txt | ||
IRQ-affinity.txt | ||
IRQ-domain.txt | ||
IRQ.txt | ||
Intel-IOMMU.txt | ||
Makefile | ||
ManagementStyle | ||
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 | ||
dynamic-debug-howto.txt | ||
edac.txt | ||
eisa.txt | ||
email-clients.txt | ||
feature-removal-schedule.txt | ||
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 | ||
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 | ||
prio_tree.txt | ||
pwm.txt | ||
ramoops.txt | ||
rbtree.txt | ||
remoteproc.txt | ||
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 | ||
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 | ||
xz.txt | ||
zorro.txt |