Currently, XFS uses BH_PrivateStart for flagging unwritten
extent state in a bufferhead. Recently, i found the long standing
mmap/unwritten extent conversion bug, and it was to do with
partial page invalidation not clearing the unwritten flag from
bufferheads attached to the page but beyond EOF. See here
for a full explaination:
http://oss.sgi.com/archives/xfs/2006-12/msg00196.html
The solution I have checked into the XFS dev tree involves
duplicating code from block_invalidatepage to clear the
unwritten flag from the bufferhead(s), and then calling
block_invalidatepage() to do the rest.
Christoph suggested that this would be better solved by
pushing the unwritten flag into the common buffer head flags
and just adding the call to discard_buffer():
http://oss.sgi.com/archives/xfs/2006-12/msg00239.html
The following patch makes BH_Unwritten a first class citizen.
Patch against 2.6.20-rc3.
Signed-Off-By: Dave Chinner <dgc@sgi.com>
---
fs/buffer.c | 1 +
fs/xfs/linux-2.6/xfs_linux.h | 10 ----------
include/linux/buffer_head.h | 2 ++
3 files changed, 3 insertions(+), 10 deletions(-)
Index: linux/fs/buffer.c
===================================================================
--- linux.orig/fs/buffer.c 2007-01-08 17:19:49.039465038 +1100
+++ linux/fs/buffer.c 2007-01-08 17:20:43.547898480 +1100
@@ -1439,6 +1439,7 @@ static void discard_buffer(struct buffer
clear_buffer_req(bh);
clear_buffer_new(bh);
clear_buffer_delay(bh);
+ clear_buffer_unwritten(bh);
unlock_buffer(bh);
}
Index: linux/fs/xfs/linux-2.6/xfs_linux.h
===================================================================
--- linux.orig/fs/xfs/linux-2.6/xfs_linux.h 2007-01-08 17:19:32.703335135 +1100
+++ linux/fs/xfs/linux-2.6/xfs_linux.h 2007-01-08 17:19:36.271363508 +1100
@@ -109,16 +109,6 @@
#undef HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */
#endif
-/*
- * State flag for unwritten extent buffers.
- *
- * We need to be able ...