From: Eric Sandeen Subject: TAKE - Add buffer to inode's dirty list after truncate() To: undisclosed-recipients: ; Date: Tue, 24 Sep 2002 16:39:35 -0500 Lines: 29 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 the root cause of the mapcheck program failing on fsr'd files, it found data past EOF as a result of the failed sync after truncate. This one seems to have the Kernel Gods' blessings, and will hopefully be in 2.4.20. Index: linux/fs/buffer.c =================================================================== RCS file: /cvs/linux-2.4-xfs/linux/fs/buffer.c,v retrieving revision 1.109 retrieving revision 1.110 diff -u -r1.109 -r1.110 --- linux/fs/buffer.c 2002/07/25 15:31:36 1.109 +++ linux/fs/buffer.c 2002/09/24 21:36:23 1.110 @@ -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; unlock: