mm: fix corruption of hibernation caused by reusing swap during image saving
[sfrench/cifs-2.6.git] / mm / swapfile.c
index 03aa2d55f1a2f54fc5eb17b099806edbc83a4049..f08d165871b38cd658ffc366cdf3b39290b829da 100644 (file)
@@ -318,8 +318,10 @@ checks:
        if (offset > si->highest_bit)
                scan_base = offset = si->lowest_bit;
 
-       /* reuse swap entry of cache-only swap if not busy. */
-       if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) {
+       /* reuse swap entry of cache-only swap if not hibernation. */
+       if (vm_swap_full()
+               && usage == SWAP_HAS_CACHE
+               && si->swap_map[offset] == SWAP_HAS_CACHE) {
                int swap_was_freed;
                spin_unlock(&swap_lock);
                swap_was_freed = __try_to_reclaim_swap(si, offset);