Module Name:    src
Committed By:   riz
Date:           Wed Jan 25 18:18:46 UTC 2012

Modified Files:
        src/sys/ufs/ffs [netbsd-5]: ffs_inode.c
        src/sys/ufs/lfs [netbsd-5]: lfs_inode.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1702):
        sys/ufs/lfs/lfs_inode.c: revision 1.126
        sys/ufs/ffs/ffs_inode.c: revision 1.108
If ufs_balloc_range() fails, make sure to call ?fs_truncate() to
reset v_writesize to the right value.
If v_writesize is left larger than the allocated blocks, we may have
the same issue as the one described in
http://mail-index.netbsd.org/tech-kern/2010/02/02/msg007156.html


To generate a diff of this commit:
cvs rdiff -u -r1.99.4.1 -r1.99.4.2 src/sys/ufs/ffs/ffs_inode.c
cvs rdiff -u -r1.120.10.1 -r1.120.10.2 src/sys/ufs/lfs/lfs_inode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_inode.c
diff -u src/sys/ufs/ffs/ffs_inode.c:1.99.4.1 src/sys/ufs/ffs/ffs_inode.c:1.99.4.2
--- src/sys/ufs/ffs/ffs_inode.c:1.99.4.1	Mon Feb 22 04:43:46 2010
+++ src/sys/ufs/ffs/ffs_inode.c	Wed Jan 25 18:18:46 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_inode.c,v 1.99.4.1 2010/02/22 04:43:46 snj Exp $	*/
+/*	$NetBSD: ffs_inode.c,v 1.99.4.2 2012/01/25 18:18:46 riz Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.99.4.1 2010/02/22 04:43:46 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.99.4.2 2012/01/25 18:18:46 riz Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -273,8 +273,11 @@ ffs_truncate(struct vnode *ovp, off_t le
 			uvm_vnp_setwritesize(ovp, eob);
 			error = ufs_balloc_range(ovp, osize, eob - osize,
 			    cred, aflag);
-			if (error)
+			if (error) {
+				(void) ffs_truncate(ovp, osize,
+				    ioflag & IO_SYNC, cred);
 				return error;
+			}
 			if (ioflag & IO_SYNC) {
 				mutex_enter(&ovp->v_interlock);
 				VOP_PUTPAGES(ovp,

Index: src/sys/ufs/lfs/lfs_inode.c
diff -u src/sys/ufs/lfs/lfs_inode.c:1.120.10.1 src/sys/ufs/lfs/lfs_inode.c:1.120.10.2
--- src/sys/ufs/lfs/lfs_inode.c:1.120.10.1	Mon Feb 22 04:43:46 2010
+++ src/sys/ufs/lfs/lfs_inode.c	Wed Jan 25 18:18:46 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.c,v 1.120.10.1 2010/02/22 04:43:46 snj Exp $	*/
+/*	$NetBSD: lfs_inode.c,v 1.120.10.2 2012/01/25 18:18:46 riz Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.120.10.1 2010/02/22 04:43:46 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.120.10.2 2012/01/25 18:18:46 riz Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -276,8 +276,11 @@ lfs_truncate(struct vnode *ovp, off_t le
 				uvm_vnp_setwritesize(ovp, eob);
 				error = ufs_balloc_range(ovp, osize,
 				    eob - osize, cred, aflags);
-				if (error)
+				if (error) {
+					(void) lfs_truncate(ovp, osize,
+						    ioflag & IO_SYNC, cred);
 					return error;
+				}
 				if (ioflag & IO_SYNC) {
 					mutex_enter(&ovp->v_interlock);
 					VOP_PUTPAGES(ovp,

Reply via email to