From patchwork Sat Oct 22 07:19:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7227 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1090531wrr; Sat, 22 Oct 2022 00:47:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7SASQmSDyLpgxypHf2ImOhv68k8+F7MRjZUZBebAj6RGiK0rPPGaevb89rM1lse+gx4LmJ X-Received: by 2002:a17:902:d34d:b0:17f:9018:6 with SMTP id l13-20020a170902d34d00b0017f90180006mr23796089plk.112.1666424846900; Sat, 22 Oct 2022 00:47:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424846; cv=none; d=google.com; s=arc-20160816; b=CnPcePDWHG2CW8rEJgVpFpzyg6POOXoXTukORbRpVarUq+spahgpRN4T3PzVOescDN NMeBO2hCm5tRluzv07HfpBknf05KPGgQk+fkUPoFTTYPgJlIjhu9t5EBdjWn0CK+k6d4 PQeyKaR8nA6KzTf8YPlSheMMqJr1YL3phYF5xxGpoocFObN5UXKNnbWCUb6kS2IjDPLi CGlcO4OoqsYfv6K/kDHzFfccdYG8ycCWyVs4WzEX+FakKWyPrwrQ/tasHztQmCoBq75m Dz1fpoRfVcWFtjZAi2T/yxF19W5k/ZpjjSNZqne5r3uGZ5UD0fI/obt2NlOvswzI3Eji /OJA== 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=wlvBRqNQ5SxFgV3Szr4DZ3ymUcnrE/MSrqah9LdGyz4=; b=yMuip/1QbD3QOhXo2kEhTmLN1NC8qaj79Gq4eT8Pohbe1KyYpfIb7WRHOEbjDDEyQZ aQRZF1VZvf4Ve7BWX3/kN6Sp+Nv4AqP3VyoVkXL6J63BEn9iAhFDBO/17ZC6HmEiNLVD mX+I3vfuZ/QubSV7E6lQNf6X/ExVdTuBAyyD0jRd7i6mxuwg9HrmMmzw/X7ibIQDqR/e yP/IeL0sYEf5opE7w5nxVLiD+/JYbXP3OO6cLoIlmmIcpPEV0x0/apBDQrHXkXuJPVmF Pmoe/kmSR+AyWcrEFQloeAbZZNUSYLWWiSq1Ate9JvhRxfODAhUaNvafWh2qKoWhdNj6 uNTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Ap/Mb7tk"; 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 lb5-20020a17090b4a4500b0020dcf30338fsi2513793pjb.96.2022.10.22.00.47.14; Sat, 22 Oct 2022 00:47:26 -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="Ap/Mb7tk"; 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 S231519AbiJVHq4 (ORCPT + 99 others); Sat, 22 Oct 2022 03:46:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231633AbiJVHop (ORCPT ); Sat, 22 Oct 2022 03:44:45 -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 EE18329F67A; Sat, 22 Oct 2022 00:43:25 -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 0FFAA60B21; Sat, 22 Oct 2022 07:39:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2B23C433D6; Sat, 22 Oct 2022 07:39:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424351; bh=AKjqxU4F0WI3D5+Ca3cuRol5AchGUdnutzPQA42eCZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ap/Mb7tk6Sjo+Vc1LA2agIil8jsib/C6L7FT+nKZsF2C/76Nr+lFudruWNkNOT8QQ M8SOtroED5NEIY8Wx18Gx3kaWgHziTHv0ybHQawiSnth0So9J/0Oi7ux7ml9SWxxgL YtWf/gh1+qC6i3xk8r7wq6g60ZqqzahHWQMTyT0w= 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 114/717] f2fs: flush pending checkpoints when freezing super Date: Sat, 22 Oct 2022 09:19:53 +0200 Message-Id: <20221022072435.577636339@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?1747373100558963802?= X-GMAIL-MSGID: =?utf-8?q?1747373100558963802?= From: Jaegeuk Kim commit c7b58576370147833999fd4cc874d0f918bdf9ca upstream. This avoids -EINVAL when trying to freeze f2fs. Cc: stable@vger.kernel.org Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/checkpoint.c | 24 ++++++++++++++++++------ fs/f2fs/f2fs.h | 1 + fs/f2fs/super.c | 5 ++--- 3 files changed, 21 insertions(+), 9 deletions(-) --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -1894,15 +1894,27 @@ int f2fs_start_ckpt_thread(struct f2fs_s void f2fs_stop_ckpt_thread(struct f2fs_sb_info *sbi) { struct ckpt_req_control *cprc = &sbi->cprc_info; + struct task_struct *ckpt_task; - if (cprc->f2fs_issue_ckpt) { - struct task_struct *ckpt_task = cprc->f2fs_issue_ckpt; + if (!cprc->f2fs_issue_ckpt) + return; - cprc->f2fs_issue_ckpt = NULL; - kthread_stop(ckpt_task); + ckpt_task = cprc->f2fs_issue_ckpt; + cprc->f2fs_issue_ckpt = NULL; + kthread_stop(ckpt_task); - flush_remained_ckpt_reqs(sbi, NULL); - } + f2fs_flush_ckpt_thread(sbi); +} + +void f2fs_flush_ckpt_thread(struct f2fs_sb_info *sbi) +{ + struct ckpt_req_control *cprc = &sbi->cprc_info; + + flush_remained_ckpt_reqs(sbi, NULL); + + /* Let's wait for the previous dispatched checkpoint. */ + while (atomic_read(&cprc->queued_ckpt)) + io_schedule_timeout(DEFAULT_IO_TIMEOUT); } void f2fs_init_ckpt_req_control(struct f2fs_sb_info *sbi) --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3676,6 +3676,7 @@ static inline bool f2fs_need_rand_seg(st * checkpoint.c */ void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io); +void f2fs_flush_ckpt_thread(struct f2fs_sb_info *sbi); struct page *f2fs_grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index); struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index); struct page *f2fs_get_meta_page_retry(struct f2fs_sb_info *sbi, pgoff_t index); --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1637,9 +1637,8 @@ static int f2fs_freeze(struct super_bloc if (is_sbi_flag_set(F2FS_SB(sb), SBI_IS_DIRTY)) return -EINVAL; - /* ensure no checkpoint required */ - if (!llist_empty(&F2FS_SB(sb)->cprc_info.issue_list)) - return -EINVAL; + /* Let's flush checkpoints and stop the thread. */ + f2fs_flush_ckpt_thread(F2FS_SB(sb)); /* to avoid deadlock on f2fs_evict_inode->SB_FREEZE_FS */ set_sbi_flag(F2FS_SB(sb), SBI_IS_FREEZING);