• Andrew Morton's avatar
    [PATCH] Disallow swapoff if there is insufficient memory · 464f4e78
    Andrew Morton authored
    From: Hugh Dickins <hugh@veritas.com>
    
    First of three small "stop swapoff" patches based on 2.5.67-mm3:
    
    stop swapoff 1/3 vm_enough_memory?
    
    Before embarking upon swapoff, check vm_enough_memory.  Mainly
    for consistency in the overcommit_memory 2 (strict accounting) case:
    fail with -ENOMEM if it wouldn't let the amount removed be committed.
    
    Will always succeed in the overcommit_memory 1 case, as it should in
    root-shoot-foot mode.  In the overcommit_memory 0 case, well, I don't
    care much either way, so opted for the simplest code: no special case.
    Which means it could now fail at the start; but that's unlikely (case 0
    is over-generous) and only when it would have got stuck later on anyway.
    464f4e78
swapfile.c 38.2 KB