From patchwork Mon Jul 20 17:01:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Nesterov X-Patchwork-Id: 6829421 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 39CCCC05AC for ; Mon, 20 Jul 2015 17:03:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6C6EC20532 for ; Mon, 20 Jul 2015 17:03:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B66920454 for ; Mon, 20 Jul 2015 17:03:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756639AbbGTRDA (ORCPT ); Mon, 20 Jul 2015 13:03:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56197 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756581AbbGTRC6 (ORCPT ); Mon, 20 Jul 2015 13:02:58 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 53F64347A62; Mon, 20 Jul 2015 17:02:58 +0000 (UTC) Received: from tranklukator.brq.redhat.com (dhcp-1-208.brq.redhat.com [10.34.1.208]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t6KH2u0G013625; Mon, 20 Jul 2015 13:02:56 -0400 Received: by tranklukator.brq.redhat.com (nbSMTP-1.00) for uid 500 oleg@redhat.com; Mon, 20 Jul 2015 19:01:11 +0200 (CEST) Date: Mon, 20 Jul 2015 19:01:09 +0200 From: Oleg Nesterov To: Al Viro , Dave Chinner , Dave Hansen , Jan Kara Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] change thaw_super() to re-acquire s_writers.lock_map Message-ID: <20150720170109.GA3909@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150720170044.GA3868@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change thaw_super() to re-acquire the "write" locks we are going to release. This way s_op->unfreeze_fs(sb) is called with these locks held as it seen by lockdep, and this matches the reality. This adds another trivial helper, sb_freeze_acquire(). Signed-off-by: Oleg Nesterov Reviewed-by: Jan Kara --- fs/super.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/fs/super.c b/fs/super.c index e7ea9f1..b4db3ee 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1263,6 +1263,14 @@ static void sb_freeze_release(struct super_block *sb) rwsem_release(sb->s_writers.lock_map + level, 1, _THIS_IP_); } +static void sb_freeze_acquire(struct super_block *sb) +{ + int level; + + for (level = 0; level < SB_FREEZE_LEVELS; ++level) + rwsem_acquire(sb->s_writers.lock_map + level, 0, 1, _THIS_IP_); +} + /** * freeze_super - lock the filesystem and force it into a consistent state * @sb: the super to lock @@ -1386,16 +1394,20 @@ int thaw_super(struct super_block *sb) if (sb->s_flags & MS_RDONLY) goto out; + sb_freeze_acquire(sb); + if (sb->s_op->unfreeze_fs) { error = sb->s_op->unfreeze_fs(sb); if (error) { printk(KERN_ERR "VFS:Filesystem thaw failed\n"); + sb_freeze_release(sb); up_write(&sb->s_umount); return error; } } + sb_freeze_release(sb); out: sb->s_writers.frozen = SB_UNFROZEN; smp_wmb();