diff options
author | Hugh Dickins <hugh@veritas.com> | 2009-01-06 17:39:51 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-06 18:59:05 -0500 |
commit | 6a6ba83175c029c7820765bae44692266b29e67a (patch) | |
tree | 30bfb4938c73b715eb90dd15c09777fe0bbf93e6 /include | |
parent | ebebbbe904634b0ca1c674457b399f68db5e05b1 (diff) |
swapfile: swapon use discard (trim)
When adding swap, all the old data on swap can be forgotten: sys_swapon()
discard all but the header page of the swap partition (or every extent but
the header of the swap file), to give a solidstate swap device the
opportunity to optimize its wear-levelling.
If that succeeds, note SWP_DISCARDABLE for later use, and report it with a
"D" at the right end of the kernel's "Adding ... swap" message. Perhaps
something should be shown in /proc/swaps (swapon -s), but we have to be
more cautious before making any addition to that format.
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')
-rw-r--r-- | include/linux/swap.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h index 9cabb8b21aba..0b9210ea96c7 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h | |||
@@ -120,6 +120,7 @@ struct swap_extent { | |||
120 | enum { | 120 | 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 | /* add others here before... */ | 124 | /* add others here before... */ |
124 | SWP_SCANNING = (1 << 8), /* refcount in scan_swap_map */ | 125 | SWP_SCANNING = (1 << 8), /* refcount in scan_swap_map */ |
125 | }; | 126 | }; |