diff options
author | Hugh Dickins <hugh@veritas.com> | 2009-01-06 17:39:53 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-06 18:59:05 -0500 |
commit | 7992fde72ce06c73280a1939b7a1e903bc95ef85 (patch) | |
tree | 8e8ef30ec4e29b325f70c2d01d2a9def192b5c64 /include/linux/swap.h | |
parent | 6a6ba83175c029c7820765bae44692266b29e67a (diff) |
swapfile: swap allocation use discard
When scan_swap_map() finds a free cluster of swap pages to allocate,
discard the old contents of the cluster if the device supports discard.
But don't bother when swap is so fragmented that we allocate single pages.
Be careful about racing allocations made while we're scanning for a
cluster; and hold up allocations made while we're discarding.
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Joern Engel <joern@logfs.org>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Donjun Shin <djshin90@gmail.com>
Cc: Tejun Heo <teheo@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/swap.h')
-rw-r--r-- | include/linux/swap.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h index 0b9210ea96c7..fe79f44c858e 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h | |||
@@ -121,6 +121,7 @@ enum { | |||
121 | SWP_USED = (1 << 0), /* is slot in swap_info[] used? */ | 121 | SWP_USED = (1 << 0), /* is slot in swap_info[] used? */ |
122 | SWP_WRITEOK = (1 << 1), /* ok to write to this swap? */ | 122 | SWP_WRITEOK = (1 << 1), /* ok to write to this swap? */ |
123 | SWP_DISCARDABLE = (1 << 2), /* blkdev supports discard */ | 123 | SWP_DISCARDABLE = (1 << 2), /* blkdev supports discard */ |
124 | SWP_DISCARDING = (1 << 3), /* now discarding a free cluster */ | ||
124 | /* add others here before... */ | 125 | /* add others here before... */ |
125 | SWP_SCANNING = (1 << 8), /* refcount in scan_swap_map */ | 126 | SWP_SCANNING = (1 << 8), /* refcount in scan_swap_map */ |
126 | }; | 127 | }; |
@@ -144,6 +145,8 @@ struct swap_info_struct { | |||
144 | unsigned short *swap_map; | 145 | unsigned short *swap_map; |
145 | unsigned int lowest_bit; | 146 | unsigned int lowest_bit; |
146 | unsigned int highest_bit; | 147 | unsigned int highest_bit; |
148 | unsigned int lowest_alloc; /* while preparing discard cluster */ | ||
149 | unsigned int highest_alloc; /* while preparing discard cluster */ | ||
147 | unsigned int cluster_next; | 150 | unsigned int cluster_next; |
148 | unsigned int cluster_nr; | 151 | unsigned int cluster_nr; |
149 | unsigned int pages; | 152 | unsigned int pages; |