Source-Changes-HG archive

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

[src/trunk]: src The ifile's inode number is constant. (it is always 1)



details:   https://anonhg.NetBSD.org/src/rev/0e7cdeb4d595
branches:  trunk
changeset: 340337:0e7cdeb4d595
user:      dholland <dholland%NetBSD.org@localhost>
date:      Tue Sep 01 06:12:04 2015 +0000

description:
The ifile's inode number is constant. (it is always 1)

Therefore, storing the value in the superblock and reading it out
again is silly and offers the opportunity for it to become corrupted.
So, don't do that (most of the code already didn't) and use the
existing constant instead. Initialize new 32-bit superblocks with
the value for the sake of old userland programs, but don't keep the
value in the 64-bit superblock at all.

(approved by Margo Seltzer)

diffstat:

 libexec/lfs_cleanerd/lfs_cleanerd.c |   6 +++---
 sbin/dump_lfs/lfs_inode.c           |  10 +++++-----
 sbin/fsck_lfs/lfs.c                 |   5 ++---
 sbin/fsck_lfs/pass1.c               |   4 ++--
 sbin/fsck_lfs/pass6.c               |   4 ++--
 sbin/fsck_lfs/setup.c               |   4 ++--
 sbin/newfs_lfs/make_lfs.c           |   6 +++---
 sys/lib/libsa/ufs.c                 |   6 +++---
 sys/ufs/lfs/lfs.h                   |   4 ++--
 sys/ufs/lfs/lfs_accessors.h         |   4 ++--
 sys/ufs/lfs/lfs_debug.c             |  15 ++++++++++-----
 usr.sbin/dumplfs/dumplfs.c          |  15 ++++++++++-----
 12 files changed, 46 insertions(+), 37 deletions(-)

diffs (truncated from 318 to 300 lines):

diff -r a5e531a3c995 -r 0e7cdeb4d595 libexec/lfs_cleanerd/lfs_cleanerd.c
--- a/libexec/lfs_cleanerd/lfs_cleanerd.c       Tue Sep 01 06:11:06 2015 +0000
+++ b/libexec/lfs_cleanerd/lfs_cleanerd.c       Tue Sep 01 06:12:04 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_cleanerd.c,v 1.51 2015/09/01 06:10:16 dholland Exp $    */
+/* $NetBSD: lfs_cleanerd.c,v 1.52 2015/09/01 06:12:04 dholland Exp $    */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -1017,10 +1017,10 @@
                        /*
                         * Look for IFILE blocks, unless this is the Ifile.
                         */
