Skip to contentSkip to conversation

ext4: Mark the buffer_heads as dirty and uptodate after prepare_write

PATCH In review Aneesh Kumar K.V 2 participants 2 messages Nov 7, 2008 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: Mark the buffer_heads as dirty and uptodate after prepare_write

We need to make sure we mark the buffer_heads as dirty and uptodate so that block_write_full_page write them correctly.

---
 fs/ext4/inode.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
fs/ext4/inode.c +9 -0
index 95d0d12..f9461d7 100644
@@ -2333,6 +2333,15 @@ static int ext4_da_writepage(struct page *page,
 		ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE,
 						ext4_normal_get_block_write);
 		if (!ret) {
+			/*
+			 * We mark the buffer_head dirty and uptodate even
+			 * if we are not doing a block_write_full_page. This
+			 * make sure when writeback see the page again with
+			 * buffer_head present the buffer_head would have
+			 * the right flags
+			 */
+			block_commit_write(page, 0, PAGE_CACHE_SIZE);
+
 			page_bufs = page_buffers(page);
 			/* check whether all are mapped and non delay */
 			if (walk_page_buffers(NULL, page_bufs, 0, len, NULL,
Signature · 1 line
1.6.0.3.640.g6331a
maintainer
#1 lore raw

Per discussion on IRC, we've Aneesh and I have concluded that the V1 patch is correct, and in fact calling block_commit_write() when we will be redirtying the page (a) can cause problems if one or more buffer heads on the page is marked for delayed allocation and so bh->block_nr is 0, and (b) wastes disk bandwidth since the page contents will be potentially written out twice.

So we'll be going with the V1 version of the patch, and pushing it to Linus ASAP.

- Ted