Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3795419pxb; Mon, 21 Feb 2022 06:00:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxLGC66n4pJrH9bF9cEp7bQ83qFxAuXmImq4lV+3t+xP4oKVmqSUTvAAMQfI8xi7AyzoOXW X-Received: by 2002:a17:90a:ead6:b0:1bc:66f2:1746 with SMTP id ev22-20020a17090aead600b001bc66f21746mr66851pjb.44.1645452027750; Mon, 21 Feb 2022 06:00:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645452027; cv=none; d=google.com; s=arc-20160816; b=Z87rArI6xmAhcgoNceavF4I8o37s0yJ2b9U7hibl03XkJWMSDgeyeJHWc1IxfAxvrB QT5VllukYBO3jArWRMImq66GEfpoXoNmAxac1OiY1Dmva9zryuCVEEYS57R5/9RpmnTH +wDKKf2U9t+2AWIkKdh/JBwc2LqsId3E4LKHWnmzzoC1OmplF5BjoRItfPqVJj/xKZZC AUVtnQohp/mAK7J+YzAVp0eWipcmcI17ePZjmUZFyQQVY1kOO6ka7rJn4u6MJfaaJT60 X7AK+kub8W4Qwx9iGbncRx/fG3FquGxojPGPd6OFi7MViIr8SceR5MuJSJtOGHkJXzuj 6+6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vORA3RvfNYMFsUcVW0JjhiDgcJW48zclTjQOfiqJ3WQ=; b=hCJYGmq0dODXpWOQK0LubhW6QfGUnbQPQRUp+tm9AGWGSCdp0t2obhYaTEiMCOnu/t UsRdXr3V4JRUu8kPawVVBRtzTAxJl4liulXsbEwcYOUrsBAvQgiUosBzMiX1E4qscXIL vt/YiYPF7UKwXZ/bXlAnEYHgYx7fXAbAVyYFLFLKvp3vCwP+OfMAgKvyMh6puipJA5ov 0kicWS9rdgqeudA/TBhSqZ0cZP5Olk3qTOPGWu9VmzmYcawmE6Nr8runMJoqxDssD7Gp SKE0rnJrhVwRJpO7Q0GhQBnLcAkOEKpsKvk1bhlIAYLVq4Jcs1V9AzMXEzkdKZ+vLWsg QgRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zm091h0C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m130si18467810pga.644.2022.02.21.06.00.12; Mon, 21 Feb 2022 06:00:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zm091h0C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348061AbiBUJKr (ORCPT + 99 others); Mon, 21 Feb 2022 04:10:47 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:43678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347707AbiBUJGB (ORCPT ); Mon, 21 Feb 2022 04:06:01 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 792E126128; Mon, 21 Feb 2022 00:59:35 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2BF09B80EAC; Mon, 21 Feb 2022 08:59:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BA92C340E9; Mon, 21 Feb 2022 08:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645433972; bh=bNuYXFbCZ5mrCCRAjSQ6gMyKhbK+/OC4G2sR7LxHKw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zm091h0C30A+Q6nEt9MmXGpzpwmQwb8KQbH3VuqhPnBwhjSc9WZnqkED+KDN+m2MZ Hsg3z99OKxcyfc47y6BA6Zjpo+stXIrVPOc5OLyepxiA2KmK46liaKRsaSAb883KpL zdsLy2X0YUL7vfZktNpoOQvSMd+ZrSmS400EYtkM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Darrick J. Wong" , Jan Kara , Christoph Hellwig , Christian Brauner , Sasha Levin Subject: [PATCH 5.4 16/80] vfs: make freeze_super abort when sync_filesystem returns error Date: Mon, 21 Feb 2022 09:48:56 +0100 Message-Id: <20220221084916.116545193@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221084915.554151737@linuxfoundation.org> References: <20220221084915.554151737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Darrick J. Wong [ Upstream commit 2719c7160dcfaae1f73a1c0c210ad3281c19022e ] If we fail to synchronize the filesystem while preparing to freeze the fs, abort the freeze. Signed-off-by: Darrick J. Wong Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig Acked-by: Christian Brauner Signed-off-by: Sasha Levin --- fs/super.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/super.c b/fs/super.c index b289356f302fc..e255c18fa2c88 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1691,11 +1691,9 @@ static void lockdep_sb_freeze_acquire(struct super_block *sb) percpu_rwsem_acquire(sb->s_writers.rw_sem + level, 0, _THIS_IP_); } -static void sb_freeze_unlock(struct super_block *sb) +static void sb_freeze_unlock(struct super_block *sb, int level) { - int level; - - for (level = SB_FREEZE_LEVELS - 1; level >= 0; level--) + for (level--; level >= 0; level--) percpu_up_write(sb->s_writers.rw_sem + level); } @@ -1766,7 +1764,14 @@ int freeze_super(struct super_block *sb) sb_wait_write(sb, SB_FREEZE_PAGEFAULT); /* All writers are done so after syncing there won't be dirty data */ - sync_filesystem(sb); + ret = sync_filesystem(sb); + if (ret) { + sb->s_writers.frozen = SB_UNFROZEN; + sb_freeze_unlock(sb, SB_FREEZE_PAGEFAULT); + wake_up(&sb->s_writers.wait_unfrozen); + deactivate_locked_super(sb); + return ret; + } /* Now wait for internal filesystem counter */ sb->s_writers.frozen = SB_FREEZE_FS; @@ -1778,7 +1783,7 @@ int freeze_super(struct super_block *sb) printk(KERN_ERR "VFS:Filesystem freeze failed\n"); sb->s_writers.frozen = SB_UNFROZEN; - sb_freeze_unlock(sb); + sb_freeze_unlock(sb, SB_FREEZE_FS); wake_up(&sb->s_writers.wait_unfrozen); deactivate_locked_super(sb); return ret; @@ -1829,7 +1834,7 @@ static int thaw_super_locked(struct super_block *sb) } sb->s_writers.frozen = SB_UNFROZEN; - sb_freeze_unlock(sb); + sb_freeze_unlock(sb, SB_FREEZE_FS); out: wake_up(&sb->s_writers.wait_unfrozen); deactivate_locked_super(sb); -- 2.34.1