public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* Review: ensure EOF writes into existing extents update filesize
@ 2007-05-20 23:34 David Chinner
  2007-05-20 23:40 ` Chris Wedgwood
  2007-05-21  6:34 ` Timothy Shimmin
  0 siblings, 2 replies; 11+ messages in thread
From: David Chinner @ 2007-05-20 23:34 UTC (permalink / raw)
  To: xfs-dev; +Cc: xfs-oss


As reported a coupl eof times on lkml since the 2.6.22 window opened,
XFS is not updating the file size corectly in all cases. This is a
result of the null files fix not updating the file size when the
write extending the file does not need to allocate a block.

In that case, we use a read mapping of the extent, and this also
happens to use the read I/O completion handler instead of the
write I/O completion handle. Hence the file size was not updated
on I/O completion.

Comments?

Cheers,

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

---
 fs/xfs/linux-2.6/xfs_aops.c |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

Index: 2.6.x-xfs-new/fs/xfs/linux-2.6/xfs_aops.c
===================================================================
--- 2.6.x-xfs-new.orig/fs/xfs/linux-2.6/xfs_aops.c	2007-05-11 16:03:59.000000000 +1000
+++ 2.6.x-xfs-new/fs/xfs/linux-2.6/xfs_aops.c	2007-05-12 23:46:54.379994052 +1000
@@ -973,8 +973,9 @@ xfs_page_state_convert(
 
 	bh = head = page_buffers(page);
 	offset = page_offset(page);
-	flags = -1;
-	type = IOMAP_READ;
+	iomap_valid = 0;
+	flags = BMAPI_READ;
+	type = IOMAP_NEW;
 
 	/* TODO: cleanup count and page_dirty */
 
@@ -1004,14 +1005,14 @@ xfs_page_state_convert(
 		 *
 		 * Third case, an unmapped buffer was found, and we are
 		 * in a path where we need to write the whole page out.
- 		 */
+		 */
 		if (buffer_unwritten(bh) || buffer_delay(bh) ||
 		    ((buffer_uptodate(bh) || PageUptodate(page)) &&
 		     !buffer_mapped(bh) && (unmapped || startio))) {
-		     	/*
+			/*
 			 * Make sure we don't use a read-only iomap
 			 */
-		     	if (flags == BMAPI_READ)
+			if (flags == BMAPI_READ)
 				iomap_valid = 0;
 
 			if (buffer_unwritten(bh)) {
@@ -1060,7 +1061,7 @@ xfs_page_state_convert(
 			 * That means it must already have extents allocated
 			 * underneath it. Map the extent by reading it.
 			 */
-			if (!iomap_valid || type != IOMAP_READ) {
+			if (!iomap_valid || flags != BMAPI_READ) {
 				flags = BMAPI_READ;
 				size = xfs_probe_cluster(inode, page, bh,
 								head, 1);
@@ -1071,7 +1072,15 @@ xfs_page_state_convert(
 				iomap_valid = xfs_iomap_valid(&iomap, offset);
 			}
 
-			type = IOMAP_READ;
+			/*
+			 * We set the type to IOMAP_NEW in case we are doing a
+			 * small write at EOF that is extending the file but
+			 * without needing an allocation. We need to update the
+			 * file size on I/O completion in this case so it is
+			 * the same case as having just allocated a new extent
+			 * that we are writing into for the first time.
+			 */
+			type = IOMAP_NEW;
 			if (!test_and_set_bit(BH_Lock, &bh->b_state)) {
 				ASSERT(buffer_mapped(bh));
 				if (iomap_valid)

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-05-23  0:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-20 23:34 Review: ensure EOF writes into existing extents update filesize David Chinner
2007-05-20 23:40 ` Chris Wedgwood
2007-05-20 23:44   ` David Chinner
2007-05-21  6:34 ` Timothy Shimmin
2007-05-22  0:44   ` David Chinner
2007-05-22  1:02     ` Nathan Scott
2007-05-22  1:03       ` David Chinner
2007-05-22  4:10         ` Nathan Scott
2007-05-22  6:05           ` David Chinner
2007-05-23  0:02             ` David Chinner
2007-05-23  0:15               ` Nathan Scott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox