Module Name: src
Committed By: bouyer
Date: Wed Nov 23 19:42:10 UTC 2011
Modified Files:
src/sys/ufs/ffs: ffs_inode.c
src/sys/ufs/lfs: lfs_inode.c
Log Message:
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.107 -r1.108 src/sys/ufs/ffs/ffs_inode.c
cvs rdiff -u -r1.125 -r1.126 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.107 src/sys/ufs/ffs/ffs_inode.c:1.108
--- src/sys/ufs/ffs/ffs_inode.c:1.107 Thu Jun 16 09:21:03 2011
+++ src/sys/ufs/ffs/ffs_inode.c Wed Nov 23 19:42:10 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_inode.c,v 1.107 2011/06/16 09:21:03 hannken Exp $ */
+/* $NetBSD: ffs_inode.c,v 1.108 2011/11/23 19:42:10 bouyer 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.107 2011/06/16 09:21:03 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.108 2011/11/23 19:42:10 bouyer Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -269,8 +269,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.125 src/sys/ufs/lfs/lfs_inode.c:1.126
--- src/sys/ufs/lfs/lfs_inode.c:1.125 Mon Jul 11 08:27:40 2011
+++ src/sys/ufs/lfs/lfs_inode.c Wed Nov 23 19:42:10 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_inode.c,v 1.125 2011/07/11 08:27:40 hannken Exp $ */
+/* $NetBSD: lfs_inode.c,v 1.126 2011/11/23 19:42:10 bouyer 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.125 2011/07/11 08:27:40 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.126 2011/11/23 19:42:10 bouyer 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,