[PATCH 04/13] ext4: Clear dirty bit from pages without data to write

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <jack@xxxxxxx>
---
 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




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux