aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Chinner <dgc@sgi.com>2007-02-12 03:51:41 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-12 12:48:27 -0500
commit33a266dda9fbbe72dd978a451a8ee33c59da5e9c (patch)
tree7e3fa4100e436f12b4c0ed562dd1f6dc9ec84fd4 /fs
parent42da9cbd3eedde33a42acc2cb06f454814cf5de0 (diff)
[PATCH] Make BH_Unwritten a first class bufferhead flag V2
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. Signed-off-by: Dave Chinner <dgc@sgi.com> Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/buffer.c4
-rw-r--r--fs/xfs/linux-2.6/xfs_linux.h10
2 files changed, 3 insertions, 11 deletions
diff --git a/fs/buffer.c b/fs/buffer.c
index 7ff6e9346fae..a4b824234fb9 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1440,6 +1440,7 @@ static void discard_buffer(struct buffer_head * bh)
1440 clear_buffer_req(bh); 1440 clear_buffer_req(bh);
1441 clear_buffer_new(bh); 1441 clear_buffer_new(bh);
1442 clear_buffer_delay(bh); 1442 clear_buffer_delay(bh);
1443 clear_buffer_unwritten(bh);
1443 unlock_buffer(bh); 1444 unlock_buffer(bh);
1444} 1445}
1445 1446
@@ -1823,6 +1824,7 @@ static int __block_prepare_write(struct inode *inode, struct page *page,
1823 continue; 1824 continue;
1824 } 1825 }
1825 if (!buffer_uptodate(bh) && !buffer_delay(bh) && 1826 if (!buffer_uptodate(bh) && !buffer_delay(bh) &&
1827 !buffer_unwritten(bh) &&
1826 (block_start < from || block_end > to)) { 1828 (block_start < from || block_end > to)) {
1827 ll_rw_block(READ, 1, &bh); 1829 ll_rw_block(READ, 1, &bh);
1828 *wait_bh++=bh; 1830 *wait_bh++=bh;
@@ -2544,7 +2546,7 @@ int block_truncate_page(struct address_space *mapping,
2544 if (PageUptodate(page)) 2546 if (PageUptodate(page))
2545 set_buffer_uptodate(bh); 2547 set_buffer_uptodate(bh);
2546 2548
2547 if (!buffer_uptodate(bh) && !buffer_delay(bh)) { 2549 if (!buffer_uptodate(bh) && !buffer_delay(bh) && !buffer_unwritten(bh)) {
2548 err = -EIO; 2550 err = -EIO;
2549 ll_rw_block(READ, 1, &bh); 2551 ll_rw_block(READ, 1, &bh);
2550 wait_on_buffer(bh); 2552 wait_on_buffer(bh);
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h
index 2b0e0018738a..715adad7dd4d 100644
--- a/fs/xfs/linux-2.6/xfs_linux.h
+++ b/fs/xfs/linux-2.6/xfs_linux.h
@@ -109,16 +109,6 @@
109#undef HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */ 109#undef HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */
110#endif 110#endif
111 111
112/*
113 * State flag for unwritten extent buffers.
114 *
115 * We need to be able to distinguish between these and delayed
116 * allocate buffers within XFS. The generic IO path code does
117 * not need to distinguish - we use the BH_Delay flag for both
118 * delalloc and these ondisk-uninitialised buffers.
119 */
120BUFFER_FNS(PrivateStart, unwritten);
121
122#define restricted_chown xfs_params.restrict_chown.val 112#define restricted_chown xfs_params.restrict_chown.val
123#define irix_sgid_inherit xfs_params.sgid_inherit.val 113#define irix_sgid_inherit xfs_params.sgid_inherit.val
124#define irix_symlink_mode xfs_params.symlink_mode.val 114#define irix_symlink_mode xfs_params.symlink_mode.val