Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs pull in a bit more FreeBSD code to allow specifying ...



details:   https://anonhg.NetBSD.org/src/rev/4835dd858832
branches:  trunk
changeset: 936340:4835dd858832
user:      chs <chs%NetBSD.org@localhost>
date:      Sun Jul 26 00:21:24 2020 +0000

description:
pull in a bit more FreeBSD code to allow specifying truncation of
the regular bmap (IO_NORMAL) independently of the extattr bmap (IO_EXT).
fixes fs corruption when removing extattrs in UFS2.

diffstat:

 sys/ufs/ffs/ffs_inode.c |  20 ++++++++++++++------
 sys/ufs/ufs/ufs_inode.c |   6 +++---
 2 files changed, 17 insertions(+), 9 deletions(-)

diffs (87 lines):

diff -r dcafaaa09a56 -r 4835dd858832 sys/ufs/ffs/ffs_inode.c
--- a/sys/ufs/ffs/ffs_inode.c   Sun Jul 26 00:20:13 2020 +0000
+++ b/sys/ufs/ffs/ffs_inode.c   Sun Jul 26 00:21:24 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_inode.c,v 1.129 2020/05/02 22:11:16 christos Exp $ */
+/*     $NetBSD: ffs_inode.c,v 1.130 2020/07/26 00:21:24 chs 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.129 2020/05/02 22:11:16 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.130 2020/07/26 00:21:24 chs Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -232,6 +232,14 @@
        if (length < 0)
                return (EINVAL);
 
+       /*
+        * Historically clients did not have to specify which data
+        * they were truncating. So, if not specified, we assume
+        * traditional behavior, e.g., just the normal data.
+        */
+       if ((ioflag & (IO_EXT | IO_NORMAL)) == 0)
+               ioflag |= IO_NORMAL;
+
        fs = oip->i_fs;
 #define i_din2 i_din.ffs2_din
        extblocks = 0;
@@ -267,6 +275,8 @@
                        extblocks = 0;
                }
        }
+       if ((ioflag & IO_NORMAL) == 0)
+               return (0);
        if (ovp->v_type == VLNK &&
            (oip->i_size < ump->um_maxsymlinklen ||
             (ump->um_maxsymlinklen == 0 && datablocks == 0))) {
@@ -376,8 +386,7 @@
                }
        }
 
-       if (!(ioflag & IO_EXT))
-               genfs_node_wrlock(ovp);
+       genfs_node_wrlock(ovp);
        oip->i_size = length;
        DIP_ASSIGN(oip, size, length);
        uvm_vnp_setsize(ovp, length);
@@ -586,8 +595,7 @@
        oip->i_size = length;
        DIP_ASSIGN(oip, size, length);
        DIP_ADD(oip, blocks, -blocksreleased);
-       if (!(ioflag & IO_EXT))
-               genfs_node_unlock(ovp);
+       genfs_node_unlock(ovp);
        oip->i_flag |= IN_CHANGE;
        UFS_WAPBL_UPDATE(ovp, NULL, NULL, 0);
 #if defined(QUOTA) || defined(QUOTA2)
diff -r dcafaaa09a56 -r 4835dd858832 sys/ufs/ufs/ufs_inode.c
--- a/sys/ufs/ufs/ufs_inode.c   Sun Jul 26 00:20:13 2020 +0000
+++ b/sys/ufs/ufs/ufs_inode.c   Sun Jul 26 00:21:24 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_inode.c,v 1.110 2020/04/18 19:18:34 christos Exp $ */
+/*     $NetBSD: ufs_inode.c,v 1.111 2020/07/26 00:21:24 chs Exp $      */
 
 /*
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.110 2020/04/18 19:18:34 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.111 2020/07/26 00:21:24 chs Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -327,5 +327,5 @@
 
        if (isize == 0)
                return 0;
-       return ufs_truncate_retry(vp, IO_EXT, 0, NOCRED);
+       return ufs_truncate_retry(vp, IO_NORMAL | IO_EXT, 0, NOCRED);
 }



Home | Main Index | Thread Index | Old Index