Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/puffs Update file size after write without metadata f...



details:   https://anonhg.NetBSD.org/src/rev/94b7fa1b6f65
branches:  trunk
changeset: 806454:94b7fa1b6f65
user:      manu <manu%NetBSD.org@localhost>
date:      Wed Feb 25 14:08:45 2015 +0000

description:
Update file size after write without metadata flush

If we do not use metadata flush, we must make sure the size is updated
in the filesystem after a write, otherwise the next GETATTR will get us
a stale value and the file will be truncated.

diffstat:

 sys/fs/puffs/puffs_vnops.c |  21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diffs (42 lines):

diff -r 10fe6f494b95 -r 94b7fa1b6f65 sys/fs/puffs/puffs_vnops.c
--- a/sys/fs/puffs/puffs_vnops.c        Wed Feb 25 14:02:43 2015 +0000
+++ b/sys/fs/puffs/puffs_vnops.c        Wed Feb 25 14:08:45 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_vnops.c,v 1.200 2015/02/15 20:21:29 manu Exp $   */
+/*     $NetBSD: puffs_vnops.c,v 1.201 2015/02/25 14:08:45 manu Exp $   */
 
 /*
  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.200 2015/02/15 20:21:29 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.201 2015/02/25 14:08:45 manu Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -2551,6 +2551,23 @@
        uflags |= PUFFS_UPDATEMTIME;
        puffs_updatenode(VPTOPP(vp), uflags, vp->v_size);
 
+       /*
+        * If we do not use meta flush, we need to update the
+        * filesystem now, otherwise we will get a stale value
+        * on the next GETATTR
+        */
+       if (!PUFFS_USE_METAFLUSH(pmp) && (uflags & PUFFS_UPDATESIZE)) {
+               struct vattr va;
+               int ret;
+
+               vattr_null(&va);
+               va.va_size = vp->v_size;
+               ret = dosetattr(vp, &va, FSCRED, 0);
+               if (ret) {
+                       DPRINTF(("dosetattr set size to %lld failed: %d\n",
+                                vp->v_size, ret));
+               }
+       }
        mutex_exit(&pn->pn_sizemtx);
        return error;
 }



Home | Main Index | Thread Index | Old Index