Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Aug 2009 21:15:17 GMT
From:      Aditya Sarawgi <truncs@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 167912 for review
Message-ID:  <200908272115.n7RLFHQ6006007@repoman.freebsd.org>

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

Change 167912 by truncs@aditya on 2009/08/27 21:14:14

	Style fixes and IO sync bug fix.

Affected files ...

.. //depot/projects/soc2009/soc_ext2fs/src/sys/fs/ext2fs/ext2_inode.c#3 edit

Differences ...

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

@@ -125,16 +125,11 @@
 	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.
-	 */
+
+	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 +150,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)
@@ -166,11 +161,12 @@
 		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) {
+			vnode_pager_setsize(vp, osize);
 			return (error);
 		oip->i_size = length;
-		if (aflags & IO_SYNC)
+		if (aflags & B_SYNC)
 			bwrite(bp);
 		else
 			bawrite(bp);
@@ -193,14 +189,15 @@
 		aflags = B_CLRBUF;
 		if (flags & IO_SYNC)
 			aflags |= B_SYNC;
-		if ((error = ext2_balloc(oip, lbn, offset, cred, &bp,
-		    aflags)) != 0)
+		error = 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);



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