linux user group brescia

immagine del castello

Archivio della mailing list

[akpm a digeo.com: data corrupting bug in 2.4.20 ext3, data=journal]

andrea gelmini andrea.gelmini a lugbs.linux.it
Dom 1 Dic 2002 11:18:05 UTC
brevemente, per chi non sapesse l'inglese: non usare l'ext3 in modalita`
journal con il kernel 2.4.20 (questo veniva gia` sconsigliato anche sul
2.4.19 ma per altre ragioni). nel momento in cui viene fatto l'umount di
una partizione non vengono scritti fisicamente sul disco i dati mandati
negli ultimi 30 secondi.

ciao,
andrea

----- Forwarded message from Andrew Morton <akpm a digeo.com> -----

Date: 	Sun, 01 Dec 2002 00:11:41 -0800
From: Andrew Morton <akpm a digeo.com>
X-Mailer: Mozilla 4.79 [en] (X11; U; Linux 2.5.46 i686)
To: lkml <linux-kernel a vger.kernel.org>,
   "ext3-users a redhat.com" <ext3-users a redhat.com>
Subject: data corrupting bug in 2.4.20 ext3, data=journal
X-Mailing-List: 	linux-kernel a vger.kernel.org


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);

_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo a vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

----- End forwarded message -----

-- 
"Se Alan Turing fosse vivo oggi, la sua omosessualità non sarebbe un problema
 ma finirebbe in galera per aver decifrato codici".
		-- Martin Bacon, utente internet



Maggiori informazioni sulla lista Lug