Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Apr 1998 11:54:19 -0700 (PDT)
From:      Matthew Dillon <dillon@backplane.com>
To:        David Greenman <dg@root.com>
Cc:        freebsd-bugs@hub.freebsd.org, freebsd-gnats-submit@hub.freebsd.org
Subject:   Re: kern/6212: Two bugs with MFS filesystem fixed, two features added 
Message-ID:  <199804071854.LAA21604@apollo.backplane.com>

next in thread | raw e-mail | index | archive | help
:
:   ...only if you want us to commit the changes. :-)
:
:-DG
:
:David Greenman
:Core-team/Principal Architect, The FreeBSD Project

    heh heh.


    Matthew Dillon   Engineering, BEST Internet Communications, Inc.
		     <dillon@backplane.com>
    [always include a portion of the original email in any response!]


Index: mkfs.c
===================================================================
RCS file: /src/FreeBSD-CVS/ncvs/src/sbin/newfs/mkfs.c,v
retrieving revision 1.21
diff -u -r1.21 mkfs.c
--- mkfs.c	1998/01/19 16:55:26	1.21
+++ mkfs.c	1998/04/07 04:06:28
@@ -40,6 +40,7 @@
 #include <sys/time.h>
 #include <sys/wait.h>
 #include <sys/resource.h>
+#include <sys/stat.h>
 #include <ufs/ufs/dinode.h>
 #include <ufs/ufs/dir.h>
 #include <ufs/ffs/fs.h>
@@ -106,6 +107,7 @@
 extern caddr_t	malloc(), calloc();
 #endif
 extern char *	filename;
+extern int	skipnewfs;
 
 union {
 	struct fs fs;
@@ -178,19 +180,29 @@
 		if(filename) {
 			unsigned char buf[BUFSIZ];
 			unsigned long l,l1;
-			fd = open(filename,O_RDWR|O_TRUNC|O_CREAT,0644);
+			struct stat st;
+
+			fd = open(filename,O_RDWR|O_CREAT,0644);
 			if(fd < 0) {
 				perror(filename);
 				exit(12);
 			}
-			for(l=0;l< fssize * sectorsize;l += l1) {
-				l1 = fssize * sectorsize;
-				if (BUFSIZ < l1)
-					l1 = BUFSIZ;
-				if (l1 != write(fd,buf,l1)) {
-					perror(filename);
+			fstat(fd, &st);
+			if (st.st_size != fssize * sectorsize) {
+				if (skipnewfs) {
+					fprintf(stderr, "Filesize does not match filesystem sector count\n");
 					exit(12);
 				}
+				ftruncate(fd, fssize * sectorsize);
+				for(l=0;l< fssize * sectorsize;l += l1) {
+					l1 = fssize * sectorsize;
+					if (BUFSIZ < l1)
+						l1 = BUFSIZ;
+					if (l1 != write(fd,buf,l1)) {
+						perror(filename);
+						exit(12);
+					}
+				}
 			}
 			membase = mmap(
 				0,
@@ -216,6 +228,8 @@
 			}
 		}
 	}
+	if (skipnewfs == 0) { 	/* didn't re-indent context so submitted cvs diff would be more readable */
+
 	fsi = fi;
 	fso = fo;
 	if (Oflag) {
@@ -699,6 +713,9 @@
 	pp->p_fsize = sblock.fs_fsize;
 	pp->p_frag = sblock.fs_frag;
 	pp->p_cpg = sblock.fs_cpg;
+
+	}	/* endif skipnewfs */
+
 	/*
 	 * Notify parent process of success.
 	 * Dissociate from session and tty.
Index: newfs.c
===================================================================
RCS file: /src/FreeBSD-CVS/ncvs/src/sbin/newfs/newfs.c,v
retrieving revision 1.18
diff -u -r1.18 newfs.c
--- newfs.c	1998/01/16 06:31:23	1.18
+++ newfs.c	1998/04/07 04:02:25
@@ -193,6 +193,7 @@
 u_long	memleft;		/* virtual memory available */
 caddr_t	membase;		/* start address of memory based filesystem */
 char	*filename;
+int	skipnewfs;
 #ifdef COMPAT
 char	*disktype;
 int	unlabeled;
@@ -234,7 +235,7 @@
 	}
 
 	opstring = mfs ?
-	    "NF:T:a:b:c:d:e:f:i:m:o:s:" :
+	    "NF:U:T:a:b:c:d:e:f:i:m:o:s:" :
 	    "NOS:T:a:b:c:d:e:f:i:k:l:m:n:o:p:r:s:t:u:x:";
 	while ((ch = getopt(argc, argv, opstring)) != -1)
 		switch (ch) {
@@ -253,6 +254,9 @@
 			disktype = optarg;
 			break;
 #endif
+		case 'U':
+			skipnewfs = 1;
+			/* fall through */
 		case 'F':
 			filename = optarg;
 			break;
Index: mfs_vfsops.c
===================================================================
RCS file: /src/FreeBSD-CVS/ncvs/src/sys/ufs/mfs/mfs_vfsops.c,v
retrieving revision 1.41
diff -u -r1.41 mfs_vfsops.c
--- mfs_vfsops.c	1998/03/01 22:46:53	1.41
+++ mfs_vfsops.c	1998/04/05 02:21:16
@@ -46,6 +46,8 @@
 #include <sys/signalvar.h>
 #include <sys/vnode.h>
 #include <sys/malloc.h>
+#include <sys/sysproto.h>	/* for msync_args */
+#include <sys/mman.h>	/* for msync_args */
 
 #include <ufs/ufs/quota.h>
 #include <ufs/ufs/inode.h>
@@ -430,6 +432,13 @@
 error_1:	/* no state to back out*/
 
 success:
+	/*
+	 * must mark the calling process as a system process
+	 * so the pager doesn't try to kill it.  Doh!  And the
+	 * pager may because the resident set size may be huge.
+	 */
+	p->p_flag |= P_SYSTEM;
+
 	return( err);
 }
 
@@ -468,7 +477,8 @@
 		 * If a non-ignored signal is received, try to unmount.
 		 * If that fails, clear the signal (it has been "processed"),
 		 * otherwise we will loop here, as tsleep will always return
-		 * EINTR/ERESTART.
+		 * EINTR/ERESTART.  It will return EWOULDBLOCK if the timer
+		 * expired.
 		 */
 		/*
 		 * Note that dounmount() may fail if work was queued after
@@ -479,9 +489,37 @@
 			gotsig = 0;
 			if (dounmount(mp, 0, p) != 0)
 				CLRSIG(p, CURSIG(p));	/* try sleep again.. */
-		}
-		else if (tsleep((caddr_t)vp, mfs_pri, "mfsidl", 0))
+		} else {
+		    int r = tsleep((caddr_t)vp, mfs_pri, "mfsidl", hz * 10);
+
+		    if (r && r != EWOULDBLOCK)
 			gotsig++;	/* try to unmount in next pass */
+		}
+
+		/*
+		 * we should call msync on the backing store every 30 seconds,
+		 * otherwise the pages are not associated with the file and guess
+		 * what!  the syncer never sees them.  msync has no effect 
+		 * if the backing store is swap, but a big effect if it's a file
+		 * (e.g. an NFS mounted file).
+		 */
+		{
+			static long lsec;
+			int dt = time_second - lsec;
+
+			if (dt < -30 || dt > 30) {
+				struct msync_args uap;
+
+				lsec = time_second;
+
+				uap.addr = mfsp->mfs_baseoff;
+				uap.len = mfsp->mfs_size;
+				uap.flags = MS_ASYNC;
+
+				msync(curproc, &uap);
+			}
+		}
+
 	}
 	return (0);
 }

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199804071854.LAA21604>