kern/138109: Minor cleanups to the sys/gnu/fs/ext2fs based on BSD Lite2

Pedro F. Giffuni giffunip at tutopia.com
Sun Aug 23 18:00:13 UTC 2009


>Number:         138109
>Category:       kern
>Synopsis:       Minor cleanups to the sys/gnu/fs/ext2fs based on BSD Lite2
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 23 18:00:12 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Pedro F. Giffuni
>Release:        FreeBSD-7.2-RELEASE
>Organization:
>Environment:
FreeBSD kakumen.cable.net.co 7.2-RELEASE FreeBSD 7.2-RELEASE #3: Tue Aug 18 22:42:27 COT 2009     pedro at kakumen.cable.net.co:/usr/src/sys/amd64/compile/GENERIC.Dell  amd64
>Description:
I have been looking at some of the FFS BSD-lite2 fixes to apply them to our ext2fs (based on an older FFS1 from BSD lites). This is helping getting some of the code more in sync with the NetBSD implementation.

I am still missing some bigger changes but for now here are pretty simple cleanups, based on these FFS changes:

ffs_inode.c
------------
Use the correct flags (IO_SYNC -> B_SYNC) when deciding to do a sync or
async write in the section that changes the filesize. The bug resulted
in the updates always being async.

ffs_vfsops.c
-------------
Speed up for vfs_bio -- addition of a routine bqrelse to greatly diminish
	overhead for merged cache.
>How-To-Repeat:

>Fix:
diff -ruN ext2fs.orig/ext2_inode.c ext2fs/ext2_inode.c
--- ext2fs.orig/ext2_inode.c	2009-08-18 20:32:13.000000000 -0500
+++ ext2fs/ext2_inode.c	2009-08-23 12:37:18.000000000 -0500
@@ -126,16 +126,16 @@
 	long count, nblocks, blocksreleased = 0;
 	int aflags, error, i, allerror;
 	off_t osize;
-/*
-printf("ext2_truncate called %d to %d\n", VTOI(ovp)->i_number, length);
-*/	/* 
+
+	/* 
 	 * negative file sizes will totally break the code below and
 	 * are not meaningful anyways.
+	 * XXX: We should check for  max file size here too.
 	 */
+	oip = VTOI(ovp);
 	if (length < 0)
-	    return EFBIG;
+	    return EINVAL;
 
-	oip = VTOI(ovp);
 	if (ovp->v_type == VLNK &&
 	    oip->i_size < ovp->v_mount->mnt_maxsymlinklen) {
 #ifdef DIAGNOSTIC
@@ -157,7 +157,7 @@
 	/*
 	 * Lengthen the size of the file. We must ensure that the
 	 * last byte of the file is allocated. Since the smallest
-	 * value of oszie is 0, length will be at least 1.
+	 * value of osize is 0, length will be at least 1.
 	 */
 	if (osize < length) {
 		if (length > oip->i_e2fs->fs_maxfilesize)
@@ -167,12 +167,13 @@
 		aflags = B_CLRBUF;
 		if (flags & IO_SYNC)
 			aflags |= B_SYNC;
-		vnode_pager_setsize(ovp, length);
-		if ((error = ext2_balloc(oip, lbn, offset + 1, cred, &bp,
-		    aflags)) != 0)
+		error = ext2_balloc(oip, lbn, offset + 1, cred,
+		    &bp, aflags);
+		if (error)
 			return (error);
 		oip->i_size = length;
-		if (aflags & IO_SYNC)
+		vnode_pager_setsize(ovp, length);
+		if (aflags & B_SYNC)
 			bwrite(bp);
 		else
 			bawrite(bp);
@@ -195,18 +196,20 @@
 		aflags = B_CLRBUF;
 		if (flags & IO_SYNC)
 			aflags |= B_SYNC;
-		if ((error = ext2_balloc(oip, lbn, offset, cred, &bp,
-		    aflags)) != 0)
+		ext2_balloc(oip, lbn, offset, cred, &bp,
+		    aflags)
+		if (error)
 			return (error);
 		oip->i_size = length;
 		size = blksize(fs, oip, lbn);
 		bzero((char *)bp->b_data + offset, (u_int)(size - offset));
 		allocbuf(bp, size);
-		if (aflags & IO_SYNC)
+		if (aflags & B_SYNC)
 			bwrite(bp);
 		else
 			bawrite(bp);
 	}
+	vnode_pager_setsize(ovp, length);
 	/*
 	 * Calculate index into inode's block list of
 	 * last direct and indirect blocks (if any)
diff -ruN ext2fs.orig/ext2_vfsops.c ext2fs/ext2_vfsops.c
--- ext2fs.orig/ext2_vfsops.c	2009-08-18 20:32:13.000000000 -0500
+++ ext2fs/ext2_vfsops.c	2009-08-23 12:40:27.000000000 -0500
@@ -171,10 +171,7 @@
 			flags = WRITECLOSE;
 			if (mp->mnt_flag & MNT_FORCE)
 				flags |= FORCECLOSE;
-			if (vfs_busy(mp, LK_NOWAIT, 0, td))
-				return (EBUSY);
 			error = ext2_flushfiles(mp, flags, td);
-			vfs_unbusy(mp, td);
 			if (!error && fs->s_wasvalid) {
 				fs->s_es->s_state |= EXT2_VALID_FS;
 				ext2_sbupdate(ump, MNT_WAIT);
@@ -496,10 +493,10 @@
  * Things to do to update the mount:
  *	1) invalidate all cached meta-data.
  *	2) re-read superblock from disk.
- *	3) re-read summary information from disk.
- *	4) invalidate all inactive vnodes.
- *	5) invalidate all cached file data.
- *	6) re-read inode data for all active vnodes.
+ *	3) (re-read summary information from disk.)
+ *	-  (invalidate all inactive vnodes.)
+ *	4) invalidate all cached file data.
+ *	5) re-read inode data for all active vnodes.
  */
 static int
 ext2_reload(struct mount *mp, struct thread *td)
@@ -1007,8 +1004,8 @@
 		 * still zero, it will be unlinked and returned to the free
 		 * list by vput().
 		 */
-		vput(vp);
 		brelse(bp);
+		vput(vp);
 		*vpp = NULL;
 		return (error);
 	}
@@ -1032,7 +1029,7 @@
 /*
 	ext2_print_inode(ip);
 */
-	brelse(bp);
+	bqrelse(bp);
 
 	/*
 	 * Initialize the vnode from the inode, check for aliases.


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list