>From 40310ae771ba1d625c7917891a5d4f84f5b458ac Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Wed, 4 Aug 2010 17:10:56 +0200 Subject: [PATCH] fs: Remove obsolete buffer handling When we freshly allocate a new block under an uptodate page, we have to make sure it doesn't get zeroed and gets marked dirty. Commit 637aff46 added a code to handle this case properly. Later, commit afddba49 added page_zero_new_buffers() function which takes care of this case properly as well and all filesystems use it either directly or indirectly. So let's remove the obsolete code so that we handle this special case only in one place. Signed-off-by: Jan Kara --- fs/buffer.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index d54812b..a2947c2 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1876,9 +1876,17 @@ static int __block_prepare_write(struct inode *inode, struct page *page, unmap_underlying_metadata(bh->b_bdev, bh->b_blocknr); if (PageUptodate(page)) { - clear_buffer_new(bh); + /* + * New buffer underlying already + * uptodate data. This can happen when + * data was already written via mmap. + * We must not zero-out already valid + * data and must mark buffer dirty. + * page_zero_new_buffers() takes care + * of this (or block_commit_write() if + * data gets overwritten). + */ set_buffer_uptodate(bh); - mark_buffer_dirty(bh); continue; } if (block_end > to || block_start < from) -- 1.6.4.2