From: Andrew Morton <akpm@osdl.org>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Dave Jones <davej@redhat.com>, Pavel Machek <pavel@ucw.cz>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -mm 3/6] swsusp: Use block device offsets to identify swap locations
Date: Tue, 26 Sep 2006 12:38:53 -0700 [thread overview]
Message-ID: <20060926123853.14682513.akpm@osdl.org> (raw)
In-Reply-To: <200609231204.25911.rjw@sisk.pl>
On Sat, 23 Sep 2006 12:04:25 +0200
"Rafael J. Wysocki" <rjw@sisk.pl> wrote:
> 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().
>
> ..
>
> +sector_t swapdev_block(int swap_type, pgoff_t offset)
swapdev_block() returns sector_t.
> -unsigned long alloc_swap_page(int swap, struct bitmap_page *bitmap)
> +loff_t alloc_swapdev_block(int swap, struct bitmap_page *bitmap)
> {
> unsigned long offset;
>
> offset = swp_offset(get_swap_page_of_type(swap));
> if (offset) {
> - if (bitmap_set(bitmap, offset)) {
> + if (bitmap_set(bitmap, offset))
> swap_free(swp_entry(swap, offset));
> - offset = 0;
> - }
> + else
> + return swapdev_block(swap, offset);
> }
> - return offset;
> + return 0;
> }
But alloc_swapdev_block() returns loff_t.
> void free_all_swap_pages(int swap, struct bitmap_page *bitmap)
> Index: linux-2.6.18-rc7-mm1/kernel/power/user.c
> ===================================================================
> --- linux-2.6.18-rc7-mm1.orig/kernel/power/user.c
> +++ linux-2.6.18-rc7-mm1/kernel/power/user.c
> @@ -239,7 +239,7 @@ static int snapshot_ioctl(struct inode *
> break;
> }
> }
> - offset = alloc_swap_page(data->swap, data->bitmap);
> + offset = alloc_swapdev_block(data->swap, data->bitmap);
`offset' is declared loff_t, yet it is holding a sector_t.
> ===================================================================
> --- linux-2.6.18-rc7-mm1.orig/kernel/power/swap.c
> +++ linux-2.6.18-rc7-mm1/kernel/power/swap.c
> @@ -34,8 +34,8 @@ extern char resume_file[];
> #define SWSUSP_SIG "S1SUSPEND"
>
> static struct swsusp_header {
> - char reserved[PAGE_SIZE - 20 - sizeof(swp_entry_t)];
> - swp_entry_t image;
> + char reserved[PAGE_SIZE - 20 - sizeof(loff_t)];
> + loff_t image;
More possible sector_t/loff_t confusion.
> static int swsusp_swap_check(void) /* This is called before saving image */
> {
> - int res = swap_type_of(swsusp_resume_device, 0);
> + int res;
>
> - if (res >= 0) {
> - root_swap = res;
> - return 0;
> - }
> - return res;
> + res = swap_type_of(swsusp_resume_device, 0);
> + if (res < 0)
> + return res;
> +
> + root_swap = res;
> + resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_WRITE);
> + if (IS_ERR(resume_bdev))
> + return PTR_ERR(resume_bdev);
> +
> + set_blocksize(resume_bdev, PAGE_SIZE);
> + return 0;
> }
set_blocksize() can fail.
> -#define MAP_PAGE_ENTRIES (PAGE_SIZE / sizeof(long) - 1)
> +#define MAP_PAGE_ENTRIES (PAGE_SIZE / sizeof(loff_t) - 1)
I think this is dealing with sector_t's?
next prev parent reply other threads:[~2006-09-26 19:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-23 9:57 [PATCH -mm] swsusp: Add support for swap files Rafael J. Wysocki
2006-09-23 10:01 ` [PATCH -mm 1/6] swsusp: Use partition device and offset to identify swap areas Rafael J. Wysocki
2006-09-23 10:02 ` [PATCH -mm 2/6] swsusp: Rearrange swap-handling code Rafael J. Wysocki
2006-09-23 10:04 ` [PATCH -mm 3/6] swsusp: Use block device offsets to identify swap locations Rafael J. Wysocki
2006-09-26 19:38 ` Andrew Morton [this message]
2006-09-26 20:04 ` Rafael J. Wysocki
2006-09-26 21:51 ` Rafael J. Wysocki
2006-09-23 10:08 ` [PATCH -mm 4/6] swsusp: Add resume_offset command line parameter Rafael J. Wysocki
2006-09-26 19:38 ` Andrew Morton
2006-09-26 20:10 ` Rafael J. Wysocki
2006-09-23 10:10 ` [PATCH -mm 5/6] mm: Print first block offset for swap areas Rafael J. Wysocki
2006-09-26 19:39 ` Andrew Morton
2006-09-26 20:13 ` Rafael J. Wysocki
2006-09-26 20:49 ` Andrew Morton
2006-09-26 21:04 ` Rafael J. Wysocki
2006-09-23 10:13 ` [PATCH -mm 6/6] swsusp: Document support for swap files Rafael J. Wysocki
2006-09-26 21:56 ` Rafael J. Wysocki
2006-09-23 10:17 ` [PATCH -mm] swsusp: Add " Pavel Machek
2006-09-23 20:30 ` Rafael J. Wysocki
-- strict thread matches above, loose matches on Subject: below --
2006-09-20 19:20 [PATCH -mm 0/6] " Rafael J. Wysocki
2006-09-20 19:41 ` [PATCH -mm 3/6] swsusp: Use block device offsets to identify swap locations Rafael J. Wysocki
2006-09-21 21:30 ` Pavel Machek
2006-09-21 22:21 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060926123853.14682513.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=davej@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rjw@sisk.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®