-                       if (bip[i].bi_inode != lfs_sb_getifile(fs)) {
+                       if (bip[i].bi_inode != LFS_IFILE_INUM) {
                                lbn = lfs_sb_getcleansz(fs) + bip[i].bi_inode /
                                                        lfs_sb_getifpb(fs);
-                               *ifc += check_or_add(lfs_sb_getifile(fs), lbn,
+                               *ifc += check_or_add(LFS_IFILE_INUM, lbn,
                                                     bip, bic, &ebip, &ebic);
                        }
                }
diff -r a5e531a3c995 -r 0e7cdeb4d595 sbin/dump_lfs/lfs_inode.c
--- a/sbin/dump_lfs/lfs_inode.c Tue Sep 01 06:11:06 2015 +0000
+++ b/sbin/dump_lfs/lfs_inode.c Tue Sep 01 06:12:04 2015 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: lfs_inode.c,v 1.25 2015/08/12 18:28:00 dholland Exp $ */
+/*      $NetBSD: lfs_inode.c,v 1.26 2015/09/01 06:12:04 dholland Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c      8.6 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: lfs_inode.c,v 1.25 2015/08/12 18:28:00 dholland Exp $");
+__RCSID("$NetBSD: lfs_inode.c,v 1.26 2015/09/01 06:12:04 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -170,7 +170,7 @@
 ino_t
 fs_maxino(void)
 {
-       return ((getino(lfs_sb_getifile(sblock))->dp1.di_size
+       return ((getino(LFS_IFILE_INUM)->dp1.di_size
                   - (lfs_sb_getcleansz(sblock) + lfs_sb_getsegtabsz(sblock))
                   * lfs_sb_getbsize(sblock))
                  / lfs_sb_getbsize(sblock)) * lfs_sb_getifpb(sblock) - 1;
@@ -288,7 +288,7 @@
        unsigned index;
     
        lbn = ino/lfs_sb_getifpb(sblock) + lfs_sb_getcleansz(sblock) + lfs_sb_getsegtabsz(sblock);
-       dp = getino(lfs_sb_getifile(sblock));
+       dp = getino(LFS_IFILE_INUM);
        /* XXX this is foolish */
        if (sblock->lfs_is64) {
                ldp = (union lfs_dinode *)&dp->dlp64;
@@ -340,7 +340,7 @@
        union lfs_dinode *dp;
        ino_t inum2;
 
-       if(inum == lfs_sb_getifile(sblock)) {
+       if (inum == LFS_IFILE_INUM) {
                /* Load the ifile inode if not already */
                inum2 = sblock->lfs_is64 ?
                        ifile_dinode.dlp64.di_inumber :
diff -r a5e531a3c995 -r 0e7cdeb4d595 sbin/fsck_lfs/lfs.c
--- a/sbin/fsck_lfs/lfs.c       Tue Sep 01 06:11:06 2015 +0000
+++ b/sbin/fsck_lfs/lfs.c       Tue Sep 01 06:12:04 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs.c,v 1.59 2015/09/01 06:10:16 dholland Exp $ */
+/* $NetBSD: lfs.c,v 1.60 2015/09/01 06:12:04 dholland Exp $ */
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -559,8 +559,7 @@
        else
                lfs_sb_setidaddr(fs, idaddr);
        /* NB: If dummy_read!=0, idaddr==0 here so we get a fake inode. */
-       fs->lfs_ivnode = lfs_raw_vget(fs,
-               (dummy_read ? LFS_IFILE_INUM : lfs_sb_getifile(fs)),
+       fs->lfs_ivnode = lfs_raw_vget(fs, LFS_IFILE_INUM,
                devvp->v_fd, idaddr);
        if (fs->lfs_ivnode == NULL)
                return NULL;
diff -r a5e531a3c995 -r 0e7cdeb4d595 sbin/fsck_lfs/pass1.c
--- a/sbin/fsck_lfs/pass1.c     Tue Sep 01 06:11:06 2015 +0000
+++ b/sbin/fsck_lfs/pass1.c     Tue Sep 01 06:12:04 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass1.c,v 1.42 2015/08/12 18:28:00 dholland Exp $   */
+/* $NetBSD: pass1.c,v 1.43 2015/09/01 06:12:04 dholland Exp $   */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -112,7 +112,7 @@
        for (i = 0; i < maxino; i++) {
                dins[i] = emalloc(sizeof(**dins));
                dins[i]->ino = i;
-               if (i == lfs_sb_getifile(fs))
+               if (i == LFS_IFILE_INUM)
                        dins[i]->daddr = lfs_sb_getidaddr(fs);
                else {
                        LFS_IENTRY(ifp, fs, i, bp);
diff -r a5e531a3c995 -r 0e7cdeb4d595 sbin/fsck_lfs/pass6.c
--- a/sbin/fsck_lfs/pass6.c     Tue Sep 01 06:11:06 2015 +0000
+++ b/sbin/fsck_lfs/pass6.c     Tue Sep 01 06:12:04 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass6.c,v 1.44 2015/09/01 06:08:37 dholland Exp $   */
+/* $NetBSD: pass6.c,v 1.45 2015/09/01 06:12:04 dholland Exp $   */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -667,7 +667,7 @@
                        for (k = 0; k < LFS_INOPB(fs); k++) {
                                dp = DINO_IN_BLOCK(fs, ibbuf, k);
                                if (lfs_dino_getinumber(fs, dp) == 0 ||
-                                   lfs_dino_getinumber(fs, dp) == lfs_sb_getifile(fs))
+                                   lfs_dino_getinumber(fs, dp) == LFS_IFILE_INUM)
                                        continue;
                                /* Basic sanity checks */
                                if (lfs_dino_getnlink(fs, dp) < 0 
diff -r a5e531a3c995 -r 0e7cdeb4d595 sbin/fsck_lfs/setup.c
--- a/sbin/fsck_lfs/setup.c     Tue Sep 01 06:11:06 2015 +0000
+++ b/sbin/fsck_lfs/setup.c     Tue Sep 01 06:12:04 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: setup.c,v 1.56 2015/09/01 06:08:37 dholland Exp $ */
+/* $NetBSD: setup.c,v 1.57 2015/09/01 06:12:04 dholland Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -438,7 +438,7 @@
        }
 
        /* Initialize Ifile entry */
-       din_table[lfs_sb_getifile(fs)] = lfs_sb_getidaddr(fs);
+       din_table[LFS_IFILE_INUM] = lfs_sb_getidaddr(fs);
        seg_table[lfs_dtosn(fs, lfs_sb_getidaddr(fs))].su_nbytes += DINOSIZE(fs);
 
 #ifndef VERBOSE_BLOCKMAP
diff -r a5e531a3c995 -r 0e7cdeb4d595 sbin/newfs_lfs/make_lfs.c
--- a/sbin/newfs_lfs/make_lfs.c Tue Sep 01 06:11:06 2015 +0000
+++ b/sbin/newfs_lfs/make_lfs.c Tue Sep 01 06:12:04 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make_lfs.c,v 1.45 2015/09/01 06:10:16 dholland Exp $   */
+/*     $NetBSD: make_lfs.c,v 1.46 2015/09/01 06:12:04 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.45 2015/09/01 06:10:16 dholland Exp $");
+__RCSID("$NetBSD: make_lfs.c,v 1.46 2015/09/01 06:12:04 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -189,7 +189,7 @@
                .dlfs_avail =           0,
                .dlfs_idaddr =          0,
                .dlfs_uinodes =         0,
-               .dlfs_ifile =           LFS_IFILE_INUM,
+               .dlfs_unused_0 =        0,
                .dlfs_lastseg =         0,
                .dlfs_nextseg =         0,
                .dlfs_curseg =          0,
diff -r a5e531a3c995 -r 0e7cdeb4d595 sys/lib/libsa/ufs.c
--- a/sys/lib/libsa/ufs.c       Tue Sep 01 06:11:06 2015 +0000
+++ b/sys/lib/libsa/ufs.c       Tue Sep 01 06:12:04 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs.c,v 1.72 2015/08/12 18:28:01 dholland Exp $        */
+/*     $NetBSD: ufs.c,v 1.73 2015/09/01 06:12:04 dholland Exp $        */
 
 /*-
  * Copyright (c) 1993
@@ -218,7 +218,7 @@
        size_t entsize;
        int rc;
 
-       rc = read_inode(lfs_sb_getifile(fs), f);
+       rc = read_inode(LFS_IFILE_INUM, f);
        if (rc)
                return rc;
 
@@ -260,7 +260,7 @@
 #endif
 
 #ifdef LIBSA_LFS
-       if (inumber == lfs_sb_getifile(fs))
+       if (inumber == LFS_IFILE_INUM)
                inode_sector = FSBTODB(fs, lfs_sb_getidaddr(fs));
        else if ((rc = find_inode_sector(inumber, f, &inode_sector)) != 0)
                return rc;
diff -r a5e531a3c995 -r 0e7cdeb4d595 sys/ufs/lfs/lfs.h
--- a/sys/ufs/lfs/lfs.h Tue Sep 01 06:11:06 2015 +0000
+++ b/sys/ufs/lfs/lfs.h Tue Sep 01 06:12:04 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs.h,v 1.182 2015/09/01 06:11:06 dholland Exp $       */
+/*     $NetBSD: lfs.h,v 1.183 2015/09/01 06:12:04 dholland Exp $       */
 
 /*  from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp  */
 /*  from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp  */
@@ -795,7 +795,7 @@
        int64_t   dlfs_avail;     /* 64: blocks available for writing */
        int64_t   dlfs_idaddr;    /* 72: inode file disk address */
        int32_t   dlfs_uinodes;   /* 80: inodes in cache not yet on disk */
-       u_int32_t dlfs_ifile;     /* 84: inode file inode number */
+       u_int32_t dlfs_unused_0;  /* 84: not used */
        int64_t   dlfs_lastseg;   /* 88: address of last segment written */
        int64_t   dlfs_nextseg;   /* 96: address of next segment to write */
        int64_t   dlfs_curseg;    /* 104: current segment being written */
diff -r a5e531a3c995 -r 0e7cdeb4d595 sys/ufs/lfs/lfs_accessors.h
--- a/sys/ufs/lfs/lfs_accessors.h       Tue Sep 01 06:11:06 2015 +0000
+++ b/sys/ufs/lfs/lfs_accessors.h       Tue Sep 01 06:12:04 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_accessors.h,v 1.18 2015/09/01 06:11:06 dholland Exp $      */
+/*     $NetBSD: lfs_accessors.h,v 1.19 2015/09/01 06:12:04 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  */
@@ -925,7 +925,7 @@
 LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, avail);
 LFS_DEF_SB_ACCESSOR(int32_t, uinodes);
 LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, idaddr);
-LFS_DEF_SB_ACCESSOR(u_int32_t, ifile);
+LFS_DEF_SB_ACCESSOR_32ONLY(u_int32_t, ifile, LFS_IFILE_INUM);
 LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, lastseg);
 LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, nextseg);
 LFS_DEF_SB_ACCESSOR_FULL(int64_t, int32_t, curseg);
diff -r a5e531a3c995 -r 0e7cdeb4d595 sys/ufs/lfs/lfs_debug.c
--- a/sys/ufs/lfs/lfs_debug.c   Tue Sep 01 06:11:06 2015 +0000
+++ b/sys/ufs/lfs/lfs_debug.c   Tue Sep 01 06:12:04 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_debug.c,v 1.53 2015/09/01 06:11:06 dholland Exp $  */
+/*     $NetBSD: lfs_debug.c,v 1.54 2015/09/01 06:12:04 dholland 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_debug.c,v 1.53 2015/09/01 06:11:06 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_debug.c,v 1.54 2015/09/01 06:12:04 dholland Exp $");
 
 #ifdef DEBUG
 
@@ -176,10 +176,9 @@
        printf("\n");
 
        printf("Checkpoint Info\n");
-       printf("%s%ju\t%s%jx\t%s%d\n",
+       printf("%s%ju\t%s%jx\n",
               "freehd   ", (uintmax_t)lfs_sb_getfreehd(lfsp),
-              "idaddr   ", (intmax_t)lfs_sb_getidaddr(lfsp),
-              "ifile    ", lfs_sb_getifile(lfsp));
+              "idaddr   ", (intmax_t)lfs_sb_getidaddr(lfsp));
        printf("%s%jx\t%s%ju\t%s%jx\t%s%jx\t%s%jx\t%s%jx\n",
               "bfree    ", (intmax_t)lfs_sb_getbfree(lfsp),
               "nfiles   ", (uintmax_t)lfs_sb_getnfiles(lfsp),
@@ -188,6 +187,12 @@
               "curseg   ", (intmax_t)lfs_sb_getcurseg(lfsp),
               "offset   ", (intmax_t)lfs_sb_getoffset(lfsp));
        printf("tstamp   %llx\n", (long long)lfs_sb_gettstamp(lfsp));
+
+       if (!lfsp->lfs_is64) {
+               printf("32-bit only derived or constant fields\n");
+               printf("%s%u\n",
+                      "ifile    ", lfs_sb_getifile(lfsp));
+       }
 }
 
 void
diff -r a5e531a3c995 -r 0e7cdeb4d595 usr.sbin/dumplfs/dumplfs.c
--- a/usr.sbin/dumplfs/dumplfs.c        Tue Sep 01 06:11:06 2015 +0000
+++ b/usr.sbin/dumplfs/dumplfs.c        Tue Sep 01 06:12:04 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dumplfs.c,v 1.56 2015/09/01 06:11:06 dholland Exp $    */
+/*     $NetBSD: dumplfs.c,v 1.57 2015/09/01 06:12:04 dholland Exp $    */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "@(#)dumplfs.c  8.5 (Berkeley) 5/24/95";
 #else
-__RCSID("$NetBSD: dumplfs.c,v 1.56 2015/09/01 06:11:06 dholland Exp $");
+__RCSID("$NetBSD: dumplfs.c,v 1.57 2015/09/01 06:12:04 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -816,10 +816,9 @@
        (void)printf("\n");
        
        (void)printf("  Checkpoint Info\n");
-       (void)printf("    %s%-10ju  %s0x%-8jx  %s%-10ju\n",
+       (void)printf("    %s%-10ju  %s0x%-8jx\n",
                     "freehd   ", (uintmax_t)lfs_sb_getfreehd(lfsp),
-                    "idaddr   ", (intmax_t)lfs_sb_getidaddr(lfsp),



Home | Main Index | Thread Index | Old Index