/* * linux/kernel/power/swap.c * * This file provides functions for reading the suspend image from * and writing it to a swap partition. * * Copyright (C) 1998,2001-2005 Pavel Machek <pavel@ucw.cz> * Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl> * Copyright (C) 2010 Bojan Smojver <bojan@rexursive.com> * * This file is released under the GPLv2. * */#include<linux/module.h>#include<linux/file.h>#include<linux/delay.h>#include<linux/bitops.h>#include<linux/genhd.h>#include<linux/device.h>#include<linux/bio.h>#include<linux/blkdev.h>#include<linux/swap.h>#include<linux/swapops.h>#include<linux/pm.h>#include<linux/slab.h>#include<linux/lzo.h>#include<linux/vmalloc.h>#include<linux/cpumask.h>#include<linux/atomic.h>#include<linux/kthread.h>#include<linux/crc32.h>#include"power.h"#define HIBERNATE_SIG "S1SUSPEND"/* * The swap map is a data structure used for keeping track of each page * written to a swap partition. It consists of many swap_map_page * structures that contain each an array of MAP_PAGE_ENTRIES swap entries. * These structures are stored on the swap and linked together with the * help of the .next_swap member. * * The swap map is created during suspend. The swap map pages are * allocated and populated one at a time, so we only need one memory * page to set up the entire structure. * * During resume we pick up all swap_map_page structures into a list. */#define MAP_PAGE_ENTRIES (PAGE_SIZE / sizeof(sector_t) - 1)structswap_map_page{sector_tentries[MAP_PAGE_ENTRIES];sector_tnext_swap;};structswap_map_page_list{structswap_map_page*map;structswap_map_page_list*next;};/** * The swap_map_handle structure is used for handling swap in * a file-alike way */structswap_map_handle{structswap_map_page*cur;structswap_map_page_list*maps;sector_tcur_swap;sector_tfirst_sector;unsignedintk;unsignedlongnr_free_pages,written;u32crc32;};structswsusp_header{char