[PATCH] swsusp: use block device offsets to identify swap locations

Make swsusp use block device offsets instead of swap offsets to identify swap
locations and make it use the same code paths for writing as well as for
reading data.

This allows us to use the same code for handling swap files and swap
partitions and to simplify the code, eg.  by dropping rw_swap_page_sync().

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Rafael J. Wysocki
2006-12-06 20:34:10 -08:00
committed by Linus Torvalds
parent 3fc6b34f48
commit 3aef83e0ef
7 changed files with 96 additions and 117 deletions

View File

@@ -147,48 +147,3 @@ int swap_readpage(struct file *file, struct page *page)
out:
return ret;
}
#ifdef CONFIG_SOFTWARE_SUSPEND
/*
* A scruffy utility function to read or write an arbitrary swap page
* and wait on the I/O. The caller must have a ref on the page.
*
* We use end_swap_bio_read() even for writes, because it happens to do what
* we want.
*/
int rw_swap_page_sync(int rw, swp_entry_t entry, struct page *page,
struct bio **bio_chain)
{
struct bio *bio;
int ret = 0;
int bio_rw;
lock_page(page);
bio = get_swap_bio(GFP_KERNEL, entry.val, page, end_swap_bio_read);
if (bio == NULL) {
unlock_page(page);
ret = -ENOMEM;
goto out;
}
bio_rw = rw;
if (!bio_chain)
bio_rw |= (1 << BIO_RW_SYNC);
if (bio_chain)
bio_get(bio);
submit_bio(bio_rw, bio);
if (bio_chain == NULL) {
wait_on_page_locked(page);
if (!PageUptodate(page) || PageError(page))
ret = -EIO;
}
if (bio_chain) {
bio->bi_private = *bio_chain;
*bio_chain = bio;
}
out:
return ret;
}
#endif