Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/lfs don't use daddr_t for segment summary since it's...



details:   https://anonhg.NetBSD.org/src/rev/23c106b26a79
branches:  trunk
changeset: 542452:23c106b26a79
user:      yamt <yamt%NetBSD.org@localhost>
date:      Wed Jan 29 13:14:33 2003 +0000

description:
don't use daddr_t for segment summary since it's an on-disk structure.

diffstat:

 sys/ufs/lfs/lfs.h         |   4 +++-
 sys/ufs/lfs/lfs_debug.c   |  10 +++++-----
 sys/ufs/lfs/lfs_segment.c |  28 +++++++++++++---------------
 sys/ufs/lfs/lfs_subr.c    |   6 +++---
 sys/ufs/lfs/lfs_vfsops.c  |  13 ++++++-------
 5 files changed, 30 insertions(+), 31 deletions(-)

diffs (225 lines):

diff -r 5337dfe69f25 -r 23c106b26a79 sys/ufs/lfs/lfs.h
--- a/sys/ufs/lfs/lfs.h Wed Jan 29 12:57:36 2003 +0000
+++ b/sys/ufs/lfs/lfs.h Wed Jan 29 13:14:33 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs.h,v 1.44 2003/01/27 23:17:56 yamt Exp $    */
+/*     $NetBSD: lfs.h,v 1.45 2003/01/29 13:14:33 yamt Exp $    */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -284,6 +284,8 @@
        int32_t   fi_blocks[1];         /* array of logical block numbers */
 };
 
