From: Fernando Luis =?ISO-8859-1?Q?V=E1zquez?= Cao Subject: [PATCH 1/7] fsfreeze: Prevent emergency thaw from looping infinitely Date: Tue, 10 Jul 2012 17:20:57 +0900 Message-ID: <1341908457.11559.9.camel@nexus.lab.ntt.co.jp> References: <1341908216.11559.6.camel@nexus.lab.ntt.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: Dave Chinner , Christoph Hellwig , linux-fsdevel@vger.kernel.org To: Al Viro Return-path: Received: from tama50.ecl.ntt.co.jp ([129.60.39.147]:59404 "EHLO tama50.ecl.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753210Ab2GJIVH (ORCPT ); Tue, 10 Jul 2012 04:21:07 -0400 In-Reply-To: <1341908216.11559.6.camel@nexus.lab.ntt.co.jp> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: The thawing of a filesystem through sysrq-j loops infinitely as it incorrectly detects a thawed filesytsem as frozen and tries to unfreeze repeatedly. This is a regression caused by 4504230a71566785a05d3e6b53fa1ee071b864eb ("freeze_bdev: grab active reference to frozen superblocks") in that it no longer returned -EINVAL for superblocks that were not frozen. Return -EINVAL when the filesystem is already unfrozen to avoid this problem. Cc: Christoph Hellwig Signed-off-by: Dave Chinner Signed-off-by: Fernando Luis Vazquez Cao --- diff -urNp linux-3.5-rc4-orig/fs/block_dev.c linux-3.5-rc4/fs/block_dev.c --- linux-3.5-rc4-orig/fs/block_dev.c 2012-06-27 12:00:47.694616000 +0900 +++ linux-3.5-rc4/fs/block_dev.c 2012-06-29 13:38:23.841352532 +0900 @@ -319,22 +319,20 @@ int thaw_bdev(struct block_device *bdev, if (!bdev->bd_fsfreeze_count) goto out; - error = 0; - if (--bdev->bd_fsfreeze_count > 0) + if (--bdev->bd_fsfreeze_count > 0) { + error = 0; goto out; + } if (!sb) goto out; error = thaw_super(sb); - if (error) { + if (error) bdev->bd_fsfreeze_count++; - mutex_unlock(&bdev->bd_fsfreeze_mutex); - return error; - } out: mutex_unlock(&bdev->bd_fsfreeze_mutex); - return 0; + return error; } EXPORT_SYMBOL(thaw_bdev);