From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1764645AbZBNBUo (ORCPT ); Fri, 13 Feb 2009 20:20:44 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1762923AbZBNBIo (ORCPT ); Fri, 13 Feb 2009 20:08:44 -0500 Received: from ogre.sisk.pl ([217.79.144.158]:40902 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762907AbZBNBIl (ORCPT ); Fri, 13 Feb 2009 20:08:41 -0500 From: "Rafael J. Wysocki" To: Len Brown Subject: [PATCH 3/9] PM/hibernate: fix "swap breaks after hibernation failures" Date: Sat, 14 Feb 2009 02:01:14 +0100 User-Agent: KMail/1.11.0 (Linux/2.6.29-rc5-tst; KDE/4.2.0; x86_64; ; ) Cc: Andrew Morton , Arve =?iso-8859-1?q?Hj=F8nnev=E5g?= , Greg KH , Ingo Molnar , Johannes Weiner , KOSAKI Motohiro , LKML , Linus Torvalds , Pavel Machek , pm list , Arjan van de Ven , Alan Jenkins , Masami Hiramatsu , Andrey Borzenkov References: <200902140157.40869.rjw@sisk.pl> In-Reply-To: <200902140157.40869.rjw@sisk.pl> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200902140201.16221.rjw@sisk.pl> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alan Jenkins 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 Signed-off-by: Rafael J. Wysocki --- 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);