From patchwork Mon Oct 24 11:27:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9323 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp465666wru; Mon, 24 Oct 2022 06:53:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM56Et+C6TjenaBKQIubN4Hyh/MVQknTN1rzKRtq227RQ9UHOwsQXHrBXd6VM7dATb8v/Y6e X-Received: by 2002:a17:902:6a87:b0:181:c6c6:1d38 with SMTP id n7-20020a1709026a8700b00181c6c61d38mr33401695plk.74.1666619591366; Mon, 24 Oct 2022 06:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666619591; cv=none; d=google.com; s=arc-20160816; b=NvjYFrAckJo2bMjXLJHr4re0IOA2O7oFmk2eWonWeN6kEYrEvB5Cj2GneEUpjAEAcN +ADYyek7xpGuJUN26tl4kq1lt2MsyyModusqSc0NhBRv8ek2q8Y3mcg/Q51cLEHQSooG qQ7p6xz76RTIMzMpoV+XYA8BfSOMkOS+47PYUx5AKfFCziCapJ62DBMO5t7vk7UuphE+ yEa8/QJbgEYxYi1Ks/uEvnMnEVdduJH87ANvHh61X7FYh8VGX7W1T7eftyJAuP+niouF 75lkxVVsZG3aT7AjF6+hfqnwVZVOP+RHk9aFgo08upvPz2p3KUhGUUSMz0CcnLy/7fKi 6yVQ== 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=jjkcscOyGrrqI6ffzNNe67xCDMraltxb4AK2V9eUO48=; b=na5qE3PZya4OYDdaXreKjOJyZciHKYlouwAu27z2TOTaF3zR8jb+j9cT2xcpvE1xlY NCjiZOH1XM0+cubc2KMR+1EoecUABzAl3PjoFBiwS63F9VgHmyaj/kcPmLOKBHKY4yTT zxFOOX7J8GerX+WgonaIBu/CDZxsYNTw9A3QaA0IHbMdmu1nLmJK2YtDaD9e5EYV0L9g uI0RQOKm/utRWafQ33MTk9iGBrsGD2WMMpLavmflmlLY5KzYjA3gCE3/7nGKEyjvaDx5 SiUq9q48hCrgxbpdVt7AElgGZ5PFJ0GXrgYoiyW5RUs45PY96UU4/WrWciaOhTG7iGvu H3Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HVuUVUQm; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pt1-20020a17090b3d0100b002131d141ff5si2220214pjb.117.2022.10.24.06.52.58; Mon, 24 Oct 2022 06:53:11 -0700 (PDT) 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=HVuUVUQm; 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 S236428AbiJXNwh (ORCPT + 99 others); Mon, 24 Oct 2022 09:52:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236610AbiJXNv5 (ORCPT ); Mon, 24 Oct 2022 09:51:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46367BBE28; Mon, 24 Oct 2022 05:42:51 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 640E3612FF; Mon, 24 Oct 2022 12:36:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 768B5C433C1; Mon, 24 Oct 2022 12:36:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614991; bh=ENNrL+hm6L5BWOc/eyw7R9uXNysxe5nfNyIUxw6zsnI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HVuUVUQm5Y5rxeh5euDpiO2VDbhP5JPgnWTxD8eBnuOE1F495nHaHHSdH/b2CXipF zrS21MyTuu+SzC2RUR7LiswSYPvTopgWztQHrCy3zx3AVq5td2TvCRO3LjX3gDjD6j W8sfzXNh2CwMzw412r8I19TgHq4M0y5pLZtnsh1E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Yu , Jaegeuk Kim Subject: [PATCH 5.15 081/530] f2fs: complete checkpoints during remount Date: Mon, 24 Oct 2022 13:27:05 +0200 Message-Id: <20221024113048.676219749@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747577304941839620?= X-GMAIL-MSGID: =?utf-8?q?1747577304941839620?= From: Jaegeuk Kim commit 4f99484d27961cb194cebcd917176fa038a5025f upstream. Otherwise, pending checkpoints can contribute a race condition to give a quota warning. - Thread - checkpoint thread add checkpoints to the list do_remount() down_write(&sb->s_umount); f2fs_remount() block_operations() down_read_trylock(&sb->s_umount) = 0 up_write(&sb->s_umount); f2fs_quota_sync() dquot_writeback_dquots() WARN_ON_ONCE(!rwsem_is_locked(&sb->s_umount)); Or, do_remount() down_write(&sb->s_umount); f2fs_remount() create a ckpt thread f2fs_enable_checkpoint() adds checkpoints wait for f2fs_sync_fs() trigger another pending checkpoint block_operations() down_read_trylock(&sb->s_umount) = 0 up_write(&sb->s_umount); f2fs_quota_sync() dquot_writeback_dquots() WARN_ON_ONCE(!rwsem_is_locked(&sb->s_umount)); Cc: stable@vger.kernel.org Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/super.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2152,6 +2152,9 @@ static void f2fs_enable_checkpoint(struc up_write(&sbi->gc_lock); f2fs_sync_fs(sbi->sb, 1); + + /* Let's ensure there's no pending checkpoint anymore */ + f2fs_flush_ckpt_thread(sbi); } static int f2fs_remount(struct super_block *sb, int *flags, char *data) @@ -2318,6 +2321,9 @@ static int f2fs_remount(struct super_blo f2fs_stop_ckpt_thread(sbi); need_restart_ckpt = true; } else { + /* Flush if the prevous checkpoint, if exists. */ + f2fs_flush_ckpt_thread(sbi); + err = f2fs_start_ckpt_thread(sbi); if (err) { f2fs_err(sbi,