• Hugh Dickins's avatar
    swapfile: swapon use discard (trim) · 6a6ba831
    Hugh Dickins authored
    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: default avatarHugh 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: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    6a6ba831
swapfile.c 45.9 KB