Linux Kernels

Btrfs: Make sure page mapping dirty tag is properly cleared

This change “Btrfs: Make sure page mapping dirty tag is properly cleared” (commit 7073c8e) in Linux kernel is authored by Chris Mason <chris.mason [at] oracle.com> on Tue Nov 20 13:44:45 2007 -0500.

Description of "Btrfs: Make sure page mapping dirty tag is properly cleared"

The change “Btrfs: Make sure page mapping dirty tag is properly cleared” introduces changes as follows.

Btrfs: Make sure page mapping dirty tag is properly cleared

Signed-off-by: Chris Mason <chris.mason@oracle.com>

Linux kernel releases containing commit 7073c8e

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "Btrfs: Make sure page mapping dirty tag is properly cleared"

There are 22 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 fs/btrfs/extent_map.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
 
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index 7fd4eb7a8f03..a4e9096754fc 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -1825,12 +1825,18 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
 		if (ret)
 			SetPageError(page);
 		else {
-			unsigned long nr = end_index + 1;
+			unsigned long max_nr = end_index + 1;
 			set_range_writeback(tree, cur, cur + iosize - 1);
+			if (!PageWriteback(page)) {
+				printk("warning page %lu not writeback, "
+				       "cur %llu end %llu\n", page->index,
+				       (unsigned long long)cur,
+				       (unsigned long long)end);
+			}
 
 			ret = submit_extent_page(WRITE, tree, page, sector,
 						 iosize, page_offset, bdev,
-						 &epd->bio, nr,
+						 &epd->bio, max_nr,
 						 end_bio_extent_writepage);
 			if (ret)
 				SetPageError(page);
@@ -1840,6 +1846,11 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
 		nr++;
 	}
 done:
+	if (nr == 0) {
+		/* make sure the mapping tag for page dirty gets cleared */
+		set_page_writeback(page);
+		end_page_writeback(page);
+	}
 	unlock_extent(tree, start, page_end, GFP_NOFS);
 	unlock_page(page);
 	return 0;
@@ -2408,6 +2419,13 @@ int clear_extent_buffer_dirty(struct extent_map_tree *tree,
 			}
 		}
 		clear_page_dirty_for_io(page);
+		write_lock_irq(&page->mapping->tree_lock);
+		if (!PageDirty(page)) {
+			radix_tree_tag_clear(&page->mapping->page_tree,
+						page_index(page),
+						PAGECACHE_TAG_DIRTY);
+		}
+		write_unlock_irq(&page->mapping->tree_lock);
 		unlock_page(page);
 	}
 	return 0;

The commit for this change in Linux stable tree is 7073c8e (patch).

Last modified: 2020/01/11 09:49