From patchwork Mon Oct 24 11:27:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10096 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp625685wru; Mon, 24 Oct 2022 12:55:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7427gTJGLFyAhMgT1/l4fsRoriRSfTOWU2/zERwPZIYP2hCQOG1sKSfxsKB4x8QkNRgCf6 X-Received: by 2002:a17:90b:1e4c:b0:213:32a5:a778 with SMTP id pi12-20020a17090b1e4c00b0021332a5a778mr2474388pjb.172.1666641302305; Mon, 24 Oct 2022 12:55:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666641302; cv=none; d=google.com; s=arc-20160816; b=Dyuy6rQdFp1aS9tpo7ryMXNF43zQF1XlHk+QBDZmvT2yy0Jzbkm7gH3NWIOkpRd83g rxjNVzfAhWZcmvKCfvBkAxYvH85fG5g8EZgj+EoxBx00H4fwMIBa4wbvSZ9oakecDO+Q tlT7V+4KfafcaCvnF5kwXx4lzaSaj0NpV6OUUmWUJwSCAa/iMfj6mgkfEBoB1IQUCfN+ JLmYalp6bIjZ8npmVkgGljoKaMJoBK5lWm+eFyI3E4z3nm0Yb0xjdne1uaumuDWxzsU2 AfeJ/e054KkDotVBYQfzt2T671gPKxLerNBtP/OhIZRS0CK2WmX1RDqj/F+nw9JRTpc2 ao9g== 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=Jhai53hJqr6xv3huGyKSMXlb98am9XGfbKi7sV6aOtI=; b=kBUolfh4a0cjwIMFctYJ5mxkgIPW26p91WMkKsTI9jqUfVfsydQKtvdIsi3M8Y5tuk QrVegFK2m2VLWHTY6ArrL5DlQbxpatc2PjBURvsHKYN0bSUUpIHpN77zt0DVUOYox88q aNMglnSe1uuA4dhMKkC5LHMXs8E8AJCD84csrNgJBqncZTPexGIIUbixIKPo7jetCB42 AQ4+a2e6LHRQqbb30kHhbCkcfBWxqSihcli/mCB+GXhvD2i7bWTHZZwo7e1wXOuMLMhg Iurgf4BUKmXewDGtcCumdcgKH3aIROKImF8VQaM0zw5suzYXYTnaMl4p2kwtjf4yNeNv Ykag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PgVTv8hB; 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 x8-20020a170902ec8800b001868bdb66cfsi408718plg.461.2022.10.24.12.54.49; Mon, 24 Oct 2022 12:55:02 -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=PgVTv8hB; 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 S231976AbiJXTxw (ORCPT + 99 others); Mon, 24 Oct 2022 15:53:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233719AbiJXTwh (ORCPT ); Mon, 24 Oct 2022 15:52:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A09D386A2; Mon, 24 Oct 2022 11:17: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 ams.source.kernel.org (Postfix) with ESMTPS id E8156B817C2; Mon, 24 Oct 2022 12:36:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E1F6C433D6; Mon, 24 Oct 2022 12:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614994; bh=fCrdWHM8LnRaqMfC4KAxu5QD6ur8u7uDL8AqdQGAJ9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PgVTv8hBRmKi6TKQsj701VcV3I7z73elPZCB4ZIUe7UiZiZ2Py8YFdj3bplaTvoqY VBEOJbhyDuNZsWP5Qh2C9pzYHzkyEUIfFjmO7U9SxJ5vhXs+qiaYPgLgdqoSxQalSO 76FRYT/H3ZFpVIm5ANwHvDBbbWKEsp6K1f8CZu6Q= 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 082/530] f2fs: flush pending checkpoints when freezing super Date: Mon, 24 Oct 2022 13:27:06 +0200 Message-Id: <20221024113048.729715245@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?1747600070155686231?= X-GMAIL-MSGID: =?utf-8?q?1747600070155686231?= 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 @@ -1892,15 +1892,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 @@ -3540,6 +3540,7 @@ unsigned int f2fs_usable_blks_in_seg(str * 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 @@ -1661,9 +1661,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);