From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Len Brown <lenb@kernel.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>,
pm list <linux-pm@lists.linux-foundation.org>,
Greg KH <gregkh@suse.de>, LKML <linux-kernel@vger.kernel.org>,
Arve@smtp1.linux-foundation.org,
Alan Jenkins <alan-jenkins@tuffmail.co.uk>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Andrew Morton <akpm@linux-foundation.org>,
Andrey Borzenkov <arvidjaar@mail.ru>,
Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>,
Masami Hiramatsu <mhiramat@redhat.com>
Subject: [PATCH 3/9] PM/hibernate: fix "swap breaks after hibernation failures"
Date: Sat, 14 Feb 2009 02:01:14 +0100 [thread overview]
Message-ID: <200902140201.16221.rjw@sisk.pl> (raw)
In-Reply-To: <200902140157.40869.rjw@sisk.pl>
From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
http://bugzilla.kernel.org/show_bug.cgi?id=12239
The image writing code dropped a reference to the current swap device.
This doesn't show up if the hibernation succeeds - because it doesn't
affect the image which gets resumed. But it means multiple _failed_
hibernations end up freeing the swap device while it is still use!
swsusp_write() finds the block device for the swap file using swap_type_of().
It then uses blkdev_get() / blkdev_put() to open and close the block device.
Unfortunately, blkdev_get() assumes ownership of the inode of the block_device
passed to it. So blkdev_put() calls iput() on the inode. This is by design
and other callers expect this behaviour. The fix is for swap_type_of() to take
a reference on the inode using bdget().
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
mm/swapfile.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: linux-2.6/mm/swapfile.c
===================================================================
--- linux-2.6.orig/mm/swapfile.c
+++ linux-2.6/mm/swapfile.c
@@ -635,7 +635,7 @@ int swap_type_of(dev_t device, sector_t
if (!bdev) {
if (bdev_p)
- *bdev_p = sis->bdev;
+ *bdev_p = bdget(sis->bdev->bd_dev);
spin_unlock(&swap_lock);
return i;
@@ -647,7 +647,7 @@ int swap_type_of(dev_t device, sector_t
struct swap_extent, list);
if (se->start_block == offset) {
if (bdev_p)
- *bdev_p = sis->bdev;
+ *bdev_p = bdget(sis->bdev->bd_dev);
spin_unlock(&swap_lock);
bdput(bdev);
WARNING: multiple messages have this Message-ID (diff)
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Len Brown <lenb@kernel.org>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
"Arve Hjønnevåg" <arve@android.com>, "Greg KH" <gregkh@suse.de>,
"Ingo Molnar" <mingo@elte.hu>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"KOSAKI Motohiro" <kosaki.motohiro@jp.fujitsu.com>,
LKML <linux-kernel@vger.kernel.org>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Pavel Machek" <pavel@ucw.cz>,
"pm list" <linux-pm@lists.linux-foundation.org>,
"Arjan van de Ven" <arjan@linux.intel.com>,
"Alan Jenkins" <alan-jenkins@tuffmail.co.uk>,
"Masami Hiramatsu" <mhiramat@redhat.com>,
"Andrey Borzenkov" <arvidjaar@mail.ru>
Subject: [PATCH 3/9] PM/hibernate: fix "swap breaks after hibernation failures"
Date: Sat, 14 Feb 2009 02:01:14 +0100 [thread overview]
Message-ID: <200902140201.16221.rjw@sisk.pl> (raw)
In-Reply-To: <200902140157.40869.rjw@sisk.pl>
From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
http://bugzilla.kernel.org/show_bug.cgi?id=12239
The image writing code dropped a reference to the current swap device.
This doesn't show up if the hibernation succeeds - because it doesn't
affect the image which gets resumed. But it means multiple _failed_
hibernations end up freeing the swap device while it is still use!
swsusp_write() finds the block device for the swap file using swap_type_of().
It then uses blkdev_get() / blkdev_put() to open and close the block device.
Unfortunately, blkdev_get() assumes ownership of the inode of the block_device
passed to it. So blkdev_put() calls iput() on the inode. This is by design
and other callers expect this behaviour. The fix is for swap_type_of() to take
a reference on the inode using bdget().
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
mm/swapfile.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: linux-2.6/mm/swapfile.c
===================================================================
--- linux-2.6.orig/mm/swapfile.c
+++ linux-2.6/mm/swapfile.c
@@ -635,7 +635,7 @@ int swap_type_of(dev_t device, sector_t
if (!bdev) {
if (bdev_p)
- *bdev_p = sis->bdev;
+ *bdev_p = bdget(sis->bdev->bd_dev);
spin_unlock(&swap_lock);
return i;
@@ -647,7 +647,7 @@ int swap_type_of(dev_t device, sector_t
struct swap_extent, list);
if (se->start_block == offset) {
if (bdev_p)
- *bdev_p = sis->bdev;
+ *bdev_p = bdget(sis->bdev->bd_dev);
spin_unlock(&swap_lock);
bdput(bdev);
next prev parent reply other threads:[~2009-02-14 1:01 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-14 0:57 [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Rafael J. Wysocki
2009-02-14 0:57 ` Rafael J. Wysocki
2009-02-14 0:59 ` [PATCH 1/9] Consolidate driver_probe_done() loops into one place Rafael J. Wysocki
2009-02-14 0:59 ` Rafael J. Wysocki
2009-02-14 1:47 ` Greg KH
2009-02-14 1:47 ` Greg KH
2009-02-22 5:29 ` Raja R Harinath
2009-02-14 1:00 ` [PATCH 2/9] PM/resume: wait for device probing to finish Rafael J. Wysocki
2009-02-14 1:00 ` Rafael J. Wysocki
2009-02-14 1:48 ` Greg KH
2009-02-14 1:48 ` Greg KH
2009-02-14 1:01 ` Rafael J. Wysocki [this message]
2009-02-14 1:01 ` [PATCH 3/9] PM/hibernate: fix "swap breaks after hibernation failures" Rafael J. Wysocki
2009-02-14 1:02 ` [PATCH 4/9] PM: fix build for CONFIG_PM unset Rafael J. Wysocki
2009-02-14 1:02 ` Rafael J. Wysocki
2009-02-14 1:03 ` [PATCH 5/9] swsusp: dont fiddle with swappiness Rafael J. Wysocki
2009-02-14 1:03 ` Rafael J. Wysocki
2009-02-14 1:04 ` [PATCH 6/9] swsusp: clean up shrink_all_zones() Rafael J. Wysocki
2009-02-14 1:04 ` Rafael J. Wysocki
2009-02-14 1:05 ` [PATCH 7/9] PM: Fix pm_notifiers during user mode hibernation Rafael J. Wysocki
2009-02-14 1:05 ` Rafael J. Wysocki
2009-02-14 1:06 ` [PATCH 8/9] PM: Wait for console in resume Rafael J. Wysocki
2009-02-14 1:06 ` Rafael J. Wysocki
2009-02-14 1:07 ` [PATCH 9/9] PM: Fix suspend_console and resume_console to use only one semaphore Rafael J. Wysocki
2009-02-14 1:07 ` Rafael J. Wysocki
2009-02-21 4:41 ` [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Len Brown
2009-02-21 9:38 ` Rafael J. Wysocki
2009-02-21 18:29 ` Greg KH
2009-02-21 19:32 ` Arjan van de Ven
2009-02-21 19:48 ` Greg KH
2009-02-21 19:48 ` Greg KH
2009-02-21 22:18 ` Linus Torvalds
2009-02-21 22:18 ` Linus Torvalds
2009-02-22 2:47 ` Len Brown
2009-02-22 2:47 ` Len Brown
2009-02-22 10:07 ` Rafael J. Wysocki
2009-02-22 10:07 ` Rafael J. Wysocki
2009-02-21 19:32 ` Arjan van de Ven
2009-02-21 18:29 ` Greg KH
2009-02-21 9:38 ` Rafael J. Wysocki
2009-02-21 4:41 ` Len Brown
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=200902140201.16221.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=Arve@smtp1.linux-foundation.org \
--cc=akpm@linux-foundation.org \
--cc=alan-jenkins@tuffmail.co.uk \
--cc=arjan@linux.intel.com \
--cc=arvidjaar@mail.ru \
--cc=gregkh@suse.de \
--cc=hannes@cmpxchg.org \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=mhiramat@redhat.com \
--cc=mingo@elte.hu \
--cc=torvalds@linux-foundation.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.