Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Aug 2009 18:18:19 GMT
From:      Aditya Sarawgi <truncs@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 167619 for review
Message-ID:  <200908221818.n7MIIJtZ020147@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=167619

Change 167619 by truncs@aditya on 2009/08/22 18:18:13

	A little cleanup and making it more consistent with UFS.
	Submitted by: Pedro Giffuni

Affected files ...

.. //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_inode.c#6 edit
.. //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_vfsops.c#18 edit

Differences ...

==== //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_inode.c#6 (text+ko) ====

@@ -125,16 +125,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.
+	 * We should check the 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
@@ -155,7 +155,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->e2fs_maxfilesize)
@@ -163,14 +163,15 @@
 		offset = blkoff(fs, length - 1);
 		lbn = lblkno(fs, length - 1);
 		aflags = B_CLRBUF;
-		if (flags & B_SYNC)
+		if (flags & IO_SYNC)
 			aflags |= B_SYNC;
-		if ((error = ext2_balloc(oip, lbn, offset + 1, cred, &bp,
-		    aflags)) != 0)
+		vnode_pager_setsize(ovp, length);
+		error = ext2_balloc(oip, lbn, offset + 1, cred, &bp,
+		    aflags);
+		if(error)
 			return (error);
 		oip->i_size = length;
-		vnode_pager_setsize(ovp, length);
-		if (aflags & IO_SYNC)
+		if (aflags & B_SYNC)
 			bwrite(bp);
 		else
 			bawrite(bp);
@@ -200,12 +201,11 @@
 		size = blksize(fs, oip, lbn);
 		bzero((char *)bp->b_data + offset, (u_int)(size - offset));
 		allocbuf(bp, size);
-		if (aflags & B_SYNC)
+		if (aflags & IO_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)
@@ -444,8 +444,9 @@
 		last = lastbn % factor;
 		nb = bap[i];
 		if (nb != 0) {
-			if ((error = ext2_indirtrunc(ip, nlbn, fsbtodb(fs, nb),
-			    last, level - 1, &blkcount)) != 0)
+			error = ext2_indirtrunc(ip, nlbn, fsbtodb(fs, nb),
+			    last, level - 1, &blkcount)
+			if (error)
 				allerror = error;
 			blocksreleased += blkcount;
 		}

==== //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_vfsops.c#18 (text+ko) ====

@@ -149,10 +149,7 @@
 			flags = WRITECLOSE;
 			if (mp->mnt_flag & MNT_FORCE)
 				flags |= FORCECLOSE;
-			if (vfs_busy(mp, MBF_NOWAIT))
-				return (EBUSY);
 			error = ext2_flushfiles(mp, flags, td);
-			vfs_unbusy(mp);
 			if ( error == 0 && fs->e2fs_wasvalid && ext2_cgupdate(ump, MNT_WAIT) == 0) {
 				fs->e2fs->e2fs_state |= E2FS_ISCLEAN;
 				ext2_sbupdate(ump, MNT_WAIT);
@@ -400,10 +397,9 @@
  * 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).
+ *	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)
@@ -888,8 +884,8 @@
 		 * still zero, it will be unlinked and returned to the free
 		 * list by vput().
 		 */
+		brelse(bp);
 		vput(vp);
-		brelse(bp);
 		*vpp = NULL;
 		return (error);
 	}
@@ -915,7 +911,7 @@
 /*
 	ext2_print_inode(ip);
 */
-	brelse(bp);
+	bqrelse(bp);
 
 	/*
 	 * Initialize the vnode from the inode, check for aliases.



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