In 2.4.20-pre5 an optimisation was made to the ext3 fsync function which can very easily cause file data corruption at unmount time. This was first reported by Nick Piggin on November 29th (one day after 2.4.20 was released, and three months after the bug was merged. Unfortunate timing) This only affects filesystems which were mounted with the `data=journal' option. Or files which are operating under `chattr -j'. So most people are unaffected. The problem is not present in 2.5 kernels. The symptoms are that any file data which was written within the thirty seconds prior to the unmount may not make it to disk. A workaround is to run `sync' before unmounting. The optimisation was intended to avoid writing out and waiting on the inode's buffers when the subsequent commit would do that anyway. This optimisation was applied to both data=journal and data=ordered modes. But it is only valid for data=ordered mode. In data=journal mode the data is left dirty in memory and the unmount will silently discard it. The fix is to only apply the optimisation to inodes which are operating under data=ordered. --- linux-akpm/fs/ext3/fsync.c~ext3-fsync-fix Sat Nov 30 23:37:33 2002 +++ linux-akpm-akpm/fs/ext3/fsync.c Sat Nov 30 23:39:30 2002 @@ -63,10 +63,12 @@ int ext3_sync_file(struct file * file, s */ ret = fsync_inode_buffers(inode); - /* In writeback mode, we need to force out data buffers too. In - * the other modes, ext3_force_commit takes care of forcing out - * just the right data blocks. */ - if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA) + /* + * If the inode is under ordered-data writeback it is not necessary to + * sync its data buffers here - commit will do that, with potentially + * better IO merging + */ + if (!ext3_should_order_data(inode)) ret |= fsync_inode_data_buffers(inode); ext3_force_commit(inode->i_sb); _
Andrew Morton wrote:> > ... > The fix is to only apply the optimisation to inodes which are operating > under data=ordered. >That "fix" didn't fix it. Sorry about that. Please avoid ext3/data=journal until it is sorted out.
Andrew Morton wrote:>In 2.4.20-pre5 an optimisation was made to the ext3 fsync function >which can very easily cause file data corruption at unmount time. This >was first reported by Nick Piggin on November 29th (one day after 2.4.20 was >released, and three months after the bug was merged. Unfortunate timing) >In fact it was reported on lkml on 18th July IIRC before 2.4.19 was released if that is any help to you. 2.4.19 and 2.4.20 are affected and I haven't tested previous releases. I was going to re-report it sometime, but Alan brought it to light just the other day. Nick
Andrew Morton wrote:>Nick Piggin wrote: >> >> Andrew Morton wrote: >> >> >In 2.4.20-pre5 an optimisation was made to the ext3 fsync function >> >which can very easily cause file data corruption at unmount time. This >> >was first reported by Nick Piggin on November 29th (one day after 2.4.20 was >> >released, and three months after the bug was merged. Unfortunate timing) >> > >> In fact it was reported on lkml on 18th July IIRC before 2.4.19 was >> released if that is any help to you. 2.4.19 and 2.4.20 are affected >> and I haven't tested previous releases. I was going to re-report it >> sometime, but Alan brought it to light just the other day. >> > >Are you sure? I can't make it happen on 2.4.19. And disabling the new >BH_Freed logic (which went into 2.4.20-pre5) makes it go away. > > >--- linux-akpm/fs/jbd/commit.c~a Sun Dec 1 23:10:12 2002 >+++ linux-akpm-akpm/fs/jbd/commit.c Sun Dec 1 23:10:27 2002 >@@ -695,7 +695,7 @@ skip_commit: /* The journal should be un > * use in a different page. */ > if (__buffer_state(bh, Freed)) { > clear_bit(BH_Freed, &bh->b_state); >- clear_bit(BH_JBDDirty, &bh->b_state); >+// clear_bit(BH_JBDDirty, &bh->b_state); > } > > if (buffer_jdirty(bh)) { >I reported the bug for 2.4.19-rc1 and 2 but I can't remember if I tested 2.4.19 when it was released. It has an external journal on a seperate disk. I can't really do any testing with the machine unfortunately. Regards, Nick
Maybe Matching Threads
- PATCH for filesys corruption in ext3 with data=journal
- one question
- [PATCH] BUG on error handlings in Ext3 under I/O failure condition
- More ext3 fileserver woes ...
- failure in do_get_write_access() at transaction.c:731: "(((jh2bh(jh))->b_state & (1UL << BH_Uptodate)) != 0)"