Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp820877rwl; Wed, 29 Mar 2023 08:54:42 -0700 (PDT) X-Google-Smtp-Source: AKy350bziDOkS9unVgVuh7aIprRtFTsZ0vcqBB4uFFvHHjhFGo8q6aocU2GOSPWycWAY4tb23kf3 X-Received: by 2002:a17:907:a424:b0:93e:6f40:d141 with SMTP id sg36-20020a170907a42400b0093e6f40d141mr23394448ejc.40.1680105281804; Wed, 29 Mar 2023 08:54:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680105281; cv=none; d=google.com; s=arc-20160816; b=r9TnZNx8FGdNERu4da/oFWKYhb1uacGOCvPBkrdQhtTyjnS8bAnYawHLkvFjuqfwR0 brD8HhA4RrwTkNFKCVKm2ZlaeO95ozDiJnTmqZnr8Fo+yETv6vjWD/LHyNSjQhWZnpqF a5Lgin0vqnlECugwtF6f60e+ZasmCsud0GwcB+KZ1jReNJ4MHbroGcz39suv8mgVHGEx myS8FVxyF43hSaukhhFsOd9Tt5w9oZLG8bWkXb6qhpjYtHN9+TW/HFKQ0HQgR4+lUiwX 1ryv3mSCLVwJzunkDxlRFHGTTAwvX56DyhGAS5oHB/wT6sFuWWH9FynpeTZ9TbsKpnAC SJ1A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=Thhq6nwM/21CbXNXp69ncnfJKSCf/bPOZknFshjPbQ8=; b=hditO6+r4DMdbm9J4HLBII2FU/IXVzaRCe3f5oGf6PrnBNtJh5/bnMMaBeK8SepEod cQ30X3ULJix7lfRhiuUYUxtS5Wbp2Enl02Xw/2qs3DDtATKoSnygpYvFxOXJNZ/DyWJp bTfvqVEjtMMD/2DtGCl4bJuZ05vUbLwM4HwVFfZKRcIS8j0WlguSCO4IdUhQMCAa69wy 7gFW00gDMicllgrSPNHY6xTenSeJJrF1sVhBDJIonWieBEwkEjfPgw63X0y/wSybkIX1 2+eimJWPN6IJwkCMtXomvurlFBQz5DOXeOrbwjoUR7eRPz9aacUb9qgvnpUGJ6nLfaJY HfWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=cmP6w9Ae; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b="3Eihzv/o"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e25-20020a1709067e1900b008b20e95d474si31794277ejr.51.2023.03.29.08.54.17; Wed, 29 Mar 2023 08:54:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@suse.cz header.s=susede2_rsa header.b=cmP6w9Ae; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b="3Eihzv/o"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230233AbjC2PuE (ORCPT + 99 others); Wed, 29 Mar 2023 11:50:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230245AbjC2Pt7 (ORCPT ); Wed, 29 Mar 2023 11:49:59 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57E25469C for ; Wed, 29 Mar 2023 08:49:57 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 103551FE02; Wed, 29 Mar 2023 15:49:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1680104996; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Thhq6nwM/21CbXNXp69ncnfJKSCf/bPOZknFshjPbQ8=; b=cmP6w9AeIbtPZk6X11AmTyqTDagi3Ae8u/BwAiZhu/PadWOWxnutzn22jyzsOrHoAORfPq PmsPxidng6kTTb4R6ZJJGTckzww+OokQrvavDa9wgDu1YxKUURlZkUttilvuYI5Y6AJH23 SDYrCdcPvzYfooS0pH+320LR5/Y7qak= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1680104996; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Thhq6nwM/21CbXNXp69ncnfJKSCf/bPOZknFshjPbQ8=; b=3Eihzv/oeEpNQA182IAheBC3xN+DjNyLv2LQMIEBdXKeK3gftvSNGWhxBPC4pL/hmVMmED NB7vGfohDUH6ZqDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CCAED13A3A; Wed, 29 Mar 2023 15:49:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6PoEMSJeJGQ3YwAAMHmgww (envelope-from ); Wed, 29 Mar 2023 15:49:54 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 3F84FA0735; Wed, 29 Mar 2023 17:49:50 +0200 (CEST) From: Jan Kara To: Ted Tso Cc: , Jan Kara Subject: [PATCH 04/13] ext4: Clear dirty bit from pages without data to write Date: Wed, 29 Mar 2023 17:49:35 +0200 Message-Id: <20230329154950.19720-4-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230329125740.4127-1-jack@suse.cz> References: <20230329125740.4127-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2191; i=jack@suse.cz; h=from:subject; bh=615TyBLgzeP3gyxMjfOLmB1DE1pIuuHs8koGXQI3RTQ=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBkJF4Ph6AhIF8YeljGnrFrBt+nIPmwq81c5EW7HwYf L5PTrSOJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZCReDwAKCRCcnaoHP2RA2XtnB/ 9f1MllocnUMYk5SbDZaoL5j1PA0tEj8bQgfMONwu5YiYvNHgOYqM/CgoOdEY/Zt02iZFtzl0bPDKpv T3fH9zjZZ2CnnqQAUClwFfsycO+CICvQomEWAWfZwqsXC2+X5EBZxTKxQASrSK1vpu9jmp+yab534B QSqCF1lguSSyASyI3abQsYMWOkZSRsC/1sYeej7XM8mPi1iahkipIrCmtxeEoTComVKfaexisUP2tM HR9t7c3/Nq4yqwega+5ALcKjlAYbbUPAEqJ2qQP4+/nQVZsZ1JVlAmZrI9qGYkwxNaotnZASJr47iX B8bGlx312J2R6oHJnfifLvCdlbLS3A X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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-ext4@vger.kernel.org With journalled data it can happen that checkpointing code will write out page contents without clearing the page dirty bit. The logic in ext4_page_nomap_can_writeout() then results in us never calling mpage_submit_page() and thus clearing the dirty bit. Drop the optimization with ext4_page_nomap_can_writeout() and just always call to mpage_submit_page(). ext4_bio_write_page() knows when to redirty the page and the additional clearing & setting of page dirty bit for ordered mode writeout is not that expensive to jump through the hoops for it. Signed-off-by: Jan Kara --- fs/ext4/inode.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 78e29da70af7..85299c90b0f7 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2342,19 +2342,6 @@ static int ext4_da_writepages_trans_blocks(struct inode *inode) MAX_WRITEPAGES_EXTENT_LEN + bpp - 1, bpp); } -/* Return true if the page needs to be written as part of transaction commit */ -static bool ext4_page_nomap_can_writeout(struct page *page) -{ - struct buffer_head *bh, *head; - - bh = head = page_buffers(page); - do { - if (buffer_dirty(bh) && buffer_mapped(bh) && !buffer_delay(bh)) - return true; - } while ((bh = bh->b_this_page) != head); - return false; -} - static int ext4_journal_page_buffers(handle_t *handle, struct page *page, int len) { @@ -2539,13 +2526,11 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) * range operations before discarding the page cache. */ if (!mpd->can_map) { - if (ext4_page_nomap_can_writeout(&folio->page)) { - WARN_ON_ONCE(sb->s_writers.frozen == - SB_FREEZE_COMPLETE); - err = mpage_submit_page(mpd, &folio->page); - if (err < 0) - goto out; - } + WARN_ON_ONCE(sb->s_writers.frozen == + SB_FREEZE_COMPLETE); + err = mpage_submit_page(mpd, &folio->page); + if (err < 0) + goto out; /* Pending dirtying of journalled data? */ if (PageChecked(&folio->page)) { WARN_ON_ONCE(sb->s_writers.frozen >= -- 2.35.3