Source-Changes-HG archive

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

[src/netbsd-1-6]: src/sys/ufs/ufs Pull up revision 1.43 (requested by yamt in...



details:   https://anonhg.NetBSD.org/src/rev/abb903fb50f4
branches:  netbsd-1-6
changeset: 529175:abb903fb50f4
user:      lukem <lukem%NetBSD.org@localhost>
date:      Mon Oct 21 01:54:27 2002 +0000

description:
Pull up revision 1.43 (requested by yamt in ticket #926):
make sure to update the vnode's size even if uiomove failed.
otherwise, softdep states can't be flushed later.
ok'ed by Chuck Silvers. fix PR/16670.

diffstat:

 sys/ufs/ufs/ufs_readwrite.c |  35 ++++++++++++++++++++++++++---------
 1 files changed, 26 insertions(+), 9 deletions(-)

diffs (78 lines):

diff -r 27f6d3cf3eee -r abb903fb50f4 sys/ufs/ufs/ufs_readwrite.c
--- a/sys/ufs/ufs/ufs_readwrite.c       Mon Oct 21 01:52:31 2002 +0000
+++ b/sys/ufs/ufs/ufs_readwrite.c       Mon Oct 21 01:54:27 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_readwrite.c,v 1.42 2002/03/25 02:23:56 chs Exp $   */
+/*     $NetBSD: ufs_readwrite.c,v 1.42.4.1 2002/10/21 01:54:27 lukem Exp $     */
 
 /*-
  * Copyright (c) 1993
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.42 2002/03/25 02:23:56 chs Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.42.4.1 2002/10/21 01:54:27 lukem Exp $");
 
 #ifdef LFS_READWRITE
 #define        BLKSIZE(a, b, c)        blksize(a, b, c)
@@ -309,6 +309,9 @@
 
        ubc_alloc_flags = UBC_WRITE;
        while (uio->uio_resid > 0) {
+               boolean_t extending; /* if we're extending a whole block */
+               off_t newoff;
+
                oldoff = uio->uio_offset;
                blkoffset = blkoff(fs, uio->uio_offset);
                bytelen = MIN(fs->fs_bsize - blkoffset, uio->uio_resid);
@@ -320,9 +323,10 @@
                 * since the new blocks will be inaccessible until the write
                 * is complete.
                 */
+               extending = uio->uio_offset >= preallocoff &&
+                   uio->uio_offset < endallocoff;
 
-               if (uio->uio_offset < preallocoff ||
-                   uio->uio_offset >= endallocoff) {
+               if (!extending) {
                        error = ufs_balloc_range(vp, uio->uio_offset, bytelen,
                            cred, aflag);
                        if (error) {
@@ -347,18 +351,31 @@
                win = ubc_alloc(&vp->v_uobj, uio->uio_offset, &bytelen,
                    ubc_alloc_flags);
                error = uiomove(win, bytelen, uio);
+               if (error && extending) {
+                       /*
+                        * if we haven't initialized the pages yet,
+                        * do it now.  it's safe to use memset here
+                        * because we just mapped the pages above.
+                        */
+                       memset(win, 0, bytelen);
+               }
                ubc_release(win, 0);
-               if (error) {
-                       break;
-               }
 
                /*
                 * update UVM's notion of the size now that we've
                 * copied the data into the vnode's pages.
+                *
+                * we should update the size even when uiomove failed.
+                * otherwise ffs_truncate can't flush soft update states.
                 */
 
-               if (vp->v_size < uio->uio_offset) {
-                       uvm_vnp_setsize(vp, uio->uio_offset);
+               newoff = oldoff + bytelen;
+               if (vp->v_size < newoff) {
+                       uvm_vnp_setsize(vp, newoff);
+               }
+
+               if (error) {
+                       break;
                }
 
                /*



Home | Main Index | Thread Index | Old Index