Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs If ufs_balloc_range() fails, make sure to call ?fs_t...



details:   https://anonhg.NetBSD.org/src/rev/e24ecc214f1e
branches:  trunk
changeset: 771501:e24ecc214f1e
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Wed Nov 23 19:42:10 2011 +0000

description:
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

diffstat:

 sys/ufs/ffs/ffs_inode.c |  9 ++++++---
 sys/ufs/lfs/lfs_inode.c |  9 ++++++---
 2 files changed, 12 insertions(+), 6 deletions(-)

diffs (62 lines):

diff -r d854359abdcd -r e24ecc214f1e sys/ufs/ffs/ffs_inode.c
--- a/sys/ufs/ffs/ffs_inode.c   Wed Nov 23 19:41:50 2011 +0000
+++ b/sys/ufs/ffs/ffs_inode.c   Wed Nov 23 19:42:10 2011 +0000
@@ -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 @@
                        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,
diff -r d854359abdcd -r e24ecc214f1e sys/ufs/lfs/lfs_inode.c
--- a/sys/ufs/lfs/lfs_inode.c   Wed Nov 23 19:41:50 2011 +0000
+++ b/sys/ufs/lfs/lfs_inode.c   Wed Nov 23 19:42:10 2011 +0000
@@ -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 @@
                                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,



Home | Main Index | Thread Index | Old Index