Is that a typo in ffs_softdep.c

Max Khon fjoe at iclub.nsu.ru
Tue Mar 2 11:10:58 PST 2004


Hello!

On Wed, Mar 03, 2004 at 01:08:38AM +0600, Max Khon wrote:

> > It looks like a typo in ffs_softdep.c softdep_sync_metadata().
> > The second parameter of drain_output is used to tell if it is 
> > protected by &lk.
> > Is there other concern?
> > Please check the following patch from 4.9 release.

[...]

> Nice catch!
> 
> drain_output() should be called earlier (before chechkig dirty list).
> The bug was introduced in ffs_softdep.c rev. 1.57.2.10.
> Correct patch is attached.
> I sent this patch to Kirk for review and will commit it as soon as I get
> an approval from him.

Sorry, forgot to attach the patch.

/fjoe
-------------- next part --------------
Index: ffs_softdep.c
===================================================================
RCS file: /home/ncvs/src/sys/ufs/ffs/ffs_softdep.c,v
retrieving revision 1.57.2.11
diff -u -p -r1.57.2.11 ffs_softdep.c
--- ffs_softdep.c	5 Feb 2002 18:46:53 -0000	1.57.2.11
+++ ffs_softdep.c	2 Mar 2004 18:52:25 -0000
@@ -4293,7 +4293,11 @@ loop:
 	 * If we have managed to get rid of all the dirty buffers,
 	 * then we are done. For certain directories and block
 	 * devices, we may need to do further work.
+	 *
+	 * We must wait for any I/O in progress to finish so that
+	 * all potential buffers on the dirty list will be visible.
 	 */
+	drain_output(vp, 1);
 	if (TAILQ_FIRST(&vp->v_dirtyblkhd) == NULL) {
 		FREE_LOCK(&lk);
 		return (0);
@@ -4306,11 +4310,7 @@ loop:
 	 * partially written files have been written to disk. The only easy
 	 * way to accomplish this is to sync the entire filesystem (luckily
 	 * this happens rarely).
-	 *
-	 * We must wait for any I/O in progress to finish so that
-	 * all potential buffers on the dirty list will be visible.
 	 */
-	drain_output(vp, 1);
 	if (vn_isdisk(vp, NULL) && 
 	    vp->v_specmountpoint && !VOP_ISLOCKED(vp, NULL) &&
 	    (error = VFS_SYNC(vp->v_specmountpoint, MNT_WAIT, ap->a_cred,


More information about the freebsd-fs mailing list