From: Fernando Luis =?ISO-8859-1?Q?V=E1zquez?= Cao Subject: [PATCH 8/17] fsfreeze: allow bdev level thaws when the sb is unfrozen Date: Mon, 07 Jan 2013 20:32:13 +0900 Message-ID: <1357558333.8183.13.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 tama50.ecl.ntt.co.jp ([129.60.39.147]:47043 "EHLO tama50.ecl.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753680Ab3AGLdJ (ORCPT ); Mon, 7 Jan 2013 06:33:09 -0500 In-Reply-To: <1357557492.8183.1.camel@nexus.lab.ntt.co.jp> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: This behavior is important in a scenario where a filesystem frozen using freeze_bdev() is thawed through the superblock level API; if we caused subsequent calls to thaw_bdev() future calls to freeze_bdev() would fail to freeze the superblock. We can get rid of this code away once bdev level fsfreeze and sb level fsfreeze are properly integrated. Cc: linux-fsdevel@vger.kernel.org Cc: Josef Bacik Cc: Eric Sandeen Cc: Christoph Hellwig Cc: Jan Kara Cc: Dave Chinner Cc: Luiz Capitulino 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 11:52:04.344018000 +0900 +++ linux-3.8-rc1/fs/block_dev.c 2012-12-25 16:11:12.648018000 +0900 @@ -272,8 +272,19 @@ int thaw_bdev(struct block_device *bdev, } error = thaw_super(sb); - if (error) + /* + * If the superblock is already unfrozen, i.e. thaw_super() returned + * -EINVAL, we consider the block device level thaw successful. This + * behavior is important in a scenario where a filesystem frozen using + * freeze_bdev() is thawed through the superblock level API; if we + * caused the subsequent thaw_bdev() to fail bdev->bd_fsfreeze_count + * would not go back to 0 which means that future calls to freeze_bdev() + * would not freeze the superblock, just increase the counter. + */ + if (error && error != -EINVAL) bdev->bd_fsfreeze_count++; + else + error = 0; out: mutex_unlock(&bdev->bd_fsfreeze_mutex); return error;