From: Fernando Luis =?ISO-8859-1?Q?V=E1zquez?= Cao Subject: [PATCH 3/17] fsfreeze: fix emergency thaw infinite loop Date: Mon, 07 Jan 2013 20:23:54 +0900 Message-ID: <1357557834.8183.6.camel@nexus.lab.ntt.co.jp> References: <1357557492.8183.1.camel@nexus.lab.ntt.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: Josef Bacik , Eric Sandeen , Dave Chinner , Christoph Hellwig , Jan Kara , Luiz Capitulino , linux-fsdevel@vger.kernel.org To: Al Viro Return-path: Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]:54390 "EHLO tama500.ecl.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754129Ab3AGLYu (ORCPT ); Mon, 7 Jan 2013 06:24:50 -0500 In-Reply-To: <1357557492.8183.1.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: linux-fsdevel@vger.kernel.org Cc: Josef Bacik Cc: Christoph Hellwig Cc: Luiz Capitulino Reviewed-by: Jan Kara Reviewed-by: Eric Sandeen Signed-off-by: Dave Chinner Signed-off-by: Fernando Luis Vazquez Cao --- diff -urNp linux-3.8-rc1-orig/fs/block_dev.c linux-3.8-rc1/fs/block_dev.c --- linux-3.8-rc1-orig/fs/block_dev.c 2012-12-25 10:27:41.110737000 +0900 +++ linux-3.8-rc1/fs/block_dev.c 2012-12-25 11:36:24.236018000 +0900 @@ -266,22 +266,17 @@ int thaw_bdev(struct block_device *bdev, if (!bdev->bd_fsfreeze_count) goto out; - error = 0; - if (--bdev->bd_fsfreeze_count > 0) - goto out; - - if (!sb) + if (--bdev->bd_fsfreeze_count > 0 || !sb) { + error = 0; 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);