+/* sizeof FINFO except fi_blocks */
+#define        FINFOSIZE       (sizeof(FINFO) - sizeof(int32_t))
 
 /* On-disk super block. */
 struct dlfs {
diff -r 5337dfe69f25 -r 23c106b26a79 sys/ufs/lfs/lfs_debug.c
--- a/sys/ufs/lfs/lfs_debug.c   Wed Jan 29 12:57:36 2003 +0000
+++ b/sys/ufs/lfs/lfs_debug.c   Wed Jan 29 13:14:33 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_debug.c,v 1.18 2003/01/25 23:00:09 kleink Exp $    */
+/*     $NetBSD: lfs_debug.c,v 1.19 2003/01/29 13:14:34 yamt Exp $      */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
 #ifdef DEBUG
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_debug.c,v 1.18 2003/01/25 23:00:09 kleink Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_debug.c,v 1.19 2003/01/29 13:14:34 yamt Exp $");
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/namei.h>
@@ -215,7 +215,7 @@
        if ((actual = i = 1) == 1)
                return; /* XXXX not checking this anymore, really */
        
-       if (sp->sum_bytes_left >= sizeof(FINFO) - sizeof(daddr_t)
+       if (sp->sum_bytes_left >= FINFOSIZE
           && sp->fip->fi_nblocks > 512) {
                printf("%s:%d: fi_nblocks = %d\n",file,line,sp->fip->fi_nblocks);
 #ifdef DDB
@@ -233,7 +233,7 @@
                /* amount taken up by FINFOs */
                - ((char *)&(sp->fip->fi_blocks[sp->fip->fi_nblocks]) - (char *)(sp->segsum))
                        /* amount taken up by inode blocks */
-                       - sizeof(daddr_t)*((sp->ninodes+INOPB(fs)-1) / INOPB(fs));
+                       - sizeof(int32_t)*((sp->ninodes+INOPB(fs)-1) / INOPB(fs));
 #if 0
        if (actual - sp->sum_bytes_left < offset) 
        {  
@@ -252,7 +252,7 @@
 #endif
        if (sp->sum_bytes_left > 0
           && ((char *)(sp->segsum))[fs->lfs_sumsize
-                                    - sizeof(daddr_t) * ((sp->ninodes+INOPB(fs)-1) / INOPB(fs))
+                                    - sizeof(int32_t) * ((sp->ninodes+INOPB(fs)-1) / INOPB(fs))
                                     - sp->sum_bytes_left] != '\0') {
                printf("%s:%d: warning: segsum overwrite at %d (-%d => %d)\n",
                       file, line, sp->sum_bytes_left,
diff -r 5337dfe69f25 -r 23c106b26a79 sys/ufs/lfs/lfs_segment.c
--- a/sys/ufs/lfs/lfs_segment.c Wed Jan 29 12:57:36 2003 +0000
+++ b/sys/ufs/lfs/lfs_segment.c Wed Jan 29 13:14:33 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_segment.c,v 1.97 2003/01/29 03:09:32 simonb Exp $  */
+/*     $NetBSD: lfs_segment.c,v 1.98 2003/01/29 13:14:34 yamt Exp $    */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.97 2003/01/29 03:09:32 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.98 2003/01/29 13:14:34 yamt Exp $");
 
 #define ivndebug(vp,str) printf("ino %d: %s\n",VTOI(vp)->i_number,(str))
 
@@ -714,7 +714,7 @@
            sp->sum_bytes_left < sizeof(struct finfo))
                (void) lfs_writeseg(fs, sp);
        
-       sp->sum_bytes_left -= sizeof(struct finfo) - sizeof(daddr_t);
+       sp->sum_bytes_left -= FINFOSIZE;
        ++((SEGSUM *)(sp->segsum))->ss_nfinfo;
 
        if (vp->v_flag & VDIROP)
@@ -776,11 +776,11 @@
        }
        fip = sp->fip;
        if (fip->fi_nblocks != 0) {
-               sp->fip = (FINFO*)((caddr_t)fip + sizeof(struct finfo) +
-                                  sizeof(daddr_t) * (fip->fi_nblocks-1));
+               sp->fip = (FINFO*)((caddr_t)fip + FINFOSIZE +
+                                  sizeof(int32_t) * (fip->fi_nblocks));
                sp->start_lbp = &sp->fip->fi_blocks[0];
        } else {
-               sp->sum_bytes_left += sizeof(FINFO) - sizeof(daddr_t);
+               sp->sum_bytes_left += FINFOSIZE;
                --((SEGSUM *)(sp->segsum))->ss_nfinfo;
        }
 }
@@ -807,7 +807,7 @@
        if ((ip->i_number != LFS_IFILE_INUM || sp->idp == NULL) && sp->ibp == NULL) {
                /* Allocate a new segment if necessary. */
                if (sp->seg_bytes_left < fs->lfs_ibsize ||
-                   sp->sum_bytes_left < sizeof(daddr_t))
+                   sp->sum_bytes_left < sizeof(int32_t))
                        (void) lfs_writeseg(fs, sp);
 
                /* Get next inode block. */
@@ -826,11 +826,10 @@
                fs->lfs_avail -= btofsb(fs, fs->lfs_ibsize);
                /* Set remaining space counters. */
                sp->seg_bytes_left -= fs->lfs_ibsize;
-               sp->sum_bytes_left -= sizeof(daddr_t);
-               ndx = fs->lfs_sumsize / sizeof(daddr_t) -
+               sp->sum_bytes_left -= sizeof(int32_t);
+               ndx = fs->lfs_sumsize / sizeof(int32_t) -
                        sp->ninodes / INOPB(fs) - 1;
-               /* fvdl -- not on disk, should be ok */
-               ((daddr_t *)(sp->segsum))[ndx] = daddr;
+               ((int32_t *)(sp->segsum))[ndx] = daddr;
        }
 
        /* Update the inode times and copy the inode onto the inode page. */
@@ -1011,7 +1010,7 @@
                panic ("lfs_gatherblock: Null vp in segment");
 #endif
        fs = sp->fs;
-       if (sp->sum_bytes_left < sizeof(daddr_t) ||
+       if (sp->sum_bytes_left < sizeof(int32_t) ||
            sp->seg_bytes_left < bp->b_bcount) {
                if (sptr)
                        splx(*sptr);
@@ -1024,8 +1023,7 @@
                sp->fip->fi_ino = VTOI(sp->vp)->i_number;
                /* Add the current file to the segment summary. */
                ++((SEGSUM *)(sp->segsum))->ss_nfinfo;
-               sp->sum_bytes_left -= 
-                       sizeof(struct finfo) - sizeof(daddr_t);
+               sp->sum_bytes_left -= FINFOSIZE;
                
                if (sptr)
                        *sptr = splbio();
@@ -1047,7 +1045,7 @@
        *sp->cbpp++ = bp;
        sp->fip->fi_blocks[sp->fip->fi_nblocks++] = bp->b_lblkno;
        
-       sp->sum_bytes_left -= sizeof(daddr_t);
+       sp->sum_bytes_left -= sizeof(int32_t);
        sp->seg_bytes_left -= bp->b_bcount;
        return (0);
 }
diff -r 5337dfe69f25 -r 23c106b26a79 sys/ufs/lfs/lfs_subr.c
--- a/sys/ufs/lfs/lfs_subr.c    Wed Jan 29 12:57:36 2003 +0000
+++ b/sys/ufs/lfs/lfs_subr.c    Wed Jan 29 13:14:33 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_subr.c,v 1.29 2003/01/24 21:55:28 fvdl Exp $       */
+/*     $NetBSD: lfs_subr.c,v 1.30 2003/01/29 13:14:35 yamt Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.29 2003/01/24 21:55:28 fvdl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.30 2003/01/29 13:14:35 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -150,7 +150,7 @@
 
        sp = fs->lfs_sp = malloc(sizeof(struct segment), M_SEGMENT, M_WAITOK);
        sp->bpp = malloc(((fs->lfs_sumsize - SEGSUM_SIZE(fs)) /
-                         sizeof(daddr_t) + 1) * sizeof(struct buf *),
+                         sizeof(int32_t) + 1) * sizeof(struct buf *),
                         M_SEGMENT, M_WAITOK);
        sp->seg_flags = flags;
        sp->vp = NULL;
diff -r 5337dfe69f25 -r 23c106b26a79 sys/ufs/lfs/lfs_vfsops.c
--- a/sys/ufs/lfs/lfs_vfsops.c  Wed Jan 29 12:57:36 2003 +0000
+++ b/sys/ufs/lfs/lfs_vfsops.c  Wed Jan 29 13:14:33 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_vfsops.c,v 1.89 2003/01/27 23:17:57 yamt Exp $     */
+/*     $NetBSD: lfs_vfsops.c,v 1.90 2003/01/29 13:14:36 yamt Exp $     */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.89 2003/01/27 23:17:57 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.90 2003/01/29 13:14:36 yamt Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -658,9 +658,8 @@
                        if (fip->fi_nblocks <= 0)
                                break;
                        /* XXX ondisk32 */
-                       fip = (FINFO *)(((char *)fip) + sizeof(FINFO) +
-                                       (fip->fi_nblocks - 1) *
-                                       sizeof(int32_t));
+                       fip = (FINFO *)(((char *)fip) + FINFOSIZE +
+                                       (fip->fi_nblocks * sizeof(int32_t)));
                }
                nblocks += ninos;
                /* Create the sum array */
@@ -724,8 +723,8 @@
                        offset += btofsb(fs, size);
                }
                /* XXX ondisk32 */
-               fip = (FINFO *)(((char *)fip) + sizeof(FINFO)
-                               + (fip->fi_nblocks - 1) * sizeof(int32_t));
+               fip = (FINFO *)(((char *)fip) + FINFOSIZE
+                               + fip->fi_nblocks * sizeof(int32_t));
        }
        /* Checksum the array, compare */
        if ((flags & CHECK_CKSUM) &&



Home | Main Index | Thread Index | Old Index