linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 2.4.19 place buffer dirtied in truncate() on inode's dirty data list
@ 2002-09-24 18:23 Eric Sandeen
  0 siblings, 0 replies; only message in thread
From: Eric Sandeen @ 2002-09-24 18:23 UTC (permalink / raw)
  To: LKML

This is for 2.4.x:

block_truncate_page() does a __mark_buffer_dirty(bh) at the end, but it
does not file the buffer on the inode's dirty data queue, so only
bdflush can ever get to it, and other sync mechanisms which call
fsync_inode_data_buffers() do not see it.

This was causing a particular problem with O_DIRECT on an xfs
filesystem, since O_DIRECT tries to sync before doing the I/O. 
Following a truncate(), O_DIRECT reads of the last block were not
returning the correct data, since the truncate never got synced down to
disk.

ext2 does not seem to be able to do an O_DIRECT read of the last
filesytem block, unless the file size is a multiple of block size, so it
doesn't show up there.

--- linux/fs/buffer.c_1.109     Mon Sep 23 13:10:56 2002
+++ linux/fs/buffer.c   Mon Sep 23 13:04:44 2002
@@ -2028,7 +2028,12 @@
        flush_dcache_page(page);
        kunmap(page);
 
-       __mark_buffer_dirty(bh);
+       if (!atomic_set_buffer_dirty(bh)) {
+               __mark_dirty(bh);
+               buffer_insert_inode_data_queue(bh, inode);
+               balance_dirty();
+       }
+
        err = 0;


The balance_dirty() call is debatable, Andrew Morton pointed out that it
does add a bit more risk.  OTOH, if you go off and truncate a million
files in a row, you'll be in sorry shape without it.

2.5 apparently does not have this problem, it calls mark_buffer_dirty()
which seems to take care of things.

-Eric

-- 
Eric Sandeen      XFS for Linux     http://oss.sgi.com/projects/xfs
sandeen@sgi.com   SGI, Inc.         651-683-3102


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-09-24 18:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-24 18:23 [PATCH] 2.4.19 place buffer dirtied in truncate() on inode's dirty data list Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).