Subject: Re: mount -u -r does not sync?
To: None <tech-kern@NetBSD.org>
From: David Young <dyoung@pobox.com>
List: tech-kern
Date: 06/23/2005 18:06:28
--Nq2Wo0NMKNjxTN9z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Thu, Jun 23, 2005 at 06:04:51PM -0500, David Young wrote:
> Here is a patch for NetBSD that adds an ffs_sync to rw->ro transitions.
> It doesn't make any difference for my problem.

Here is that patch.

Dave

-- 
David Young             OJC Technologies
dyoung@ojctech.com      Urbana, IL * (217) 278-3933

--Nq2Wo0NMKNjxTN9z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=sync-patch

Index: ufs/ffs/ffs_vfsops.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ffs/ffs_vfsops.c,v
retrieving revision 1.164
diff -u -r1.164 ffs_vfsops.c
--- ufs/ffs/ffs_vfsops.c	29 May 2005 21:25:24 -0000	1.164
+++ ufs/ffs/ffs_vfsops.c	23 Jun 2005 23:01:10 -0000
@@ -323,7 +323,14 @@
 			/*
 			 * Changing from r/w to r/o
 			 */
-			vn_start_write(NULL, &mp, V_WAIT);
+			if ((error = vn_start_write(NULL, &mp, V_WAIT)) != 0)
+				return error;
+                        /*
+                         * Flush any dirty data.
+                         */
+			error = ffs_sync(mp, MNT_WAIT, p->p_ucred, p);
+			if (error != 0)
+				goto finish;
 			flags = WRITECLOSE;
 			if (mp->mnt_flag & MNT_FORCE)
 				flags |= FORCECLOSE;
@@ -348,6 +355,7 @@
 				fs->fs_clean = FS_ISCLEAN;
 				(void) ffs_sbupdate(ump, MNT_WAIT);
 			}
+finish:
 			vn_finished_write(mp, 0);
 			if (error)
 				return (error);

--Nq2Wo0NMKNjxTN9z--