From patchwork Wed Mar 2 19:01:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Sorenson X-Patchwork-Id: 8484771 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7E2EE9F372 for ; Wed, 2 Mar 2016 19:02:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AD3382037E for ; Wed, 2 Mar 2016 19:02:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8DA820351 for ; Wed, 2 Mar 2016 19:02:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932067AbcCBTCD (ORCPT ); Wed, 2 Mar 2016 14:02:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35529 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753401AbcCBTCC (ORCPT ); Wed, 2 Mar 2016 14:02:02 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id C88E98E3F2 for ; Wed, 2 Mar 2016 19:02:01 +0000 (UTC) Received: from fez.sorensonfamily.com (ovpn-116-27.rdu2.redhat.com [10.10.116.27]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u22J1xXX018926 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 2 Mar 2016 14:02:01 -0500 From: Frank Sorenson To: linux-fsdevel@vger.kernel.org Cc: dwysocha@redhat.com, lvaz@redhat.com Subject: [PATCH 1/5] fs: simplify freeze_super()/thaw_super() exit handling Date: Wed, 2 Mar 2016 13:01:55 -0600 Message-Id: <1456945319-16283-2-git-send-email-sorenson@redhat.com> In-Reply-To: <1456945319-16283-1-git-send-email-sorenson@redhat.com> References: <1456945319-16283-1-git-send-email-sorenson@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 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 freeze_super() and thaw_super() to have a common exit Signed-off-by: Frank Sorenson --- fs/super.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/fs/super.c b/fs/super.c index 1182af8..5e9a974 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1272,26 +1272,21 @@ static void sb_freeze_unlock(struct super_block *sb) */ int freeze_super(struct super_block *sb) { - int ret; + int ret = 0; atomic_inc(&sb->s_active); down_write(&sb->s_umount); if (sb->s_writers.frozen != SB_UNFROZEN) { deactivate_locked_super(sb); - return -EBUSY; + ret = -EBUSY; + goto out; } - if (!(sb->s_flags & MS_BORN)) { - up_write(&sb->s_umount); - return 0; /* sic - it's "nothing to do" */ - } + if (!(sb->s_flags & MS_BORN)) + goto out_unlock; /* nothing to do */ - if (sb->s_flags & MS_RDONLY) { - /* Nothing to do really... */ - sb->s_writers.frozen = SB_FREEZE_COMPLETE; - up_write(&sb->s_umount); - return 0; - } + if (sb->s_flags & MS_RDONLY) + goto out_complete; /* nothing to do */ sb->s_writers.frozen = SB_FREEZE_WRITE; /* Release s_umount to preserve sb_start_write -> s_umount ordering */ @@ -1319,16 +1314,19 @@ int freeze_super(struct super_block *sb) sb_freeze_unlock(sb); wake_up(&sb->s_writers.wait_unfrozen); deactivate_locked_super(sb); - return ret; + goto out; } } /* * This is just for debugging purposes so that fs can warn if it * sees write activity when frozen is set to SB_FREEZE_COMPLETE. */ +out_complete: sb->s_writers.frozen = SB_FREEZE_COMPLETE; +out_unlock: up_write(&sb->s_umount); - return 0; +out: + return ret; } EXPORT_SYMBOL(freeze_super); @@ -1340,34 +1338,36 @@ EXPORT_SYMBOL(freeze_super); */ int thaw_super(struct super_block *sb) { - int error; + int ret = 0; down_write(&sb->s_umount); if (sb->s_writers.frozen == SB_UNFROZEN) { up_write(&sb->s_umount); - return -EINVAL; + ret = -EINVAL; + goto out; } if (sb->s_flags & MS_RDONLY) { sb->s_writers.frozen = SB_UNFROZEN; - goto out; + goto out_wake; } if (sb->s_op->unfreeze_fs) { - error = sb->s_op->unfreeze_fs(sb); - if (error) { + ret = sb->s_op->unfreeze_fs(sb); + if (ret) { printk(KERN_ERR "VFS:Filesystem thaw failed\n"); up_write(&sb->s_umount); - return error; + goto out; } } sb->s_writers.frozen = SB_UNFROZEN; sb_freeze_unlock(sb); -out: +out_wake: wake_up(&sb->s_writers.wait_unfrozen); deactivate_locked_super(sb); - return 0; +out: + return ret; } EXPORT_SYMBOL(thaw_super);