Re: [PATCH] Make BH_Unwritten a first class bufferhead flag

Previous thread: [PATCH] X.25 Add missing sock_put in x25_receive_data by ahendry on Monday, January 8, 2007 - 3:32 pm. (2 messages)

Next thread: RE: [PATCH] x86_64 ioapic: check_timer_pin Don't add_pin_to_irq if it is already there. by Lu, Yinghai on Monday, January 8, 2007 - 3:56 pm. (1 message)
From: David Chinner
Date: Monday, January 8, 2007 - 3:49 pm

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 ...
From: Christoph Hellwig
Date: Monday, January 8, 2007 - 3:54 pm

this doesn't look like a full first class flag to me yet.  Don't
we need to check for buffer_unwritten in the places we're checking
for buffer_delay so we can stop setting buffer_delay for unwritten
buffers?
-

From: Nathan Scott
Date: Monday, January 8, 2007 - 4:14 pm

Yep, that does need to be done.  The first of the two calls
to set_buffer_delay can be removed from __xfs_get_blocks also
(currently there is an implied association between Delay and
Unwritten, which should be removed now).

I have a vague memory of some magic sysrq code (from 2.4 days)
which counted BH state on a page - if that still exists it'd
need to be updated too, but I can't seem to find it in current
2.6 kernels (used to live in buffer.c in ye olde 2.4 days).  It
probably left us around the time of PG_private's introduction.

cheers.

-- 
Nathan

-

From: David Chinner
Date: Monday, January 8, 2007 - 4:57 pm

That would be __block_prepare_write() and block_truncate_page()?
I can't see anywhere else in the code where buffer_delay is used
outside XFS....

Cheers,

Dave.
-- 
Dave Chinner
Principal Engineer
SGI Australian Software Group
-

From: Christoph Hellwig
Date: Tuesday, January 9, 2007 - 3:50 am

Yes, I think it's just those two.
-

Previous thread: [PATCH] X.25 Add missing sock_put in x25_receive_data by ahendry on Monday, January 8, 2007 - 3:32 pm. (2 messages)

Next thread: RE: [PATCH] x86_64 ioapic: check_timer_pin Don't add_pin_to_irq if it is already there. by Lu, Yinghai on Monday, January 8, 2007 - 3:56 pm. (1 message)