public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Ted Tso <tytso@mit.edu>
Cc: <linux-ext4@vger.kernel.org>, Jan Kara <jack@suse.cz>
Subject: [PATCH 02/13] ext4: Mark pages with journalled data dirty
Date: Wed, 29 Mar 2023 17:49:33 +0200	[thread overview]
Message-ID: <20230329154950.19720-2-jack@suse.cz> (raw)
In-Reply-To: <20230329125740.4127-1-jack@suse.cz>

Currently pages with journalled data written by write(2) or modified by
block zeroing during truncate(2) are not marked as dirty. They are
dirtied only once the transaction commits. This however makes writeback
code think inode has no pages to write and so ext4_writepages() is not
called to make pages with journalled data persistent. Mark pages with
journalled data dirty (similarly as it happens for writes through mmap)
so that writeback code knows about them and ext4_writepages() can do
what it needs to to the inode.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/inode.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index dbcc8b48c7ba..73e24e61fdd2 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1003,6 +1003,18 @@ int ext4_walk_page_buffers(handle_t *handle, struct inode *inode,
 	return ret;
 }
 
+/*
+ * Helper for handling dirtying of journalled data. We also mark the folio as
+ * dirty so that writeback code knows about this page (and inode) contains
+ * dirty data. ext4_writepages() then commits appropriate transaction to
+ * make data stable.
+ */
+static int ext4_dirty_journalled_data(handle_t *handle, struct buffer_head *bh)
+{
+	folio_mark_dirty(bh->b_folio);
+	return ext4_handle_dirty_metadata(handle, NULL, bh);
+}
+
 int do_journal_get_write_access(handle_t *handle, struct inode *inode,
 				struct buffer_head *bh)
 {
@@ -1025,7 +1037,7 @@ int do_journal_get_write_access(handle_t *handle, struct inode *inode,
 	ret = ext4_journal_get_write_access(handle, inode->i_sb, bh,
 					    EXT4_JTR_NONE);
 	if (!ret && dirty)
-		ret = ext4_handle_dirty_metadata(handle, NULL, bh);
+		ret = ext4_dirty_journalled_data(handle, bh);
 	return ret;
 }
 
@@ -1270,7 +1282,7 @@ static int write_end_fn(handle_t *handle, struct inode *inode,
 	if (!buffer_mapped(bh) || buffer_freed(bh))
 		return 0;
 	set_buffer_uptodate(bh);
-	ret = ext4_handle_dirty_metadata(handle, NULL, bh);
+	ret = ext4_dirty_journalled_data(handle, bh);
 	clear_buffer_meta(bh);
 	clear_buffer_prio(bh);
 	return ret;
@@ -1353,7 +1365,7 @@ static int ext4_write_end(struct file *file,
 /*
  * This is a private version of page_zero_new_buffers() which doesn't
  * set the buffer to be dirty, since in data=journalled mode we need
- * to call ext4_handle_dirty_metadata() instead.
+ * to call ext4_dirty_journalled_data() instead.
  */
 static void ext4_journalled_zero_new_buffers(handle_t *handle,
 					    struct inode *inode,
@@ -3732,7 +3744,7 @@ static int __ext4_block_zero_page_range(handle_t *handle,
 	BUFFER_TRACE(bh, "zeroed end of block");
 
 	if (ext4_should_journal_data(inode)) {
-		err = ext4_handle_dirty_metadata(handle, inode, bh);
+		err = ext4_dirty_journalled_data(handle, bh);
 	} else {
 		err = 0;
 		mark_buffer_dirty(bh);
-- 
2.35.3


  parent reply	other threads:[~2023-03-29 15:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-29 15:49 [PATCH 0/13 v1] ext4: Make ext4_writepages() write all journalled data Jan Kara
2023-03-29 15:49 ` [PATCH 01/13] jdb2: Don't refuse invalidation of already invalidated buffers Jan Kara
2023-03-29 15:49 ` Jan Kara [this message]
2023-03-29 15:49 ` [PATCH 03/13] ext4: Keep pages with journalled data dirty Jan Kara
2023-03-29 15:49 ` [PATCH 04/13] ext4: Clear dirty bit from pages without data to write Jan Kara
2023-03-29 15:49 ` [PATCH 05/13] ext4: Commit transaction before writing back pages in data=journal mode Jan Kara
2023-03-29 15:49 ` [PATCH 06/13] ext4: Drop special handling of journalled data from ext4_sync_file() Jan Kara
2023-03-30  0:05   ` Christoph Hellwig
2023-03-30  8:21     ` Jan Kara
2023-03-29 15:49 ` [PATCH 07/13] ext4: Drop special handling of journalled data from extent shifting operations Jan Kara
2023-03-29 15:49 ` [PATCH 08/13] ext4: Fix special handling of journalled data from extent zeroing Jan Kara
2023-03-29 15:49 ` [PATCH 09/13] ext4: Drop special handling of journalled data from ext4_evict_inode() Jan Kara
2023-03-29 15:49 ` [PATCH 10/13] ext4: Drop special handling of journalled data from ext4_quota_on() Jan Kara
2023-03-29 15:49 ` [PATCH 11/13] ext4: Simplify handling of journalled data in ext4_bmap() Jan Kara
2023-03-29 15:49 ` [PATCH 12/13] ext4: Update comment in mpage_prepare_extent_to_map() Jan Kara
2023-03-29 15:49 ` [PATCH 13/13] Revert "ext4: Fix warnings when freezing filesystem with journaled data" Jan Kara
2023-04-15  3:07 ` [PATCH 0/13 v1] ext4: Make ext4_writepages() write all journalled data Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230329154950.19720-2-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox