Source-Changes-HG archive

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

[src/trunk]: src Oops; LFS_DIRECTSIZ() is going to need the fs as an argument.



details:   https://anonhg.NetBSD.org/src/rev/ca17ef382105
branches:  trunk
changeset: 810769:ca17ef382105
user:      dholland <dholland%NetBSD.org@localhost>
date:      Mon Sep 21 01:22:18 2015 +0000

description:
Oops; LFS_DIRECTSIZ() is going to need the fs as an argument.

Also, it turns out that dirhash needs a compile-time-constant version
of LFS_DIRECTSIZ(LFS_MAXNAMLEN+1), independent of 64-vs-32, so create
LFS_MAXDIRENTRYSIZE for this. Sigh.

diffstat:

 sbin/fsck_lfs/dir.c         |  12 ++++++------
 sbin/fsck_lfs/pass2.c       |   6 +++---
 sbin/newfs_lfs/make_lfs.c   |   6 +++---
 sys/ufs/lfs/lfs_accessors.h |  14 +++++++++++---
 sys/ufs/lfs/lfs_rename.c    |   6 +++---
 sys/ufs/lfs/lfs_vnops.c     |  12 ++++++------
 sys/ufs/lfs/ulfs_dirhash.c  |   6 +++---
 sys/ufs/lfs/ulfs_dirhash.h  |   6 +++---
 sys/ufs/lfs/ulfs_lookup.c   |   8 ++++----
 sys/ufs/lfs/ulfs_vnops.c    |   6 +++---
 10 files changed, 45 insertions(+), 37 deletions(-)

diffs (truncated from 312 to 300 lines):

diff -r 3e1fe55cfe58 -r ca17ef382105 sbin/fsck_lfs/dir.c
--- a/sbin/fsck_lfs/dir.c       Sun Sep 20 17:45:25 2015 +0000
+++ b/sbin/fsck_lfs/dir.c       Mon Sep 21 01:22:18 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.44 2015/09/20 04:51:43 dholland Exp $     */
+/* $NetBSD: dir.c,v 1.45 2015/09/21 01:22:18 dholland Exp $     */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -376,7 +376,7 @@
 
        /* figure the length needed for id_name */
        namlen = strlen(idesc->id_name);
-       newreclen = LFS_DIRECTSIZ(namlen);
+       newreclen = LFS_DIRECTSIZ(fs, namlen);
 
        /* find the minimum record length for the existing name */
        if (lfs_dir_getino(fs, dirp) != 0)
@@ -688,19 +688,19 @@
        dirp = (struct lfs_dirheader *)bp->b_data;
        /* . */
        lfs_dir_setino(fs, dirp, ino);
-       lfs_dir_setreclen(fs, dirp, LFS_DIRECTSIZ(1));
+       lfs_dir_setreclen(fs, dirp, LFS_DIRECTSIZ(fs, 1));
        lfs_dir_settype(fs, dirp, LFS_DT_DIR);
        lfs_dir_setnamlen(fs, dirp, 1);
        lfs_copydirname(fs, lfs_dir_nameptr(fs, dirp), ".", 1,
-                       LFS_DIRECTSIZ(1));
+                       LFS_DIRECTSIZ(fs, 1));
        /* .. */
        dirp = LFS_NEXTDIR(fs, dirp);
        lfs_dir_setino(fs, dirp, parent);
-       lfs_dir_setreclen(fs, dirp, LFS_DIRBLKSIZ - LFS_DIRECTSIZ(1));
+       lfs_dir_setreclen(fs, dirp, LFS_DIRBLKSIZ - LFS_DIRECTSIZ(fs, 1));
        lfs_dir_settype(fs, dirp, LFS_DT_DIR);
        lfs_dir_setnamlen(fs, dirp, 2);
        lfs_copydirname(fs, lfs_dir_nameptr(fs, dirp), "..", 2,
-                       LFS_DIRBLKSIZ - LFS_DIRECTSIZ(1));
+                       LFS_DIRBLKSIZ - LFS_DIRECTSIZ(fs, 1));
        for (cp = &bp->b_data[LFS_DIRBLKSIZ];
            cp < &bp->b_data[lfs_sb_getfsize(fs)];
            cp += LFS_DIRBLKSIZ) {
diff -r 3e1fe55cfe58 -r ca17ef382105 sbin/fsck_lfs/pass2.c
--- a/sbin/fsck_lfs/pass2.c     Sun Sep 20 17:45:25 2015 +0000
+++ b/sbin/fsck_lfs/pass2.c     Mon Sep 21 01:22:18 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass2.c,v 1.32 2015/09/15 15:02:25 dholland Exp $   */
+/* $NetBSD: pass2.c,v 1.33 2015/09/21 01:22:18 dholland Exp $   */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -247,7 +247,7 @@
        lfs_dir_setino(fs, &proto, idesc->id_number);
        lfs_dir_settype(fs, &proto, LFS_DT_DIR);
        lfs_dir_setnamlen(fs, &proto, 1);
-       entrysize = LFS_DIRECTSIZ(1);
+       entrysize = LFS_DIRECTSIZ(fs, 1);
        lfs_dir_setreclen(fs, &proto, entrysize);
        if (lfs_dir_getino(fs, dirp) != 0 && strcmp(lfs_dir_nameptr(fs, dirp), "..") != 0) {
                pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n",
@@ -283,7 +283,7 @@
        lfs_dir_setino(fs, &proto, inp->i_parent);
        lfs_dir_settype(fs, &proto, LFS_DT_DIR);
        lfs_dir_setnamlen(fs, &proto, 2);
-       entrysize = LFS_DIRECTSIZ(2);
+       entrysize = LFS_DIRECTSIZ(fs, 2);
        lfs_dir_setreclen(fs, &proto, entrysize);
        if (idesc->id_entryno == 0) {
                n = LFS_DIRSIZ(fs, dirp);
diff -r 3e1fe55cfe58 -r ca17ef382105 sbin/newfs_lfs/make_lfs.c
--- a/sbin/newfs_lfs/make_lfs.c Sun Sep 20 17:45:25 2015 +0000
+++ b/sbin/newfs_lfs/make_lfs.c Mon Sep 21 01:22:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make_lfs.c,v 1.54 2015/09/15 15:02:25 dholland Exp $   */
+/*     $NetBSD: make_lfs.c,v 1.55 2015/09/21 01:22:18 dholland Exp $   */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
 #if 0
 static char sccsid[] = "@(#)lfs.c      8.5 (Berkeley) 5/24/95";
 #else
-__RCSID("$NetBSD: make_lfs.c,v 1.54 2015/09/15 15:02:25 dholland Exp $");
+__RCSID("$NetBSD: make_lfs.c,v 1.55 2015/09/21 01:22:18 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -366,7 +366,7 @@
        ep = bufp;
        for (i = 0; i < numentries; i++) {
                namlen = strlen(protodir[i].dp_name);
-               reclen = LFS_DIRECTSIZ(namlen);
+               reclen = LFS_DIRECTSIZ(fs, namlen);
                if (spaceleft < reclen)
                        fatal("%s: %s", special, "directory too big");
 
diff -r 3e1fe55cfe58 -r ca17ef382105 sys/ufs/lfs/lfs_accessors.h
--- a/sys/ufs/lfs/lfs_accessors.h       Sun Sep 20 17:45:25 2015 +0000
+++ b/sys/ufs/lfs/lfs_accessors.h       Mon Sep 21 01:22:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_accessors.h,v 1.29 2015/09/20 04:51:43 dholland Exp $      */
+/*     $NetBSD: lfs_accessors.h,v 1.30 2015/09/21 01:22:18 dholland Exp $      */
 
 /*  from NetBSD: lfs.h,v 1.165 2015/07/24 06:59:32 dholland Exp  */
 /*  from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp  */
@@ -222,9 +222,17 @@
  * without the d_name field, plus enough space for the name with a terminating
  * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
  */
-#define        LFS_DIRECTSIZ(namlen) \
+#define        LFS_DIRECTSIZ(fs, namlen) \
        (sizeof(struct lfs_dirheader) + (((namlen)+1 + 3) &~ 3))
 
+/*
+ * The size of the largest possible directory entry. This is
+ * used by ulfs_dirhash to figure the size of an array, so we
+ * need a single constant value true for both lfs32 and lfs64.
+ */
+#define LFS_MAXDIRENTRYSIZE \
+       (sizeof(struct lfs_dirheader) + (((LFS_MAXNAMLEN+1)+1 + 3) & ~3))
+
 #if (BYTE_ORDER == LITTLE_ENDIAN)
 #define LFS_OLDDIRSIZ(oldfmt, dp, needswap)    \
     (((oldfmt) && !(needswap)) ?               \
@@ -235,7 +243,7 @@
     LFS_DIRECTSIZ((dp)->d_type) : LFS_DIRECTSIZ((dp)->d_namlen))
 #endif
 
-#define LFS_DIRSIZ(fs, dp) LFS_DIRECTSIZ(lfs_dir_getnamlen(fs, dp))
+#define LFS_DIRSIZ(fs, dp) LFS_DIRECTSIZ(fs, lfs_dir_getnamlen(fs, dp))
 
 /* Constants for the first argument of LFS_OLDDIRSIZ */
 #define LFS_OLDDIRFMT  1
diff -r 3e1fe55cfe58 -r ca17ef382105 sys/ufs/lfs/lfs_rename.c
--- a/sys/ufs/lfs/lfs_rename.c  Sun Sep 20 17:45:25 2015 +0000
+++ b/sys/ufs/lfs/lfs_rename.c  Mon Sep 21 01:22:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_rename.c,v 1.14 2015/09/20 04:51:43 dholland Exp $ */
+/*     $NetBSD: lfs_rename.c,v 1.15 2015/09/21 01:22:18 dholland Exp $ */
 /*  from NetBSD: ufs_rename.c,v 1.6 2013/01/22 09:39:18 dholland Exp  */
 
 /*-
@@ -89,7 +89,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.14 2015/09/20 04:51:43 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.15 2015/09/21 01:22:18 dholland Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -942,7 +942,7 @@
                 * the position is the record length of the . entry,
                 * namely LFS_DIRECTSIZ(1).
                 */
-               position = LFS_DIRECTSIZ(1);
+               position = LFS_DIRECTSIZ(fs, 1);
                error = ulfs_dirrewrite(VTOI(fvp), position,
                    VTOI(fdvp), VTOI(tdvp)->i_number, LFS_DT_DIR, 0, IN_CHANGE);
 #if 0          /* XXX This branch was not in ulfs_rename! */
diff -r 3e1fe55cfe58 -r ca17ef382105 sys/ufs/lfs/lfs_vnops.c
--- a/sys/ufs/lfs/lfs_vnops.c   Sun Sep 20 17:45:25 2015 +0000
+++ b/sys/ufs/lfs/lfs_vnops.c   Mon Sep 21 01:22:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_vnops.c,v 1.291 2015/09/20 04:51:43 dholland Exp $ */
+/*     $NetBSD: lfs_vnops.c,v 1.292 2015/09/21 01:22:18 dholland Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.291 2015/09/20 04:51:43 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.292 2015/09/21 01:22:18 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -942,19 +942,19 @@
 
        /* . */
        lfs_dir_setino(fs, dirp, ip->i_number);
-       lfs_dir_setreclen(fs, dirp, LFS_DIRECTSIZ(1));
+       lfs_dir_setreclen(fs, dirp, LFS_DIRECTSIZ(fs, 1));
        lfs_dir_settype(fs, dirp, LFS_DT_DIR);
        lfs_dir_setnamlen(fs, dirp, 1);
        lfs_copydirname(fs, lfs_dir_nameptr(fs, dirp), ".", 1,
-                       LFS_DIRECTSIZ(1));
+                       LFS_DIRECTSIZ(fs, 1));
        dirp = LFS_NEXTDIR(fs, dirp);
        /* .. */
        lfs_dir_setino(fs, dirp, dp->i_number);
-       lfs_dir_setreclen(fs, dirp, dirblksiz - LFS_DIRECTSIZ(1));
+       lfs_dir_setreclen(fs, dirp, dirblksiz - LFS_DIRECTSIZ(fs, 1));
        lfs_dir_settype(fs, dirp, LFS_DT_DIR);
        lfs_dir_setnamlen(fs, dirp, 2);
        lfs_copydirname(fs, lfs_dir_nameptr(fs, dirp), "..", 2,
-                       dirblksiz - LFS_DIRECTSIZ(1));
+                       dirblksiz - LFS_DIRECTSIZ(fs, 1));
 
        /*
         * Directory set up; now install its entry in the parent directory.
diff -r 3e1fe55cfe58 -r ca17ef382105 sys/ufs/lfs/ulfs_dirhash.c
--- a/sys/ufs/lfs/ulfs_dirhash.c        Sun Sep 20 17:45:25 2015 +0000
+++ b/sys/ufs/lfs/ulfs_dirhash.c        Mon Sep 21 01:22:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ulfs_dirhash.c,v 1.12 2015/09/15 15:02:25 dholland Exp $       */
+/*     $NetBSD: ulfs_dirhash.c,v 1.13 2015/09/21 01:22:18 dholland Exp $       */
 /*  from NetBSD: ufs_dirhash.c,v 1.34 2009/10/05 23:48:08 rmind Exp  */
 
 /*
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ulfs_dirhash.c,v 1.12 2015/09/15 15:02:25 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_dirhash.c,v 1.13 2015/09/21 01:22:18 dholland Exp $");
 
 /*
  * This implements a hash-based lookup scheme for ULFS directories.
@@ -148,7 +148,7 @@
        vp = ip->i_vnode;
        /* Allocate 50% more entries than this dir size could ever need. */
        KASSERT(ip->i_size >= dirblksiz);
-       nslots = ip->i_size / LFS_DIRECTSIZ(1);
+       nslots = ip->i_size / LFS_DIRECTSIZ(fs, 1);
        nslots = (nslots * 3 + 1) / 2;
        narrays = howmany(nslots, DH_NBLKOFF);
        nslots = narrays * DH_NBLKOFF;
diff -r 3e1fe55cfe58 -r ca17ef382105 sys/ufs/lfs/ulfs_dirhash.h
--- a/sys/ufs/lfs/ulfs_dirhash.h        Sun Sep 20 17:45:25 2015 +0000
+++ b/sys/ufs/lfs/ulfs_dirhash.h        Mon Sep 21 01:22:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ulfs_dirhash.h,v 1.6 2015/09/15 15:02:25 dholland Exp $        */
+/*     $NetBSD: ulfs_dirhash.h,v 1.7 2015/09/21 01:22:18 dholland Exp $        */
 /*  from NetBSD: dirhash.h,v 1.6 2008/06/04 11:33:19 ad Exp  */
 
 /*
@@ -48,8 +48,8 @@
 #define DIRHASH_DEL    (-2)    /* deleted entry; may be part of chain */
 
 #define DIRALIGN       4
-#define DH_NFSTATS     (LFS_DIRECTSIZ(LFS_MAXNAMLEN + 1) / DIRALIGN)
-                                /* max DIRALIGN words in a directory entry */
+#define DH_NFSTATS     (LFS_MAXDIRENTRYSIZE / DIRALIGN)
+                        /* max DIRALIGN words in a directory entry */
 
 /*
  * Dirhash uses a score mechanism to achieve a hybrid between a
diff -r 3e1fe55cfe58 -r ca17ef382105 sys/ufs/lfs/ulfs_lookup.c
--- a/sys/ufs/lfs/ulfs_lookup.c Sun Sep 20 17:45:25 2015 +0000
+++ b/sys/ufs/lfs/ulfs_lookup.c Mon Sep 21 01:22:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ulfs_lookup.c,v 1.32 2015/09/15 15:02:25 dholland Exp $        */
+/*     $NetBSD: ulfs_lookup.c,v 1.33 2015/09/21 01:22:18 dholland Exp $        */
 /*  from NetBSD: ufs_lookup.c,v 1.122 2013/01/22 09:39:18 dholland Exp  */
 
 /*
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.32 2015/09/15 15:02:25 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.33 2015/09/21 01:22:18 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lfs.h"
@@ -221,7 +221,7 @@
        slotfreespace = slotsize = slotneeded = 0;
        if ((nameiop == CREATE || nameiop == RENAME) && (flags & ISLASTCN)) {
                slotstatus = NONE;
-               slotneeded = LFS_DIRECTSIZ(cnp->cn_namelen);
+               slotneeded = LFS_DIRECTSIZ(fs, cnp->cn_namelen);
        }
 
        /*
@@ -783,7 +783,7 @@
        cr = cnp->cn_cred;
 
        dp = VTOI(dvp);
-       newentrysize = LFS_DIRECTSIZ(namlen);
+       newentrysize = LFS_DIRECTSIZ(fs, namlen);
 
        if (ulr->ulr_count == 0) {
                /*
diff -r 3e1fe55cfe58 -r ca17ef382105 sys/ufs/lfs/ulfs_vnops.c
--- a/sys/ufs/lfs/ulfs_vnops.c  Sun Sep 20 17:45:25 2015 +0000
+++ b/sys/ufs/lfs/ulfs_vnops.c  Mon Sep 21 01:22:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ulfs_vnops.c,v 1.32 2015/09/15 15:02:25 dholland Exp $ */
+/*     $NetBSD: ulfs_vnops.c,v 1.33 2015/09/21 01:22:18 dholland Exp $ */
 /*  from NetBSD: ufs_vnops.c,v 1.213 2013/06/08 05:47:02 kardel Exp  */
 
 /*-
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.32 2015/09/15 15:02:25 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.33 2015/09/21 01:22:18 dholland Exp $");



Home | Main Index | Thread Index | Old Index