From patchwork Sat Oct 22 07:19:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7190 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1089337wrr; Sat, 22 Oct 2022 00:42:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM77mKXJQDX7htQEC0uxIMOhhVznx8jDTpn8n/8lhUWDVeNfz2lNq5O1mQ4oH5JXkKl8WGPg X-Received: by 2002:a17:902:c946:b0:183:4bdf:9478 with SMTP id i6-20020a170902c94600b001834bdf9478mr22344641pla.139.1666424573677; Sat, 22 Oct 2022 00:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424573; cv=none; d=google.com; s=arc-20160816; b=yHquhHLKwVMdgFx8CWUF2ja2e0ICpv9XBVEONvVawsuJ2+55oc9zHyR0M/mtuBu+E3 K9Bezm/7mOjxzG87Ch3L9KJOM6KczYd6w5Sfnq28zZ+3NLPTNCJZ09V7VTc9VQPyuIHe JYfduEktde27HROCNNieVXQiKeLxlNwIF1azTXhLuksIu6UbjXuCauvqs9r9Z+6LNFfy dhNYViUDDBeTWAGgPftcVzZuVRJ8VeZvHw1An61oZEZA68Ocz18v8wArItOvzOlR5+ti v7fgqW3ULJIQaRHux9huOmewOG+203G5uXYx4eEZjIphqmJcGdMBjyb7pqEQJQ6RCtUr F9gg== 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=Unwc5Vt5rhQBFnJZTwZST7xepFxWWO2PORxyh0x4Uxk=; b=NTglCT6vI1Vg5MlarfeXuvjMJawhxMEtUGukdFi4RmbVEeC+Y0vN2FGu3nVpu4T97T y4NIolvuRy7LxsmyYQmuCRfNKMp+PTP5TzYB8HFz2bwtolEKpa6vj0rYpeEHsMD1X4TD TGK04bXipWzg7YOOKrbCChQnz7EcwLLJceXM7ZvTuzUFuzVl0zG7VA6tnYRB1SLNwzBu sFCpTSD4rd5j5/smcsN1D+ygEQKxOWDGjrOovHGJ5kiKyyAn+s4AigB2+tlX5T9GdbwC Lw4UDva7hWz6qP9prSgkJL/4r/Lu5UysNyaz5ATRS4vas4nanCpdAEvzae11P1+qcgtM VtJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Bga8eJdB; 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 b6-20020a170902d50600b00182b78df2f8si33094526plg.495.2022.10.22.00.42.41; Sat, 22 Oct 2022 00:42:53 -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=Bga8eJdB; 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 S231252AbiJVHmZ (ORCPT + 99 others); Sat, 22 Oct 2022 03:42:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231191AbiJVHlt (ORCPT ); Sat, 22 Oct 2022 03:41:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DC99CABC2; Sat, 22 Oct 2022 00:40:10 -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 ams.source.kernel.org (Postfix) with ESMTPS id E8F64B82DF8; Sat, 22 Oct 2022 07:39:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F2E3C433B5; Sat, 22 Oct 2022 07:39:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424348; bh=/rlIOwq1/D8lcgHiDoBRaXjaRMN4FAVegRTcoeZ6J7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bga8eJdBMmpTbLz/AvTj7L96JqyxuRHdV8Q4Ob/dFyV48lYNOtJyPc9Y+EHf24ILw 05nuw9L/tbhiBHun9cIEDcZDV65CyHnVasOkTFohIz418hhD+1K0c5Dq3vNFCMdkpA +o5LRD2EWPFeyuxUzIhPTjPZUr4xqkZyRC+l7hjs= 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.19 113/717] f2fs: complete checkpoints during remount Date: Sat, 22 Oct 2022 09:19:52 +0200 Message-Id: <20221022072435.432970377@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747372813562531859?= X-GMAIL-MSGID: =?utf-8?q?1747372813562531859?= 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 @@ -2146,6 +2146,9 @@ static void f2fs_enable_checkpoint(struc f2fs_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) @@ -2311,6 +2314,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,