From patchwork Wed Nov 30 16:35:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 1710597 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=tqoq=36=vger.kernel.org=linux-ext4-owner@ozlabs.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=mll/dFZb; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=ysVTS7MA; dkim-atps=neutral Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NMlFx0N48z23nv for ; Thu, 1 Dec 2022 03:36:20 +1100 (AEDT) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4NMlFt3QyRz4x2c for ; Thu, 1 Dec 2022 03:36:18 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4NMlFt3Mfjz4xN4; Thu, 1 Dec 2022 03:36:18 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=mll/dFZb; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=ysVTS7MA; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4NMlFs2GDxz4x2c for ; Thu, 1 Dec 2022 03:36:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230260AbiK3QgN (ORCPT ); Wed, 30 Nov 2022 11:36:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230226AbiK3QgL (ORCPT ); Wed, 30 Nov 2022 11:36:11 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BACA5B840 for ; Wed, 30 Nov 2022 08:36:10 -0800 (PST) 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-out1.suse.de (Postfix) with ESMTPS id 4985221B0A; Wed, 30 Nov 2022 16:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1669826169; 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=HBKsU6wxR89x5I3rg2s8lp5ksmdLcZEbJRx6brYthgM=; b=mll/dFZbtFheRkojsXOCKJg/x/3Bs+vx0EBBjb9IaV5daMn5KTwcTZWm4sFQYsaBSQPMP/ u+YrKbYMJya36ImpDb6s2ZXgKH+Jg+Ik7p+QK0y5GjBiQhlEia/Ima9wb9xFqC8OdEFOOt Cm5bfsF2vmry5tpbGPE1zf6WEWZNUxE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1669826169; 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=HBKsU6wxR89x5I3rg2s8lp5ksmdLcZEbJRx6brYthgM=; b=ysVTS7MA2yGDhTgwYDc8709YwJfksISDr708gIm3HadqPTnJx+Fj3vS51myJ6LALJJx16u qhZq7FZeOPUZVeAQ== 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 3A9E513A70; Wed, 30 Nov 2022 16:36:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Jv1KDnmGh2NNQgAAMHmgww (envelope-from ); Wed, 30 Nov 2022 16:36:09 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id A89A6A0714; Wed, 30 Nov 2022 17:36:08 +0100 (CET) From: Jan Kara To: Ted Tso Cc: , Christoph Hellwig , Jan Kara Subject: [PATCH 1/9] ext4: Handle redirtying in ext4_bio_write_page() Date: Wed, 30 Nov 2022 17:35:52 +0100 Message-Id: <20221130163608.29034-1-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221130162435.2324-1-jack@suse.cz> References: <20221130162435.2324-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1980; i=jack@suse.cz; h=from:subject; bh=zcjEYbPJjXpKlwPeOZu0KQgMGq+rgIuX59fnDrSfxgM=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBjh4ZoZDy1ANDhnBCS1k5KlEBWcMiC5MU5BeC2TCum Fjt585KJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCY4eGaAAKCRCcnaoHP2RA2bJYB/ 9l6QHfc8BCwya5hHoUPiVx7XxiLKZqB1EtUDWUSFaCjf8DdVF7MkXRBSmG9R8j2j3gaPBox6yTus3f LPjUd5Q8Wozw+LdYEpK1jO6PrZUJKvETUzFDdfRyOjHQtjifnYH4Z9LuU/9VrU40sZFPC3xsaOtRo8 /F3eGKLwDCnwFMoRU+6sINMIIFdZhpPIuAjZS/x+YWOAovY9UMzZqjd0Yx5hSioRTnbW/o98TwfcNa yqs8v8ORdk4cQFv0PXF2c5czPDyUTwJsxCGZu+4nQdoHVIDW0JVPE0c2RdH1IDApLErQrk+A76lq5d 3Fm8BN5zSERCbOjIk4oCBf/Wfq725b X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_SOFTFAIL 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-ext4@vger.kernel.org Since we want to transition transaction commits to use ext4_writepages() for writing back ordered, add handling of page redirtying into ext4_bio_write_page(). Also move buffer dirty bit clearing into the same place other buffer state handling. Signed-off-by: Jan Kara Reviewed-by: Ritesh Harjani (IBM) --- fs/ext4/page-io.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index 97fa7b4c645f..4e68ace86f11 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -482,6 +482,13 @@ int ext4_bio_write_page(struct ext4_io_submit *io, /* A hole? We can safely clear the dirty bit */ if (!buffer_mapped(bh)) clear_buffer_dirty(bh); + /* + * Keeping dirty some buffer we cannot write? Make + * sure to redirty the page. This happens e.g. when + * doing writeout for transaction commit. + */ + if (buffer_dirty(bh) && !PageDirty(page)) + redirty_page_for_writepage(wbc, page); if (io->io_bio) ext4_io_submit(io); continue; @@ -489,6 +496,7 @@ int ext4_bio_write_page(struct ext4_io_submit *io, if (buffer_new(bh)) clear_buffer_new(bh); set_buffer_async_write(bh); + clear_buffer_dirty(bh); nr_to_submit++; } while ((bh = bh->b_this_page) != head); @@ -532,7 +540,10 @@ int ext4_bio_write_page(struct ext4_io_submit *io, printk_ratelimited(KERN_ERR "%s: ret = %d\n", __func__, ret); redirty_page_for_writepage(wbc, page); do { - clear_buffer_async_write(bh); + if (buffer_async_write(bh)) { + clear_buffer_async_write(bh); + set_buffer_dirty(bh); + } bh = bh->b_this_page; } while (bh != head); goto unlock; @@ -546,7 +557,6 @@ int ext4_bio_write_page(struct ext4_io_submit *io, io_submit_add_bh(io, inode, bounce_page ? bounce_page : page, bh); nr_submitted++; - clear_buffer_dirty(bh); } while ((bh = bh->b_this_page) != head); unlock: