diff --git a/libexec/lfs_cleanerd/cleaner.h b/libexec/lfs_cleanerd/cleaner.h index b102f893861e..4a9e227966f7 100644 --- a/libexec/lfs_cleanerd/cleaner.h +++ b/libexec/lfs_cleanerd/cleaner.h @@ -52,7 +52,8 @@ struct clfs { static __unused inline void \ clfs_sb_add##field(struct clfs *fs, type val) \ { \ - fs->lfs_dlfs.dlfs_##field += val; \ + type *p = &fs->lfs_dlfs.dlfs_##field; \ + *p += val; \ } /* more ugh... */ @@ -61,22 +62,57 @@ CLFS_DEF_SB_ACCESSOR(u_int32_t, bsize); CLFS_DEF_SB_ACCESSOR(u_int32_t, fsize); CLFS_DEF_SB_ACCESSOR(u_int32_t, frag); CLFS_DEF_SB_ACCESSOR(u_int32_t, ifile); +CLFS_DEF_SB_ACCESSOR(u_int32_t, inopb); CLFS_DEF_SB_ACCESSOR(u_int32_t, ifpb); CLFS_DEF_SB_ACCESSOR(u_int32_t, sepb); CLFS_DEF_SB_ACCESSOR(u_int32_t, nseg); CLFS_DEF_SB_ACCESSOR(u_int32_t, cleansz); CLFS_DEF_SB_ACCESSOR(u_int32_t, segtabsz); +CLFS_DEF_SB_ACCESSOR(u_int64_t, bmask); +CLFS_DEF_SB_ACCESSOR(u_int32_t, bshift); +CLFS_DEF_SB_ACCESSOR(u_int64_t, ffmask); +CLFS_DEF_SB_ACCESSOR(u_int32_t, ffshift); +CLFS_DEF_SB_ACCESSOR(u_int32_t, fbshift); +CLFS_DEF_SB_ACCESSOR(u_int32_t, blktodb); +CLFS_DEF_SB_ACCESSOR(u_int32_t, minfreeseg); +CLFS_DEF_SB_ACCESSOR(u_int32_t, sumsize); +CLFS_DEF_SB_ACCESSOR(u_int32_t, ibsize); +CLFS_DEF_SB_ACCESSOR(int32_t, s0addr); +static __unused inline int32_t +clfs_sb_getsboff(struct clfs *fs, unsigned n) +{ + assert(n < LFS_MAXNUMSB); + return fs->lfs_dlfs.dlfs_sboffs[n]; +} +static __unused inline const char * +clfs_sb_getfsmnt(struct clfs *fs) +{ + return (const char *)fs->lfs_dlfs.dlfs_fsmnt; +} /* still more ugh... */ #define lfs_sb_getssize(fs) clfs_sb_getssize(fs) #define lfs_sb_getbsize(fs) clfs_sb_getbsize(fs) #define lfs_sb_getfsize(fs) clfs_sb_getfsize(fs) #define lfs_sb_getfrag(fs) clfs_sb_getfrag(fs) +#define lfs_sb_getinopb(fs) clfs_sb_getinopb(fs) #define lfs_sb_getifpb(fs) clfs_sb_getifpb(fs) #define lfs_sb_getsepb(fs) clfs_sb_getsepb(fs) #define lfs_sb_getnseg(fs) clfs_sb_getnseg(fs) #define lfs_sb_getcleansz(fs) clfs_sb_getcleansz(fs) #define lfs_sb_getsegtabsz(fs) clfs_sb_getsegtabsz(fs) +#define lfs_sb_getbmask(fs) clfs_sb_getbmask(fs) +#define lfs_sb_getbshift(fs) clfs_sb_getbshift(fs) +#define lfs_sb_getffmask(fs) clfs_sb_getffmask(fs) +#define lfs_sb_getffshift(fs) clfs_sb_getffshift(fs) +#define lfs_sb_getfbshift(fs) clfs_sb_getfbshift(fs) +#define lfs_sb_getblktodb(fs) clfs_sb_getblktodb(fs) +#define lfs_sb_getminfreeseg(fs) clfs_sb_getminfreeseg(fs) +#define lfs_sb_getsumsize(fs) clfs_sb_getsumsize(fs) +#define lfs_sb_getibsize(fs) clfs_sb_getibsize(fs) +#define lfs_sb_gets0addr(fs) clfs_sb_gets0addr(fs) +#define lfs_sb_getsboff(fs, n) clfs_sb_getsboff(fs, n) +#define lfs_sb_getfsmnt(fs) clfs_sb_getfsmnt(fs) /* * Fraction of the could-be-clean segments required to be clean. diff --git a/libexec/lfs_cleanerd/coalesce.c b/libexec/lfs_cleanerd/coalesce.c index 9917b4ea7a38..067e67d26e64 100644 --- a/libexec/lfs_cleanerd/coalesce.c +++ b/libexec/lfs_cleanerd/coalesce.c @@ -1,4 +1,4 @@ -/* $NetBSD: coalesce.c,v 1.25 2015/07/24 06:56:41 dholland Exp $ */ +/* $NetBSD: coalesce.c,v 1.26 2015/07/24 06:59:31 dholland Exp $ */ /*- * Copyright (c) 2002, 2005 The NetBSD Foundation, Inc. @@ -49,6 +49,7 @@ #include #include #include +#include #include @@ -118,9 +119,9 @@ get_dinode(struct clfs *fs, ino_t ino) if (daddr == 0x0) return NULL; - bread(fs->clfs_devvp, daddr, fs->lfs_ibsize, 0, &bp); + bread(fs->clfs_devvp, daddr, lfs_sb_getibsize(fs), 0, &bp); for (dip = (struct ulfs1_dinode *)bp->b_data; - dip < (struct ulfs1_dinode *)(bp->b_data + fs->lfs_ibsize); dip++) + dip < (struct ulfs1_dinode *)(bp->b_data + lfs_sb_getibsize(fs)); dip++) if (dip->di_inumber == ino) { r = (struct ulfs1_dinode *)malloc(sizeof(*r)); if (r == NULL) @@ -201,7 +202,7 @@ clean_inode(struct clfs *fs, ino_t ino) lim.blkcnt = nb; if (kops.ko_fcntl(fs->clfs_ifilefd, LFCNBMAPV, &lim) < 0) { syslog(LOG_WARNING, "%s: coalesce: LFCNBMAPV: %m", - fs->lfs_fsmnt); + lfs_sb_getfsmnt(fs)); retval = COALESCE_BADBMAPV; goto out; } @@ -218,7 +219,7 @@ clean_inode(struct clfs *fs, ino_t ino) if (bip[i].bi_daddr != bip[i - 1].bi_daddr + clfs_sb_getfrag(fs)) ++noff; toff += abs(bip[i].bi_daddr - bip[i - 1].bi_daddr - - clfs_sb_getfrag(fs)) >> fs->lfs_fbshift; + - clfs_sb_getfrag(fs)) >> lfs_sb_getfbshift(fs); } /* @@ -339,7 +340,7 @@ int clean_all_inodes(struct clfs *fs) memset(totals, 0, sizeof(totals)); fstat(fs->clfs_ifilefd, &st); - maxino = lfs_sb_getifpb(fs) * (st.st_size >> fs->lfs_bshift) - + maxino = lfs_sb_getifpb(fs) * (st.st_size >> lfs_sb_getbshift(fs)) - lfs_sb_getsegtabsz(fs) - lfs_sb_getcleansz(fs); for (i = 0; i < maxino; i++) { @@ -383,14 +384,14 @@ fork_coalesce(struct clfs *fs) */ childpid = fork(); if (childpid < 0) { - syslog(LOG_ERR, "%s: fork to coaleasce: %m", fs->lfs_fsmnt); + syslog(LOG_ERR, "%s: fork to coaleasce: %m", lfs_sb_getfsmnt(fs)); return 0; } else if (childpid == 0) { syslog(LOG_NOTICE, "%s: new coalescing process, pid %d", - fs->lfs_fsmnt, getpid()); + lfs_sb_getfsmnt(fs), getpid()); num = clean_all_inodes(fs); syslog(LOG_NOTICE, "%s: coalesced %d discontiguous inodes", - fs->lfs_fsmnt, num); + lfs_sb_getfsmnt(fs), num); exit(0); } diff --git a/libexec/lfs_cleanerd/lfs_cleanerd.c b/libexec/lfs_cleanerd/lfs_cleanerd.c index 3f3547e4fccb..5a730d0d947a 100644 --- a/libexec/lfs_cleanerd/lfs_cleanerd.c +++ b/libexec/lfs_cleanerd/lfs_cleanerd.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_cleanerd.c,v 1.39 2015/07/24 06:56:41 dholland Exp $ */ +/* $NetBSD: lfs_cleanerd.c,v 1.40 2015/07/24 06:59:31 dholland Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -120,7 +120,7 @@ dlog(const char *fmt, ...) void handle_error(struct clfs **cfsp, int n) { - syslog(LOG_NOTICE, "%s: detaching cleaner", cfsp[n]->lfs_fsmnt); + syslog(LOG_NOTICE, "%s: detaching cleaner", lfs_sb_getfsmnt(cfsp[n])); free(cfsp[n]); if (n != nfss - 1) cfsp[n] = cfsp[nfss - 1]; @@ -133,9 +133,11 @@ handle_error(struct clfs **cfsp, int n) int reinit_fs(struct clfs *fs) { - char fsname[MNAMELEN]; + char fsname[sizeof(fs->lfs_dlfs.dlfs_fsmnt)]; + + memcpy(fsname, fs->lfs_dlfs.dlfs_fsmnt, sizeof(fsname)); + fsname[sizeof(fsname) - 1] = '\0'; - strncpy(fsname, (char *)fs->lfs_fsmnt, MNAMELEN); kops.ko_close(fs->clfs_ifilefd); kops.ko_close(fs->clfs_devfd); fd_reclaim(fs->clfs_devvp); @@ -174,11 +176,11 @@ init_unmounted_fs(struct clfs *fs, char *fsname) atatime); /* Allocate and clear segtab */ - fs->clfs_segtab = (struct clfs_seguse *)malloc(fs->lfs_nseg * + fs->clfs_segtab = (struct clfs_seguse *)malloc(lfs_sb_getnseg(fs) * sizeof(*fs->clfs_segtab)); - fs->clfs_segtabp = (struct clfs_seguse **)malloc(fs->lfs_nseg * + fs->clfs_segtabp = (struct clfs_seguse **)malloc(lfs_sb_getnseg(fs) * sizeof(*fs->clfs_segtabp)); - for (i = 0; i < fs->lfs_nseg; i++) { + for (i = 0; i < lfs_sb_getnseg(fs); i++) { fs->clfs_segtabp[i] = &(fs->clfs_segtab[i]); fs->clfs_segtab[i].flags = 0x0; } @@ -200,6 +202,7 @@ init_unmounted_fs(struct clfs *fs, char *fsname) int init_fs(struct clfs *fs, char *fsname) { + char mnttmp[sizeof(fs->lfs_dlfs.dlfs_fsmnt)]; struct statvfs sf; int rootfd; int i; @@ -261,7 +264,9 @@ init_fs(struct clfs *fs, char *fsname) } /* Assume fsname is the mounted name */ - strncpy((char *)fs->lfs_fsmnt, fsname, MNAMELEN); + strncpy(mnttmp, fsname, sizeof(mnttmp)); + mnttmp[sizeof(mnttmp) - 1] = '\0'; + memcpy(fs->lfs_dlfs.dlfs_fsmnt, mnttmp, sizeof(mnttmp)); /* Set up vnodes for Ifile and raw device */ fs->lfs_ivnode = fd_vget(fs->clfs_ifilefd, clfs_sb_getbsize(fs), 0, 0); @@ -269,9 +274,9 @@ init_fs(struct clfs *fs, char *fsname) atatime); /* Allocate and clear segtab */ - fs->clfs_segtab = (struct clfs_seguse *)malloc(fs->lfs_nseg * + fs->clfs_segtab = (struct clfs_seguse *)malloc(lfs_sb_getnseg(fs) * sizeof(*fs->clfs_segtab)); - fs->clfs_segtabp = (struct clfs_seguse **)malloc(fs->lfs_nseg * + fs->clfs_segtabp = (struct clfs_seguse **)malloc(lfs_sb_getnseg(fs) * sizeof(*fs->clfs_segtabp)); if (fs->clfs_segtab == NULL || fs->clfs_segtabp == NULL) { syslog(LOG_ERR, "%s: couldn't malloc segment table: %m", @@ -279,7 +284,7 @@ init_fs(struct clfs *fs, char *fsname) return -1; } - for (i = 0; i < fs->lfs_nseg; i++) { + for (i = 0; i < lfs_sb_getnseg(fs); i++) { fs->clfs_segtabp[i] = &(fs->clfs_segtab[i]); fs->clfs_segtab[i].flags = 0x0; } @@ -316,7 +321,7 @@ reload_ifile(struct clfs *fs) ohashmax = hashmax; bufrehash(st.st_size / clfs_sb_getbsize(fs)); dlog("%s: resized buffer hash from %d to %d", - fs->lfs_fsmnt, ohashmax, hashmax); + lfs_sb_getfsmnt(fs), ohashmax, hashmax); } } @@ -335,7 +340,7 @@ lfs_ientry(IFILE **ifpp, struct clfs *fs, ino_t ino, struct ubuf **bpp) lfs_sb_getsegtabsz(fs), clfs_sb_getbsize(fs), 0, bpp); if (error) syslog(LOG_ERR, "%s: ientry failed for ino %d", - fs->lfs_fsmnt, (int)ino); + lfs_sb_getfsmnt(fs), (int)ino); *ifpp = (IFILE *)(*bpp)->b_data + ino % lfs_sb_getifpb(fs); return; } @@ -400,7 +405,7 @@ parse_pseg(struct clfs *fs, daddr_t daddr, BLOCK_INFO **bipp, int *bic) */ cp = fd_ptrget(fs->clfs_devvp, daddr); ssp = (SEGSUM *)cp; - iaddrp = ((int32_t *)(cp + fs->lfs_ibsize)) - 1; + iaddrp = ((int32_t *)(cp + lfs_sb_getibsize(fs))) - 1; fip = (FINFO *)(cp + sizeof(SEGSUM)); /* @@ -408,14 +413,14 @@ parse_pseg(struct clfs *fs, daddr_t daddr, BLOCK_INFO **bipp, int *bic) */ if (ssp->ss_magic != SS_MAGIC) { syslog(LOG_WARNING, "%s: sumsum magic number bad at 0x%x:" - " read 0x%x, expected 0x%x", fs->lfs_fsmnt, + " read 0x%x, expected 0x%x", lfs_sb_getfsmnt(fs), (int32_t)daddr, ssp->ss_magic, SS_MAGIC); return 0x0; } - ck = cksum(&ssp->ss_datasum, fs->lfs_sumsize - sizeof(ssp->ss_sumsum)); + ck = cksum(&ssp->ss_datasum, lfs_sb_getsumsize(fs) - sizeof(ssp->ss_sumsum)); if (ck != ssp->ss_sumsum) { syslog(LOG_WARNING, "%s: sumsum checksum mismatch at 0x%x:" - " read 0x%x, computed 0x%x", fs->lfs_fsmnt, + " read 0x%x, computed 0x%x", lfs_sb_getfsmnt(fs), (int32_t)daddr, ssp->ss_sumsum, ck); return 0x0; } @@ -439,7 +444,7 @@ parse_pseg(struct clfs *fs, daddr_t daddr, BLOCK_INFO **bipp, int *bic) */ if (fic >= ssp->ss_nfinfo && *iaddrp != daddr) { syslog(LOG_WARNING, "%s: bad pseg at %x (seg %d)", - fs->lfs_fsmnt, odaddr, lfs_dtosn(fs, odaddr)); + lfs_sb_getfsmnt(fs), odaddr, lfs_dtosn(fs, odaddr)); *bipp = bip; return 0x0; } @@ -451,7 +456,7 @@ parse_pseg(struct clfs *fs, daddr_t daddr, BLOCK_INFO **bipp, int *bic) cp = fd_ptrget(fs->clfs_devvp, daddr); ck = lfs_cksum_part(cp, sizeof(u_int32_t), ck); dip = (struct ulfs1_dinode *)cp; - for (i = 0; i < fs->lfs_inopb; i++) { + for (i = 0; i < lfs_sb_getinopb(fs); i++) { if (dip[i].di_inumber == 0) break; @@ -488,7 +493,7 @@ parse_pseg(struct clfs *fs, daddr_t daddr, BLOCK_INFO **bipp, int *bic) bip[*bic - 1].bi_size = LFS_DINODE1_SIZE; } inoc += i; - daddr += lfs_btofsb(fs, fs->lfs_ibsize); + daddr += lfs_btofsb(fs, lfs_sb_getibsize(fs)); --iaddrp; continue; } @@ -519,7 +524,7 @@ parse_pseg(struct clfs *fs, daddr_t daddr, BLOCK_INFO **bipp, int *bic) nssp = (SEGSUM *)nbp->b_data; --nssp->ss_nfinfo; nssp->ss_sumsum = cksum(&nssp->ss_datasum, - fs->lfs_sumsize - sizeof(nssp->ss_sumsum)); + lfs_sb_getsumsize(fs) - sizeof(nssp->ss_sumsum)); bwrite(nbp); #endif syslog(LOG_WARNING, "zero-length FINFO at %x (seg %d)", @@ -586,7 +591,7 @@ parse_pseg(struct clfs *fs, daddr_t daddr, BLOCK_INFO **bipp, int *bic) #ifndef REPAIR_ZERO_FINFO if (ssp->ss_datasum != ck) { syslog(LOG_WARNING, "%s: data checksum bad at 0x%x:" - " read 0x%x, computed 0x%x", fs->lfs_fsmnt, odaddr, + " read 0x%x, computed 0x%x", lfs_sb_getfsmnt(fs), odaddr, ssp->ss_datasum, ck); *bic = obic; return 0x0; @@ -639,7 +644,7 @@ load_segment(struct clfs *fs, int sn, BLOCK_INFO **bipp, int *bic) if (daddr < lfs_btofsb(fs, LFS_LABELPAD)) daddr = lfs_btofsb(fs, LFS_LABELPAD); for (i = 0; i < LFS_MAXNUMSB; i++) { - if (fs->lfs_sboffs[i] == daddr) { + if (lfs_sb_getsboff(fs, i) == daddr) { daddr += lfs_btofsb(fs, LFS_SBPAD); break; } @@ -819,7 +824,7 @@ toss_old_blocks(struct clfs *fs, BLOCK_INFO **bipp, int *bic, int *sizep) lim.blkcnt = *bic; if ((r = kops.ko_fcntl(fs->clfs_ifilefd, LFCNBMAPV, &lim)) < 0) { syslog(LOG_WARNING, "%s: bmapv returned %d (%m)", - fs->lfs_fsmnt, r); + lfs_sb_getfsmnt(fs), r); return; } @@ -856,7 +861,7 @@ invalidate_segment(struct clfs *fs, int sn) int blkcnt; } */ lim; - dlog("%s: inval seg %d", fs->lfs_fsmnt, sn); + dlog("%s: inval seg %d", lfs_sb_getfsmnt(fs), sn); bip = NULL; bic = 0; @@ -880,7 +885,7 @@ invalidate_segment(struct clfs *fs, int sn) lim.blkcnt = bic; if ((r = kops.ko_fcntl(fs->clfs_ifilefd, LFCNMARKV, &lim)) < 0) { syslog(LOG_WARNING, "%s: markv returned %d (%m) " - "for seg %d", fs->lfs_fsmnt, r, sn); + "for seg %d", lfs_sb_getfsmnt(fs), r, sn); return r; } @@ -889,7 +894,7 @@ invalidate_segment(struct clfs *fs, int sn) */ if ((r = kops.ko_fcntl(fs->clfs_ifilefd, LFCNINVAL, &sn)) < 0) { syslog(LOG_WARNING, "%s: inval returned %d (%m) " - "for seg %d", fs->lfs_fsmnt, r, sn); + "for seg %d", lfs_sb_getfsmnt(fs), r, sn); return r; } @@ -1035,12 +1040,12 @@ clean_fs(struct clfs *fs, CLEANERINFO *cip) } /* Sort segments based on cleanliness, fulness, and condition */ - heapsort(fs->clfs_segtabp, fs->lfs_nseg, sizeof(struct clfs_seguse *), + heapsort(fs->clfs_segtabp, lfs_sb_getnseg(fs), sizeof(struct clfs_seguse *), cb_comparator); /* If no segment is cleanable, just return */ if (fs->clfs_segtabp[0]->priority == 0) { - dlog("%s: no segment cleanable", fs->lfs_fsmnt); + dlog("%s: no segment cleanable", lfs_sb_getfsmnt(fs)); return 0; } @@ -1057,12 +1062,12 @@ clean_fs(struct clfs *fs, CLEANERINFO *cip) dlog("%s: cleaning with goal %" PRId64 " bytes (%d segs clean, %d cleanable)", - fs->lfs_fsmnt, goal, cip->clean, npos); + lfs_sb_getfsmnt(fs), goal, cip->clean, npos); syslog(LOG_INFO, "%s: cleaning with goal %" PRId64 " bytes (%d segs clean, %d cleanable)", - fs->lfs_fsmnt, goal, cip->clean, npos); + lfs_sb_getfsmnt(fs), goal, cip->clean, npos); totbytes = 0; - for (i = 0; i < fs->lfs_nseg && totbytes < goal; i++) { + for (i = 0; i < lfs_sb_getnseg(fs) && totbytes < goal; i++) { if (fs->clfs_segtabp[i]->priority == 0) break; /* Upper bound on number of segments at once */ @@ -1071,7 +1076,7 @@ clean_fs(struct clfs *fs, CLEANERINFO *cip) sn = (fs->clfs_segtabp[i] - fs->clfs_segtab); dlog("%s: add seg %d prio %" PRIu64 " containing %ld bytes", - fs->lfs_fsmnt, sn, fs->clfs_segtabp[i]->priority, + lfs_sb_getfsmnt(fs), sn, fs->clfs_segtabp[i]->priority, fs->clfs_segtabp[i]->nbytes); if ((r = load_segment(fs, sn, &bip, &bic)) > 0) { ++ngood; @@ -1089,13 +1094,13 @@ clean_fs(struct clfs *fs, CLEANERINFO *cip) goal = MAX(cip->clean - 1, 1); dlog("%s: cleaning with goal %d segments (%d clean, %d cleanable)", - fs->lfs_fsmnt, (int)goal, cip->clean, npos); - for (i = 0; i < fs->lfs_nseg && ngood < goal; i++) { + lfs_sb_getfsmnt(fs), (int)goal, cip->clean, npos); + for (i = 0; i < lfs_sb_getnseg(fs) && ngood < goal; i++) { if (fs->clfs_segtabp[i]->priority == 0) break; sn = (fs->clfs_segtabp[i] - fs->clfs_segtab); dlog("%s: add seg %d prio %" PRIu64, - fs->lfs_fsmnt, sn, fs->clfs_segtabp[i]->priority); + lfs_sb_getfsmnt(fs), sn, fs->clfs_segtabp[i]->priority); if ((r = load_segment(fs, sn, &bip, &bic)) > 0) ++ngood; else if (r == 0) @@ -1109,7 +1114,7 @@ clean_fs(struct clfs *fs, CLEANERINFO *cip) /* If there is nothing to do, try again later. */ if (bic == 0) { dlog("%s: no blocks to clean in %d cleanable segments", - fs->lfs_fsmnt, (int)ngood); + lfs_sb_getfsmnt(fs), (int)ngood); fd_release_all(fs->clfs_devvp); return 0; } @@ -1152,16 +1157,16 @@ clean_fs(struct clfs *fs, CLEANERINFO *cip) if ((r = kops.ko_fcntl(fs->clfs_ifilefd, LFCNMARKV, &lim))<0) { int oerrno = errno; syslog(LOG_WARNING, "%s: markv returned %d (errno %d, %m)", - fs->lfs_fsmnt, r, errno); + lfs_sb_getfsmnt(fs), r, errno); if (oerrno != EAGAIN && oerrno != ESHUTDOWN) { syslog(LOG_DEBUG, "%s: errno %d, returning", - fs->lfs_fsmnt, oerrno); + lfs_sb_getfsmnt(fs), oerrno); fd_release_all(fs->clfs_devvp); return r; } if (oerrno == ESHUTDOWN) { syslog(LOG_NOTICE, "%s: filesystem unmounted", - fs->lfs_fsmnt); + lfs_sb_getfsmnt(fs)); fd_release_all(fs->clfs_devvp); return r; } @@ -1175,14 +1180,14 @@ clean_fs(struct clfs *fs, CLEANERINFO *cip) PRId64 " supporting indirect + %" PRId64 " supporting Ifile = %" PRId64 " bytes to clean %d segs (%" PRId64 "%% recovery)", - fs->lfs_fsmnt, (int64_t)nb, (int64_t)(extra - if_extra), + lfs_sb_getfsmnt(fs), (int64_t)nb, (int64_t)(extra - if_extra), (int64_t)if_extra, (int64_t)(nb + extra), ngood, (ngood ? (int64_t)(100 - (100 * (nb + extra)) / (ngood * clfs_sb_getssize(fs))) : (int64_t)0)); if (nb + extra >= ngood * clfs_sb_getssize(fs)) syslog(LOG_WARNING, "%s: cleaner not making forward progress", - fs->lfs_fsmnt); + lfs_sb_getfsmnt(fs)); /* * Finally call reclaim to prompt cleaning of the segments. @@ -1217,7 +1222,7 @@ needs_cleaning(struct clfs *fs, CLEANERINFO *cip) * handing it back. */ if (bread(fs->lfs_ivnode, 0, clfs_sb_getbsize(fs), 0, &bp)) { - syslog(LOG_ERR, "%s: can't read inode", fs->lfs_fsmnt); + syslog(LOG_ERR, "%s: can't read inode", lfs_sb_getfsmnt(fs)); return -1; } *cip = *(CLEANERINFO *)bp->b_data; /* Structure copy */ @@ -1229,24 +1234,25 @@ needs_cleaning(struct clfs *fs, CLEANERINFO *cip) * We don't have to start over from scratch, however, * since we don't hold any buffers. */ - if (fs->lfs_nseg != cip->clean + cip->dirty) { + if (lfs_sb_getnseg(fs) != cip->clean + cip->dirty) { if (reinit_fs(fs) < 0) { /* The normal case for unmount */ - syslog(LOG_NOTICE, "%s: filesystem unmounted", fs->lfs_fsmnt); + syslog(LOG_NOTICE, "%s: filesystem unmounted", lfs_sb_getfsmnt(fs)); return -1; } - syslog(LOG_NOTICE, "%s: nsegs changed", fs->lfs_fsmnt); + syslog(LOG_NOTICE, "%s: nsegs changed", lfs_sb_getfsmnt(fs)); } /* Compute theoretical "free segments" maximum based on usage */ fsb_per_seg = lfs_segtod(fs, 1); - max_free_segs = MAX(cip->bfree, 0) / fsb_per_seg + fs->lfs_minfreeseg; + max_free_segs = MAX(cip->bfree, 0) / fsb_per_seg + lfs_sb_getminfreeseg(fs); dlog("%s: bfree = %d, avail = %d, clean = %d/%d", - fs->lfs_fsmnt, cip->bfree, cip->avail, cip->clean, fs->lfs_nseg); + lfs_sb_getfsmnt(fs), cip->bfree, cip->avail, cip->clean, + lfs_sb_getnseg(fs)); /* If the writer is waiting on us, clean it */ - if (cip->clean <= fs->lfs_minfreeseg || + if (cip->clean <= lfs_sb_getminfreeseg(fs) || (cip->flags & LFS_CLEANER_MUST_CLEAN)) return 1; @@ -1270,7 +1276,7 @@ needs_cleaning(struct clfs *fs, CLEANERINFO *cip) time(&now); if (fstat(fs->clfs_ifilefd, &st) < 0) { syslog(LOG_ERR, "%s: failed to stat ifile", - fs->lfs_fsmnt); + lfs_sb_getfsmnt(fs)); return -1; } if (now - st.st_mtime > segwait_timeout && @@ -1280,7 +1286,7 @@ needs_cleaning(struct clfs *fs, CLEANERINFO *cip) /* CPU idle - use one-minute load avg */ if (getloadavg(&loadavg, 1) == -1) { syslog(LOG_ERR, "%s: failed to get load avg", - fs->lfs_fsmnt); + lfs_sb_getfsmnt(fs)); return -1; } if (loadavg < load_threshold && diff --git a/sbin/dump_lfs/lfs_inode.c b/sbin/dump_lfs/lfs_inode.c index 799034f5e6f7..b94e2ed696f1 100644 --- a/sbin/dump_lfs/lfs_inode.c +++ b/sbin/dump_lfs/lfs_inode.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_inode.c,v 1.20 2015/07/24 06:56:41 dholland Exp $ */ +/* $NetBSD: lfs_inode.c,v 1.21 2015/07/24 06:59:31 dholland Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993, 1994\ #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/1/95"; #else -__RCSID("$NetBSD: lfs_inode.c,v 1.20 2015/07/24 06:56:41 dholland Exp $"); +__RCSID("$NetBSD: lfs_inode.c,v 1.21 2015/07/24 06:59:31 dholland Exp $"); #endif #endif /* not lint */ @@ -95,8 +95,8 @@ fs_read_sblock(char *superblock) #endif quit("bad sblock magic number\n"); } - if (lfs_fsbtob(sblock, (off_t)sblock->lfs_sboffs[0]) != sboff) { - sboff = lfs_fsbtob(sblock, (off_t)sblock->lfs_sboffs[0]); + if (lfs_fsbtob(sblock, (off_t)lfs_sb_getsboff(sblock, 0)) != sboff) { + sboff = lfs_fsbtob(sblock, (off_t)lfs_sb_getsboff(sblock, 0)); continue; } break; @@ -105,7 +105,7 @@ fs_read_sblock(char *superblock) /* * Read the secondary and take the older of the two */ - rawread(lfs_fsbtob(sblock, (off_t)sblock->lfs_sboffs[1]), u.tbuf, + rawread(lfs_fsbtob(sblock, (off_t)lfs_sb_getsboff(sblock, 1)), u.tbuf, sizeof(u.tbuf)); #ifdef notyet if (ns) @@ -113,17 +113,17 @@ fs_read_sblock(char *superblock) #endif if (u.lfss.lfs_magic != LFS_MAGIC) { msg("Warning: secondary superblock at 0x%" PRIx64 " bad magic\n", - LFS_FSBTODB(sblock, (off_t)sblock->lfs_sboffs[1])); + LFS_FSBTODB(sblock, (off_t)lfs_sb_getsboff(sblock, 1))); } else { if (sblock->lfs_version > 1) { if (lfs_sb_getserial(&u.lfss) < lfs_sb_getserial(sblock)) { memcpy(sblock, u.tbuf, sizeof(u.tbuf)); - sboff = lfs_fsbtob(sblock, (off_t)sblock->lfs_sboffs[1]); + sboff = lfs_fsbtob(sblock, (off_t)lfs_sb_getsboff(sblock, 1)); } } else { if (lfs_sb_getotstamp(&u.lfss) < lfs_sb_getotstamp(sblock)) { memcpy(sblock, u.tbuf, sizeof(u.tbuf)); - sboff = lfs_fsbtob(sblock, (off_t)sblock->lfs_sboffs[1]); + sboff = lfs_fsbtob(sblock, (off_t)lfs_sb_getsboff(sblock, 1)); } } } @@ -148,23 +148,23 @@ fs_parametrize(void) ufsi.ufs_dsize = LFS_FSBTODB(sblock, lfs_sb_getsize(sblock)); if (sblock->lfs_version == 1) - ufsi.ufs_dsize = lfs_sb_getsize(sblock) >> sblock->lfs_blktodb; + ufsi.ufs_dsize = lfs_sb_getsize(sblock) >> lfs_sb_getblktodb(sblock); ufsi.ufs_bsize = lfs_sb_getbsize(sblock); - ufsi.ufs_bshift = sblock->lfs_bshift; + ufsi.ufs_bshift = lfs_sb_getbshift(sblock); ufsi.ufs_fsize = lfs_sb_getfsize(sblock); ufsi.ufs_frag = lfs_sb_getfrag(sblock); - ufsi.ufs_fsatoda = sblock->lfs_fsbtodb; + ufsi.ufs_fsatoda = lfs_sb_getfsbtodb(sblock); if (sblock->lfs_version == 1) ufsi.ufs_fsatoda = 0; - ufsi.ufs_nindir = sblock->lfs_nindir; - ufsi.ufs_inopb = sblock->lfs_inopb; - ufsi.ufs_maxsymlinklen = sblock->lfs_maxsymlinklen; - ufsi.ufs_bmask = ~(sblock->lfs_bmask); - ufsi.ufs_qbmask = sblock->lfs_bmask; - ufsi.ufs_fmask = ~(sblock->lfs_ffmask); - ufsi.ufs_qfmask = sblock->lfs_ffmask; + ufsi.ufs_nindir = lfs_sb_getnindir(sblock); + ufsi.ufs_inopb = lfs_sb_getinopb(sblock); + ufsi.ufs_maxsymlinklen = lfs_sb_getmaxsymlinklen(sblock); + ufsi.ufs_bmask = ~(lfs_sb_getbmask(sblock)); + ufsi.ufs_qbmask = lfs_sb_getbmask(sblock); + ufsi.ufs_fmask = ~(lfs_sb_getffmask(sblock)); + ufsi.ufs_qfmask = lfs_sb_getffmask(sblock); - dev_bsize = lfs_sb_getbsize(sblock) >> sblock->lfs_blktodb; + dev_bsize = lfs_sb_getbsize(sblock) >> lfs_sb_getblktodb(sblock); return &ufsi; } diff --git a/sbin/fsck_lfs/inode.c b/sbin/fsck_lfs/inode.c index 9f2e61adba8e..bbd9268d88bd 100644 --- a/sbin/fsck_lfs/inode.c +++ b/sbin/fsck_lfs/inode.c @@ -1,4 +1,4 @@ -/* $NetBSD: inode.c,v 1.55 2015/07/24 06:56:41 dholland Exp $ */ +/* $NetBSD: inode.c,v 1.56 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -137,8 +137,8 @@ ckinode(struct ulfs1_dinode *dp, struct inodesc *idesc) idesc->id_filesize = dp->di_size; mode = dp->di_mode & LFS_IFMT; if (mode == LFS_IFBLK || mode == LFS_IFCHR || - (mode == LFS_IFLNK && (dp->di_size < fs->lfs_maxsymlinklen || - (fs->lfs_maxsymlinklen == 0 && + (mode == LFS_IFLNK && (dp->di_size < lfs_sb_getmaxsymlinklen(fs) || + (lfs_sb_getmaxsymlinklen(fs) == 0 && dp->di_blocks == 0)))) return (KEEPON); dino = *dp; diff --git a/sbin/fsck_lfs/lfs.c b/sbin/fsck_lfs/lfs.c index a0c683e00d37..3b808bfe67db 100644 --- a/sbin/fsck_lfs/lfs.c +++ b/sbin/fsck_lfs/lfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs.c,v 1.46 2015/07/24 06:56:41 dholland Exp $ */ +/* $NetBSD: lfs.c,v 1.47 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. * All rights reserved. @@ -249,7 +249,7 @@ ulfs_getlbns(struct lfs * fs, struct uvnode * vp, daddr_t bn, struct indir * ap, bn = -bn; lognindir = -1; - for (indir = fs->lfs_nindir; indir; indir >>= 1) + for (indir = lfs_sb_getnindir(fs); indir; indir >>= 1) ++lognindir; /* Determine the number of levels of indirection. After this loop is @@ -287,7 +287,7 @@ ulfs_getlbns(struct lfs * fs, struct uvnode * vp, daddr_t bn, struct indir * ap, lbc -= lognindir; blockcnt = (int64_t) 1 << lbc; - off = (bn >> lbc) & (fs->lfs_nindir - 1); + off = (bn >> lbc) & (lfs_sb_getnindir(fs) - 1); ++numlevels; ap->in_lbn = metalbn; @@ -366,7 +366,7 @@ lfs_raw_vget(struct lfs * fs, ino_t ino, int fd, ulfs_daddr_t daddr) /* Load inode block and find inode */ if (daddr > 0) { - bread(fs->lfs_devvp, LFS_FSBTODB(fs, daddr), fs->lfs_ibsize, + bread(fs->lfs_devvp, LFS_FSBTODB(fs, daddr), lfs_sb_getibsize(fs), 0, &bp); bp->b_flags |= B_AGE; dip = lfs_ifind(fs, ino, bp); @@ -416,7 +416,7 @@ lfs_vget(void *vfs, ino_t ino) LFS_IENTRY(ifp, fs, ino, bp); daddr = ifp->if_daddr; brelse(bp, 0); - if (daddr <= 0 || lfs_dtosn(fs, daddr) >= fs->lfs_nseg) + if (daddr <= 0 || lfs_dtosn(fs, daddr) >= lfs_sb_getnseg(fs)) return NULL; return lfs_raw_vget(fs, ino, fs->lfs_ivnode->v_fd, daddr); } @@ -435,9 +435,9 @@ check_sb(struct lfs *fs) } /* checksum */ checksum = lfs_sb_cksum(&(fs->lfs_dlfs)); - if (fs->lfs_cksum != checksum) { + if (lfs_sb_getcksum(fs) != checksum) { printf("Superblock checksum (%lx) does not match computed checksum (%lx)\n", - (unsigned long) fs->lfs_cksum, (unsigned long) checksum); + (unsigned long) lfs_sb_getcksum(fs), (unsigned long) checksum); return 1; } return 0; @@ -486,10 +486,10 @@ lfs_init(int devfd, daddr_t sblkno, daddr_t idaddr, int dummy_read, int debug) bp->b_flags |= B_INVAL; brelse(bp, 0); - dev_bsize = lfs_sb_getfsize(fs) >> fs->lfs_fsbtodb; + dev_bsize = lfs_sb_getfsize(fs) >> lfs_sb_getfsbtodb(fs); if (tryalt) { - (void)bread(devvp, LFS_FSBTODB(fs, fs->lfs_sboffs[1]), + (void)bread(devvp, LFS_FSBTODB(fs, lfs_sb_getsboff(fs, 1)), LFS_SBPAD, 0, &bp); altfs = ecalloc(1, sizeof(*altfs)); altfs->lfs_dlfs = *((struct dlfs *) bp->b_data); @@ -526,17 +526,17 @@ lfs_init(int devfd, daddr_t sblkno, daddr_t idaddr, int dummy_read, int debug) /* Compatibility */ if (fs->lfs_version < 2) { - fs->lfs_sumsize = LFS_V1_SUMMARY_SIZE; - fs->lfs_ibsize = lfs_sb_getbsize(fs); - fs->lfs_s0addr = fs->lfs_sboffs[0]; + lfs_sb_setsumsize(fs, LFS_V1_SUMMARY_SIZE); + lfs_sb_setibsize(fs, lfs_sb_getbsize(fs)); + lfs_sb_sets0addr(fs, lfs_sb_getsboff(fs, 0)); lfs_sb_settstamp(fs, lfs_sb_getotstamp(fs)); - fs->lfs_fsbtodb = 0; + lfs_sb_setfsbtodb(fs, 0); } if (!dummy_read) { fs->lfs_suflags = emalloc(2 * sizeof(u_int32_t *)); - fs->lfs_suflags[0] = emalloc(fs->lfs_nseg * sizeof(u_int32_t)); - fs->lfs_suflags[1] = emalloc(fs->lfs_nseg * sizeof(u_int32_t)); + fs->lfs_suflags[0] = emalloc(lfs_sb_getnseg(fs) * sizeof(u_int32_t)); + fs->lfs_suflags[1] = emalloc(lfs_sb_getnseg(fs) * sizeof(u_int32_t)); } if (idaddr == 0) @@ -586,18 +586,18 @@ try_verify(struct lfs *osb, struct uvnode *devvp, ulfs_daddr_t goal, int debug) * Don't mistakenly read a superblock, if there is one here. */ if (lfs_sntod(osb, lfs_dtosn(osb, daddr)) == daddr) { - if (daddr == osb->lfs_s0addr) + if (daddr == lfs_sb_gets0addr(osb)) daddr += lfs_btofsb(osb, LFS_LABELPAD); for (i = 0; i < LFS_MAXNUMSB; i++) { - if (osb->lfs_sboffs[i] < daddr) + if (lfs_sb_getsboff(osb, i) < daddr) break; - if (osb->lfs_sboffs[i] == daddr) + if (lfs_sb_getsboff(osb, i) == daddr) daddr += lfs_btofsb(osb, LFS_SBPAD); } } /* Read in summary block */ - bread(devvp, LFS_FSBTODB(osb, daddr), osb->lfs_sumsize, + bread(devvp, LFS_FSBTODB(osb, daddr), lfs_sb_getsumsize(osb), 0, &bp); sp = (SEGSUM *)bp->b_data; @@ -605,30 +605,31 @@ try_verify(struct lfs *osb, struct uvnode *devvp, ulfs_daddr_t goal, int debug) * Check for a valid segment summary belonging to our fs. */ if (sp->ss_magic != SS_MAGIC || - sp->ss_ident != osb->lfs_ident || + sp->ss_ident != lfs_sb_getident(osb) || sp->ss_serial < serial || /* XXX strengthen this */ - sp->ss_sumsum != cksum(&sp->ss_datasum, osb->lfs_sumsize - + sp->ss_sumsum != cksum(&sp->ss_datasum, lfs_sb_getsumsize(osb) - sizeof(sp->ss_sumsum))) { brelse(bp, 0); if (debug) { if (sp->ss_magic != SS_MAGIC) - pwarn("pseg at 0x%x: " + pwarn("pseg at 0x%jx: " "wrong magic number\n", - (int)daddr); - else if (sp->ss_ident != osb->lfs_ident) - pwarn("pseg at 0x%x: " - "expected ident %llx, got %llx\n", - (int)daddr, - (long long)sp->ss_ident, - (long long)osb->lfs_ident); + (uintmax_t)daddr); + else if (sp->ss_ident != lfs_sb_getident(osb)) + pwarn("pseg at 0x%jx: " + "expected ident %jx, got %jx\n", + (uintmax_t)daddr, + (uintmax_t)sp->ss_ident, + (uintmax_t)lfs_sb_getident(osb)); else if (sp->ss_serial >= serial) - pwarn("pseg at 0x%x: " - "serial %d < %d\n", (int)daddr, + pwarn("pseg at 0x%jx: " + "serial %d < %d\n", + (uintmax_t)daddr, (int)sp->ss_serial, (int)serial); else - pwarn("pseg at 0x%x: " + pwarn("pseg at 0x%jx: " "summary checksum wrong\n", - (int)daddr); + (uintmax_t)daddr); } break; } @@ -646,10 +647,10 @@ try_verify(struct lfs *osb, struct uvnode *devvp, ulfs_daddr_t goal, int debug) (int)sp->ss_serial); assert (bc > 0); odaddr = daddr; - daddr += lfs_btofsb(osb, osb->lfs_sumsize + bc); + daddr += lfs_btofsb(osb, lfs_sb_getsumsize(osb) + bc); if (lfs_dtosn(osb, odaddr) != lfs_dtosn(osb, daddr) || lfs_dtosn(osb, daddr) != lfs_dtosn(osb, daddr + - lfs_btofsb(osb, osb->lfs_sumsize + lfs_sb_getbsize(osb)) - 1)) { + lfs_btofsb(osb, lfs_sb_getsumsize(osb) + lfs_sb_getbsize(osb)) - 1)) { daddr = sp->ss_next; } @@ -754,28 +755,28 @@ check_summary(struct lfs *fs, SEGSUM *sp, ulfs_daddr_t pseg_addr, int debug, /* Count the blocks. */ nblocks = howmany(sp->ss_ninos, LFS_INOPB(fs)); - bc = nblocks << (fs->lfs_version > 1 ? fs->lfs_ffshift : fs->lfs_bshift); + bc = nblocks << (fs->lfs_version > 1 ? lfs_sb_getffshift(fs) : lfs_sb_getbshift(fs)); assert(bc >= 0); fp = (FINFO *) (sp + 1); for (i = 0; i < sp->ss_nfinfo; i++) { nblocks += fp->fi_nblocks; bc += fp->fi_lastlength + ((fp->fi_nblocks - 1) - << fs->lfs_bshift); + << lfs_sb_getbshift(fs)); assert(bc >= 0); fp = (FINFO *) (fp->fi_blocks + fp->fi_nblocks); - if (((char *)fp) - (char *)sp > fs->lfs_sumsize) + if (((char *)fp) - (char *)sp > lfs_sb_getsumsize(fs)) return 0; } datap = emalloc(nblocks * sizeof(*datap)); datac = 0; dp = (ulfs_daddr_t *) sp; - dp += fs->lfs_sumsize / sizeof(ulfs_daddr_t); + dp += lfs_sb_getsumsize(fs) / sizeof(ulfs_daddr_t); dp--; idp = dp; - daddr = pseg_addr + lfs_btofsb(fs, fs->lfs_sumsize); + daddr = pseg_addr + lfs_btofsb(fs, lfs_sb_getsumsize(fs)); fp = (FINFO *) (sp + 1); for (i = 0, j = 0; i < sp->ss_nfinfo || j < howmany(sp->ss_ninos, LFS_INOPB(fs)); i++) { @@ -789,13 +790,13 @@ check_summary(struct lfs *fs, SEGSUM *sp, ulfs_daddr_t pseg_addr, int debug, break; } while (j < howmany(sp->ss_ninos, LFS_INOPB(fs)) && *idp == daddr) { - bread(devvp, LFS_FSBTODB(fs, daddr), fs->lfs_ibsize, + bread(devvp, LFS_FSBTODB(fs, daddr), lfs_sb_getibsize(fs), 0, &bp); datap[datac++] = ((u_int32_t *) (bp->b_data))[0]; brelse(bp, 0); ++j; - daddr += lfs_btofsb(fs, fs->lfs_ibsize); + daddr += lfs_btofsb(fs, lfs_sb_getibsize(fs)); --idp; } if (i < sp->ss_nfinfo) { @@ -946,7 +947,7 @@ extend_ifile(struct lfs *fs) LFS_BWRITE_LOG(bp); #ifdef IN_FSCK_LFS - reset_maxino(((ip->i_ffs1_size >> fs->lfs_bshift) + reset_maxino(((ip->i_ffs1_size >> lfs_sb_getbshift(fs)) - lfs_sb_getsegtabsz(fs) - lfs_sb_getcleansz(fs)) * lfs_sb_getifpb(fs)); #endif diff --git a/sbin/fsck_lfs/main.c b/sbin/fsck_lfs/main.c index 2c2cff11ab6c..dff94a4eb33b 100644 --- a/sbin/fsck_lfs/main.c +++ b/sbin/fsck_lfs/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.50 2015/07/24 06:56:41 dholland Exp $ */ +/* $NetBSD: main.c,v 1.51 2015/07/24 06:59:32 dholland Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -224,7 +224,7 @@ checkfilesys(const char *filesys, char *mntpt, long auxdata, int child) * else. */ if (preen == 0) { - printf("** Last Mounted on %s\n", fs->lfs_fsmnt); + printf("** Last Mounted on %s\n", lfs_sb_getfsmnt(fs)); if (hotroot()) printf("** Root file system\n"); /* diff --git a/sbin/fsck_lfs/pass1.c b/sbin/fsck_lfs/pass1.c index 6f6765f8a51e..77fd2f760a3e 100644 --- a/sbin/fsck_lfs/pass1.c +++ b/sbin/fsck_lfs/pass1.c @@ -1,4 +1,4 @@ -/* $NetBSD: pass1.c,v 1.38 2015/07/24 06:56:41 dholland Exp $ */ +/* $NetBSD: pass1.c,v 1.39 2015/07/24 06:59:32 dholland Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -227,8 +227,8 @@ checkinode(ino_t inumber, struct inodesc * idesc) * Fake ndb value so direct/indirect block checks below * will detect any garbage after symlink string. */ - if (dp->di_size < fs->lfs_maxsymlinklen || - (fs->lfs_maxsymlinklen == 0 && dp->di_blocks == 0)) { + if (dp->di_size < lfs_sb_getmaxsymlinklen(fs) || + (lfs_sb_getmaxsymlinklen(fs) == 0 && dp->di_blocks == 0)) { ndb = howmany(dp->di_size, sizeof(ulfs_daddr_t)); if (ndb > ULFS_NDADDR) { j = ndb - ULFS_NDADDR; diff --git a/sbin/fsck_lfs/pass5.c b/sbin/fsck_lfs/pass5.c index e7fe4e916936..766d0cb6ac8f 100644 --- a/sbin/fsck_lfs/pass5.c +++ b/sbin/fsck_lfs/pass5.c @@ -1,4 +1,4 @@ -/* $NetBSD: pass5.c,v 1.30 2015/07/24 06:56:41 dholland Exp $ */ +/* $NetBSD: pass5.c,v 1.31 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 2000, 2003 The NetBSD Foundation, Inc. @@ -77,7 +77,7 @@ pass5(void) avail = 0; bb = ubb = 0; dmeta = 0; - for (i = 0; i < fs->lfs_nseg; i++) { + for (i = 0; i < lfs_sb_getnseg(fs); i++) { diddirty = 0; LFS_SEGENTRY(su, fs, i, bp); if (!preen && !(su->su_flags & SEGUSE_DIRTY) && @@ -106,23 +106,23 @@ pass5(void) } if (su->su_flags & SEGUSE_DIRTY) { bb += lfs_btofsb(fs, su->su_nbytes + - su->su_nsums * fs->lfs_sumsize); + su->su_nsums * lfs_sb_getsumsize(fs)); ubb += lfs_btofsb(fs, su->su_nbytes + - su->su_nsums * fs->lfs_sumsize + - su->su_ninos * fs->lfs_ibsize); + su->su_nsums * lfs_sb_getsumsize(fs) + + su->su_ninos * lfs_sb_getibsize(fs)); dmeta += lfs_btofsb(fs, - fs->lfs_sumsize * su->su_nsums); + lfs_sb_getsumsize(fs) * su->su_nsums); dmeta += lfs_btofsb(fs, - fs->lfs_ibsize * su->su_ninos); + lfs_sb_getibsize(fs) * su->su_ninos); } else { nclean++; avail += lfs_segtod(fs, 1); if (su->su_flags & SEGUSE_SUPERBLOCK) avail -= lfs_btofsb(fs, LFS_SBPAD); if (i == 0 && fs->lfs_version > 1 && - fs->lfs_s0addr < lfs_btofsb(fs, LFS_LABELPAD)) + lfs_sb_gets0addr(fs) < lfs_btofsb(fs, LFS_LABELPAD)) avail -= lfs_btofsb(fs, LFS_LABELPAD) - - fs->lfs_s0addr; + lfs_sb_gets0addr(fs); } if (diddirty) VOP_BWRITE(bp); @@ -134,19 +134,19 @@ pass5(void) i = lfs_dtosn(fs, lfs_sb_getoffset(fs)); avail += lfs_sntod(fs, i + 1) - lfs_sb_getoffset(fs); /* But do not count minfreesegs */ - avail -= lfs_segtod(fs, (fs->lfs_minfreeseg - - (fs->lfs_minfreeseg / 2))); + avail -= lfs_segtod(fs, (lfs_sb_getminfreeseg(fs) - + (lfs_sb_getminfreeseg(fs) / 2))); /* Note we may have bytes to write yet */ avail -= lfs_btofsb(fs, locked_queue_bytes); if (idaddr) pwarn("NOTE: when using -i, expect discrepancies in dmeta," " avail, nclean, bfree\n"); - if (dmeta != fs->lfs_dmeta) { - pwarn("DMETA GIVEN AS %d, SHOULD BE %ld\n", fs->lfs_dmeta, - dmeta); + if (dmeta != lfs_sb_getdmeta(fs)) { + pwarn("DMETA GIVEN AS %d, SHOULD BE %ld\n", + lfs_sb_getdmeta(fs), dmeta); if (preen || reply("FIX")) { - fs->lfs_dmeta = dmeta; + lfs_sb_setdmeta(fs, dmeta); sbdirty(); } } @@ -158,18 +158,18 @@ pass5(void) sbdirty(); } } - if (nclean != fs->lfs_nclean) { - pwarn("NCLEAN GIVEN AS %d, SHOULD BE %d\n", fs->lfs_nclean, + if (nclean != lfs_sb_getnclean(fs)) { + pwarn("NCLEAN GIVEN AS %d, SHOULD BE %d\n", lfs_sb_getnclean(fs), nclean); if (preen || reply("FIX")) { - fs->lfs_nclean = nclean; + lfs_sb_setnclean(fs, nclean); sbdirty(); } } labelskew = 0; if (fs->lfs_version > 1 && - fs->lfs_s0addr < lfs_btofsb(fs, LFS_LABELPAD)) + lfs_sb_gets0addr(fs) < lfs_btofsb(fs, LFS_LABELPAD)) labelskew = lfs_btofsb(fs, LFS_LABELPAD); if (lfs_sb_getbfree(fs) > lfs_sb_getdsize(fs) - bb - labelskew || lfs_sb_getbfree(fs) < lfs_sb_getdsize(fs) - ubb - labelskew) { diff --git a/sbin/fsck_lfs/pass6.c b/sbin/fsck_lfs/pass6.c index f259304de0a0..e96ae69d5bfb 100644 --- a/sbin/fsck_lfs/pass6.c +++ b/sbin/fsck_lfs/pass6.c @@ -1,4 +1,4 @@ -/* $NetBSD: pass6.c,v 1.35 2015/07/24 06:56:41 dholland Exp $ */ +/* $NetBSD: pass6.c,v 1.36 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -152,15 +152,15 @@ rfw_update_single(struct uvnode *vp, daddr_t lbn, ulfs_daddr_t ndaddr, int size) } /* If block is beyond EOF, update size */ - if (lbn >= 0 && ip->i_ffs1_size <= (lbn << fs->lfs_bshift)) { - ip->i_ffs1_size = (lbn << fs->lfs_bshift) + 1; + if (lbn >= 0 && ip->i_ffs1_size <= (lbn << lfs_sb_getbshift(fs))) { + ip->i_ffs1_size = (lbn << lfs_sb_getbshift(fs)) + 1; } /* If block frag size is too large for old EOF, update size */ if (lbn < ULFS_NDADDR) { off_t minsize; - minsize = (lbn << fs->lfs_bshift); + minsize = (lbn << lfs_sb_getbshift(fs)); minsize += (size - lfs_sb_getfsize(fs)) + 1; if (ip->i_ffs1_size < minsize) ip->i_ffs1_size = minsize; @@ -292,7 +292,7 @@ pass6check(struct inodesc * idesc) anyout = anynew = 0; for (i = 0; i < idesc->id_numfrags; i++) { sn = lfs_dtosn(fs, idesc->id_blkno + i); - if (sn < 0 || sn >= fs->lfs_nseg || + if (sn < 0 || sn >= lfs_sb_getnseg(fs) || (seg_table[sn].su_flags & SEGUSE_DIRTY) == 0) { anyout = 1; break; @@ -583,7 +583,7 @@ pass6(void) * changes to any other inode. */ - ibbuf = emalloc(fs->lfs_ibsize); + ibbuf = emalloc(lfs_sb_getibsize(fs)); nnewfiles = ndelfiles = nmvfiles = nnewblocks = 0; daddr = lfs_sb_getoffset(fs); hassuper = 0; @@ -596,22 +596,22 @@ pass6(void) /* Could be a superblock */ if (lfs_sntod(fs, lfs_dtosn(fs, daddr)) == daddr) { - if (daddr == fs->lfs_s0addr) { + if (daddr == lfs_sb_gets0addr(fs)) { ++hassuper; daddr += lfs_btofsb(fs, LFS_LABELPAD); } for (i = 0; i < LFS_MAXNUMSB; i++) { - if (daddr == fs->lfs_sboffs[i]) { + if (daddr == lfs_sb_getsboff(fs, i)) { ++hassuper; daddr += lfs_btofsb(fs, LFS_SBPAD); } - if (daddr < fs->lfs_sboffs[i]) + if (daddr < lfs_sb_getsboff(fs, i)) break; } } /* Read in summary block */ - bread(devvp, LFS_FSBTODB(fs, daddr), fs->lfs_sumsize, 0, &bp); + bread(devvp, LFS_FSBTODB(fs, daddr), lfs_sb_getsumsize(fs), 0, &bp); sp = (SEGSUM *)bp->b_data; if (debug) pwarn("sum at 0x%x: ninos=%d nfinfo=%d\n", @@ -622,13 +622,13 @@ pass6(void) LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, daddr), sbp); ++sup->su_nsums; VOP_BWRITE(sbp); - lfs_sb_subbfree(fs, lfs_btofsb(fs, fs->lfs_sumsize)); - lfs_sb_adddmeta(fs, lfs_btofsb(fs, fs->lfs_sumsize)); + lfs_sb_subbfree(fs, lfs_btofsb(fs, lfs_sb_getsumsize(fs))); + lfs_sb_adddmeta(fs, lfs_btofsb(fs, lfs_sb_getsumsize(fs))); sbdirty(); if (lfs_sntod(fs, lfs_dtosn(fs, daddr)) == daddr + hassuper * lfs_btofsb(fs, LFS_SBPAD) && lfs_dtosn(fs, daddr) != lfs_dtosn(fs, lfs_sb_getoffset(fs))) { - --fs->lfs_nclean; + lfs_sb_subnclean(fs, 1); sbdirty(); } @@ -637,21 +637,21 @@ pass6(void) LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, daddr), sbp); sup->su_ninos += howmany(sp->ss_ninos, LFS_INOPB(fs)); VOP_BWRITE(sbp); - fs->lfs_dmeta += lfs_btofsb(fs, howmany(sp->ss_ninos, + lfs_sb_adddmeta(fs, lfs_btofsb(fs, howmany(sp->ss_ninos, LFS_INOPB(fs)) * - fs->lfs_ibsize); + lfs_sb_getibsize(fs))); } - idaddrp = ((ulfs_daddr_t *)((char *)bp->b_data + fs->lfs_sumsize)); + idaddrp = ((ulfs_daddr_t *)((char *)bp->b_data + lfs_sb_getsumsize(fs))); for (i = 0; i < howmany(sp->ss_ninos, LFS_INOPB(fs)); i++) { ino_t *inums; inums = ecalloc(LFS_INOPB(fs) + 1, sizeof(*inums)); ibdaddr = *--idaddrp; - lfs_sb_subbfree(fs, lfs_btofsb(fs, fs->lfs_ibsize)); + lfs_sb_subbfree(fs, lfs_btofsb(fs, lfs_sb_getibsize(fs))); sbdirty(); - bread(devvp, LFS_FSBTODB(fs, ibdaddr), fs->lfs_ibsize, - 0, &ibp); - memcpy(ibbuf, ibp->b_data, fs->lfs_ibsize); + bread(devvp, LFS_FSBTODB(fs, ibdaddr), + lfs_sb_getibsize(fs), 0, &ibp); + memcpy(ibbuf, ibp->b_data, lfs_sb_getibsize(fs)); brelse(ibp, 0); j = 0; @@ -777,10 +777,10 @@ pass6(void) lastserial = sp->ss_serial; } odaddr = daddr; - daddr += lfs_btofsb(fs, fs->lfs_sumsize + bc); + daddr += lfs_btofsb(fs, lfs_sb_getsumsize(fs) + bc); if (lfs_dtosn(fs, odaddr) != lfs_dtosn(fs, daddr) || lfs_dtosn(fs, daddr) != lfs_dtosn(fs, daddr + - lfs_btofsb(fs, fs->lfs_sumsize + lfs_sb_getbsize(fs)) - 1)) { + lfs_btofsb(fs, lfs_sb_getsumsize(fs) + lfs_sb_getbsize(fs)) - 1)) { daddr = ((SEGSUM *)bp->b_data)->ss_next; } brelse(bp, 0); @@ -825,19 +825,19 @@ pass6(void) /* Could be a superblock */ if (lfs_sntod(fs, lfs_dtosn(fs, daddr)) == daddr) { - if (daddr == fs->lfs_s0addr) + if (daddr == lfs_sb_gets0addr(fs)) daddr += lfs_btofsb(fs, LFS_LABELPAD); for (i = 0; i < LFS_MAXNUMSB; i++) { - if (daddr == fs->lfs_sboffs[i]) { + if (daddr == lfs_sb_getsboff(fs, i)) { daddr += lfs_btofsb(fs, LFS_SBPAD); } - if (daddr < fs->lfs_sboffs[i]) + if (daddr < lfs_sb_getsboff(fs, i)) break; } } /* Read in summary block */ - bread(devvp, LFS_FSBTODB(fs, daddr), fs->lfs_sumsize, 0, &bp); + bread(devvp, LFS_FSBTODB(fs, daddr), lfs_sb_getsumsize(fs), 0, &bp); sp = (SEGSUM *)bp->b_data; bc = check_summary(fs, sp, daddr, debug, devvp, pass6harvest); if (bc == 0) { @@ -847,7 +847,7 @@ pass6(void) break; } odaddr = daddr; - daddr += lfs_btofsb(fs, fs->lfs_sumsize + bc); + daddr += lfs_btofsb(fs, lfs_sb_getsumsize(fs) + bc); lfs_sb_subavail(fs, lfs_btofsb(fs, lfs_sb_getsumsize(fs) + bc)); if (lfs_dtosn(fs, odaddr) != lfs_dtosn(fs, daddr) || lfs_dtosn(fs, daddr) != lfs_dtosn(fs, daddr + @@ -863,12 +863,12 @@ pass6(void) /* Final address could also be a superblock */ if (lfs_sntod(fs, lfs_dtosn(fs, lastgood)) == lastgood) { - if (lastgood == fs->lfs_s0addr) + if (lastgood == lfs_sb_gets0addr(fs)) lastgood += lfs_btofsb(fs, LFS_LABELPAD); for (i = 0; i < LFS_MAXNUMSB; i++) { - if (lastgood == fs->lfs_sboffs[i]) + if (lastgood == lfs_sb_getsboff(fs, i)) lastgood += lfs_btofsb(fs, LFS_SBPAD); - if (lastgood < fs->lfs_sboffs[i]) + if (lastgood < lfs_sb_getsboff(fs, i)) break; } } @@ -877,7 +877,7 @@ pass6(void) lfs_sb_setoffset(fs, lastgood); lfs_sb_setcurseg(fs, lfs_sntod(fs, lfs_dtosn(fs, lastgood))); for (sn = curseg = lfs_dtosn(fs, lfs_sb_getcurseg(fs));;) { - sn = (sn + 1) % fs->lfs_nseg; + sn = (sn + 1) % lfs_sb_getnseg(fs); if (sn == curseg) errx(1, "no clean segments"); LFS_SEGENTRY(sup, fs, sn, bp); diff --git a/sbin/fsck_lfs/segwrite.c b/sbin/fsck_lfs/segwrite.c index 5959cf097d7a..9ad0d650a103 100644 --- a/sbin/fsck_lfs/segwrite.c +++ b/sbin/fsck_lfs/segwrite.c @@ -1,4 +1,4 @@ -/* $NetBSD: segwrite.c,v 1.32 2015/07/24 06:56:41 dholland Exp $ */ +/* $NetBSD: segwrite.c,v 1.33 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. * All rights reserved. @@ -252,7 +252,7 @@ lfs_writeinode(struct lfs * fs, struct segment * sp, struct inode * ip) 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 || + if (sp->seg_bytes_left < lfs_sb_getibsize(fs) || sp->sum_bytes_left < sizeof(ulfs_daddr_t)) (void) lfs_writeseg(fs, sp); @@ -261,7 +261,7 @@ lfs_writeinode(struct lfs * fs, struct segment * sp, struct inode * ip) lfs_sb_addoffset(fs, lfs_btofsb(fs, lfs_sb_getibsize(fs))); sp->ibp = *sp->cbpp++ = getblk(fs->lfs_devvp, LFS_FSBTODB(fs, daddr), - fs->lfs_ibsize); + lfs_sb_getibsize(fs)); sp->ibp->b_flags |= B_GATHERED; gotblk++; @@ -557,7 +557,7 @@ lfs_updatemeta(struct segment * sp) * that you cannot have fragments. */ sp->fip->fi_lastlength = ((sp->start_bpp[nblocks - 1]->b_bcount - 1) & - fs->lfs_bmask) + 1; + lfs_sb_getbmask(fs)) + 1; /* * Assign disk addresses, and update references to the logical @@ -576,7 +576,7 @@ lfs_updatemeta(struct segment * sp) * that the indirect block that actually ends the list * is of a smaller size!) */ - if ((sbp->b_bcount & fs->lfs_bmask) && i != 0) + if ((sbp->b_bcount & lfs_sb_getbmask(fs)) && i != 0) errx(EXIT_FAILURE, "%s: fragment is not last block", __func__); /* @@ -635,9 +635,9 @@ lfs_initseg(struct lfs * fs) brelse(bp, 0); /* Segment zero could also contain the labelpad */ if (fs->lfs_version > 1 && sp->seg_number == 0 && - fs->lfs_s0addr < lfs_btofsb(fs, LFS_LABELPAD)) { - lfs_sb_addoffset(fs, lfs_btofsb(fs, LFS_LABELPAD) - fs->lfs_s0addr); - sp->seg_bytes_left -= LFS_LABELPAD - lfs_fsbtob(fs, fs->lfs_s0addr); + lfs_sb_gets0addr(fs) < lfs_btofsb(fs, LFS_LABELPAD)) { + lfs_sb_addoffset(fs, lfs_btofsb(fs, LFS_LABELPAD) - lfs_sb_gets0addr(fs)); + sp->seg_bytes_left -= LFS_LABELPAD - lfs_fsbtob(fs, lfs_sb_gets0addr(fs)); } } else { sp->seg_number = lfs_dtosn(fs, lfs_sb_getcurseg(fs)); @@ -702,13 +702,13 @@ lfs_newseg(struct lfs * fs) LFS_CLEANERINFO(cip, fs, bp); --cip->clean; ++cip->dirty; - fs->lfs_nclean = cip->clean; + lfs_sb_setnclean(fs, cip->clean); LFS_SYNC_CLEANERINFO(cip, fs, bp, 1); lfs_sb_setlastseg(fs, lfs_sb_getcurseg(fs)); lfs_sb_setcurseg(fs, lfs_sb_getnextseg(fs)); for (sn = curseg = lfs_dtosn(fs, lfs_sb_getcurseg(fs)) + lfs_sb_getinterleave(fs);;) { - sn = (sn + 1) % fs->lfs_nseg; + sn = (sn + 1) % lfs_sb_getnseg(fs); if (sn == curseg) errx(EXIT_FAILURE, "%s: no clean segments", __func__); LFS_SEGENTRY(sup, fs, sn, bp); @@ -776,8 +776,8 @@ lfs_writeseg(struct lfs * fs, struct segment * sp) sup->su_lastmod = write_time; sup->su_ninos += ninos; ++sup->su_nsums; - fs->lfs_dmeta += (lfs_btofsb(fs, lfs_sb_getsumsize(fs)) + lfs_btofsb(fs, ninos * - fs->lfs_ibsize)); + lfs_sb_adddmeta(fs, (lfs_btofsb(fs, lfs_sb_getsumsize(fs)) + lfs_btofsb(fs, ninos * + lfs_sb_getibsize(fs)))); lfs_sb_subavail(fs, lfs_btofsb(fs, lfs_sb_getsumsize(fs))); do_again = !(bp->b_flags & B_GATHERED); @@ -810,7 +810,7 @@ lfs_writeseg(struct lfs * fs, struct segment * sp) ssp->ss_create = write_time; lfs_sb_addserial(fs, 1); ssp->ss_serial = lfs_sb_getserial(fs); - ssp->ss_ident = fs->lfs_ident; + ssp->ss_ident = lfs_sb_getident(fs); } /* Set the summary block busy too */ bremfree(*(sp->bpp)); @@ -950,8 +950,8 @@ lfs_segunlock(struct lfs * fs) fs->lfs_nactive = 0; /* Since we *know* everything's on disk, write both sbs */ - lfs_writesuper(fs, fs->lfs_sboffs[0]); - lfs_writesuper(fs, fs->lfs_sboffs[1]); + lfs_writesuper(fs, lfs_sb_getsboff(fs, 0)); + lfs_writesuper(fs, lfs_sb_getsboff(fs, 1)); --fs->lfs_seglock; fs->lfs_lockpid = 0; @@ -1003,7 +1003,7 @@ lfs_writesuper(struct lfs *fs, ulfs_daddr_t daddr) lfs_sb_settstamp(fs, write_time); /* Checksum the superblock and copy it into a buffer. */ - fs->lfs_cksum = lfs_sb_cksum(&(fs->lfs_dlfs)); + lfs_sb_setcksum(fs, lfs_sb_cksum(&(fs->lfs_dlfs))); assert(daddr > 0); bp = getblk(fs->lfs_devvp, LFS_FSBTODB(fs, daddr), LFS_SBPAD); memset(bp->b_data + sizeof(struct dlfs), 0, diff --git a/sbin/fsck_lfs/setup.c b/sbin/fsck_lfs/setup.c index 3491ed2ca32f..5467ca37f8c8 100644 --- a/sbin/fsck_lfs/setup.c +++ b/sbin/fsck_lfs/setup.c @@ -1,4 +1,4 @@ -/* $NetBSD: setup.c,v 1.47 2015/07/24 06:56:41 dholland Exp $ */ +/* $NetBSD: setup.c,v 1.48 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -218,7 +218,7 @@ setup(const char *dev) /* Resize buffer cache now that we have a superblock to guess from. */ bufrehash((lfs_sb_getsegtabsz(fs) + maxino / lfs_sb_getifpb(fs)) << 4); - if (fs->lfs_pflags & LFS_PF_CLEAN) { + if (lfs_sb_getpflags(fs) & LFS_PF_CLEAN) { if (doskipclean) { if (!quiet) pwarn("%sile system is clean; not checking\n", @@ -240,12 +240,12 @@ setup(const char *dev) (unsigned long)idaddr); tdaddr = lfs_sntod(fs, lfs_dtosn(fs, idaddr)); if (lfs_sntod(fs, lfs_dtosn(fs, tdaddr)) == tdaddr) { - if (tdaddr == fs->lfs_s0addr) + if (tdaddr == lfs_sb_gets0addr(fs)) tdaddr += lfs_btofsb(fs, LFS_LABELPAD); for (i = 0; i < LFS_MAXNUMSB; i++) { - if (fs->lfs_sboffs[i] == tdaddr) + if (lfs_sb_getsboff(fs, i) == tdaddr) tdaddr += lfs_btofsb(fs, LFS_SBPAD); - if (fs->lfs_sboffs[i] > tdaddr) + if (lfs_sb_getsboff(fs, i) > tdaddr) break; } } @@ -256,11 +256,11 @@ setup(const char *dev) (intmax_t)lfs_sb_getserial(fs)); while (tdaddr < idaddr) { bread(fs->lfs_devvp, LFS_FSBTODB(fs, tdaddr), - fs->lfs_sumsize, + lfs_sb_getsumsize(fs), 0, &bp); sp = (SEGSUM *)bp->b_data; if (sp->ss_sumsum != cksum(&sp->ss_datasum, - fs->lfs_sumsize - + lfs_sb_getsumsize(fs) - sizeof(sp->ss_sumsum))) { brelse(bp, 0); if (debug) @@ -270,11 +270,11 @@ setup(const char *dev) } fp = (FINFO *)(sp + 1); bc = howmany(sp->ss_ninos, LFS_INOPB(fs)) << - (fs->lfs_version > 1 ? fs->lfs_ffshift : - fs->lfs_bshift); + (fs->lfs_version > 1 ? lfs_sb_getffshift(fs) : + lfs_sb_getbshift(fs)); for (i = 0; i < sp->ss_nfinfo; i++) { bc += fp->fi_lastlength + ((fp->fi_nblocks - 1) - << fs->lfs_bshift); + << lfs_sb_getbshift(fs)); fp = (FINFO *)(fp->fi_blocks + fp->fi_nblocks); } @@ -290,8 +290,8 @@ setup(const char *dev) */ curseg = lfs_dtosn(fs, lfs_sb_getoffset(fs)); lfs_sb_setcurseg(fs, lfs_sntod(fs, curseg)); - for (sn = curseg + fs->lfs_interleave;;) { - sn = (sn + 1) % fs->lfs_nseg; + for (sn = curseg + lfs_sb_getinterleave(fs);;) { + sn = (sn + 1) % lfs_sb_getnseg(fs); if (sn == curseg) errx(1, "init: no clean segments"); LFS_SEGENTRY(sup, fs, sn, bp); @@ -304,7 +304,7 @@ setup(const char *dev) /* Skip superblock if necessary */ for (i = 0; i < LFS_MAXNUMSB; i++) - if (lfs_sb_getoffset(fs) == fs->lfs_sboffs[i]) + if (lfs_sb_getoffset(fs) == lfs_sb_getsboff(fs, i)) lfs_sb_addoffset(fs, lfs_btofsb(fs, LFS_SBPAD)); ++fs->lfs_nactive; @@ -330,13 +330,13 @@ setup(const char *dev) pwarn("lfs_bsize = %lu\n", (unsigned long) lfs_sb_getbsize(fs)); pwarn("lfs_fsize = %lu\n", (unsigned long) lfs_sb_getfsize(fs)); pwarn("lfs_frag = %lu\n", (unsigned long) lfs_sb_getfrag(fs)); - pwarn("lfs_inopb = %lu\n", (unsigned long) fs->lfs_inopb); + pwarn("lfs_inopb = %lu\n", (unsigned long) lfs_sb_getinopb(fs)); } if (fs->lfs_version == 1) maxfsblock = lfs_sb_getsize(fs) * (lfs_sb_getbsize(fs) / dev_bsize); else maxfsblock = lfs_sb_getsize(fs); - maxfilesize = calcmaxfilesize(fs->lfs_bshift); + maxfilesize = calcmaxfilesize(lfs_sb_getbshift(fs)); if (/* lfs_sb_getminfree(fs) < 0 || */ lfs_sb_getminfree(fs) > 99) { pfatal("IMPOSSIBLE MINFREE=%u IN SUPERBLOCK", lfs_sb_getminfree(fs)); @@ -345,53 +345,55 @@ setup(const char *dev) sbdirty(); } } - if (fs->lfs_bmask != lfs_sb_getbsize(fs) - 1) { - pwarn("INCORRECT BMASK=0x%x IN SUPERBLOCK (SHOULD BE 0x%x)", - (unsigned int) fs->lfs_bmask, - (unsigned int) lfs_sb_getbsize(fs) - 1); - fs->lfs_bmask = lfs_sb_getbsize(fs) - 1; + if (lfs_sb_getbmask(fs) != lfs_sb_getbsize(fs) - 1) { + pwarn("INCORRECT BMASK=0x%jx IN SUPERBLOCK (SHOULD BE 0x%x)", + (uintmax_t)lfs_sb_getbmask(fs), + lfs_sb_getbsize(fs) - 1); + lfs_sb_setbmask(fs, lfs_sb_getbsize(fs) - 1); if (preen) printf(" (FIXED)\n"); if (preen || reply("FIX") == 1) { sbdirty(); } } - if (fs->lfs_ffmask != lfs_sb_getfsize(fs) - 1) { - pwarn("INCORRECT FFMASK=%" PRId64 " IN SUPERBLOCK", - fs->lfs_ffmask); - fs->lfs_ffmask = lfs_sb_getfsize(fs) - 1; + if (lfs_sb_getffmask(fs) != lfs_sb_getfsize(fs) - 1) { + pwarn("INCORRECT FFMASK=0x%jx IN SUPERBLOCK (SHOULD BE 0x%x)", + (uintmax_t)lfs_sb_getffmask(fs), + lfs_sb_getfsize(fs) - 1); + lfs_sb_setffmask(fs, lfs_sb_getfsize(fs) - 1); if (preen) printf(" (FIXED)\n"); if (preen || reply("FIX") == 1) { sbdirty(); } } - if (fs->lfs_fbmask != (1 << fs->lfs_fbshift) - 1) { - pwarn("INCORRECT FBMASK=%" PRId64 " IN SUPERBLOCK", - fs->lfs_fbmask); - fs->lfs_fbmask = (1 << fs->lfs_fbshift) - 1; + if (lfs_sb_getfbmask(fs) != (1U << lfs_sb_getfbshift(fs)) - 1) { + pwarn("INCORRECT FBMASK=0x%jx IN SUPERBLOCK (SHOULD BE 0x%x)", + (uintmax_t)lfs_sb_getfbmask(fs), + (1U << lfs_sb_getfbshift(fs)) - 1); + lfs_sb_setfbmask(fs, (1U << lfs_sb_getfbshift(fs)) - 1); if (preen) printf(" (FIXED)\n"); if (preen || reply("FIX") == 1) { sbdirty(); } } - if (fs->lfs_maxfilesize != maxfilesize) { + if (lfs_sb_getmaxfilesize(fs) != maxfilesize) { pwarn( - "INCORRECT MAXFILESIZE=%llu IN SUPERBLOCK (SHOULD BE %llu WITH BSHIFT %d)", - (unsigned long long) fs->lfs_maxfilesize, - (unsigned long long) maxfilesize, (int)fs->lfs_bshift); + "INCORRECT MAXFILESIZE=%llu IN SUPERBLOCK (SHOULD BE %llu WITH BSHIFT %u)", + (unsigned long long) lfs_sb_getmaxfilesize(fs), + (unsigned long long) maxfilesize, lfs_sb_getbshift(fs)); if (preen) printf(" (FIXED)\n"); if (preen || reply("FIX") == 1) { - fs->lfs_maxfilesize = maxfilesize; + lfs_sb_setmaxfilesize(fs, maxfilesize); sbdirty(); } } - if (fs->lfs_maxsymlinklen != ULFS1_MAXSYMLINKLEN) { - pwarn("INCORRECT MAXSYMLINKLEN=%d IN SUPERBLOCK", - fs->lfs_maxsymlinklen); - fs->lfs_maxsymlinklen = ULFS1_MAXSYMLINKLEN; + if (lfs_sb_getmaxsymlinklen(fs) != ULFS1_MAXSYMLINKLEN) { + pwarn("INCORRECT MAXSYMLINKLEN=%d IN SUPERBLOCK (SHOULD BE %zu)", + lfs_sb_getmaxsymlinklen(fs), ULFS1_MAXSYMLINKLEN); + lfs_sb_setmaxsymlinklen(fs, ULFS1_MAXSYMLINKLEN); if (preen) printf(" (FIXED)\n"); if (preen || reply("FIX") == 1) { @@ -412,7 +414,7 @@ setup(const char *dev) if (debug) pwarn("maxino = %llu\n", (unsigned long long)maxino); for (i = 0; i < VTOI(ivp)->i_ffs1_size; i += lfs_sb_getbsize(fs)) { - bread(ivp, i >> fs->lfs_bshift, lfs_sb_getbsize(fs), 0, &bp); + bread(ivp, i >> lfs_sb_getbshift(fs), lfs_sb_getbsize(fs), 0, &bp); /* XXX check B_ERROR */ brelse(bp, 0); } @@ -421,9 +423,9 @@ setup(const char *dev) * allocate and initialize the necessary maps */ din_table = ecalloc(maxino, sizeof(*din_table)); - seg_table = ecalloc(fs->lfs_nseg, sizeof(SEGUSE)); + seg_table = ecalloc(lfs_sb_getnseg(fs), sizeof(SEGUSE)); /* Get segment flags */ - for (i = 0; i < fs->lfs_nseg; i++) { + for (i = 0; i < lfs_sb_getnseg(fs); i++) { LFS_SEGENTRY(sup, fs, i, bp); seg_table[i].su_flags = sup->su_flags & ~SEGUSE_ACTIVE; if (preen) diff --git a/sbin/fsck_lfs/utilities.c b/sbin/fsck_lfs/utilities.c index e197c3ab17e9..52da26c04cb0 100644 --- a/sbin/fsck_lfs/utilities.c +++ b/sbin/fsck_lfs/utilities.c @@ -1,4 +1,4 @@ -/* $NetBSD: utilities.c,v 1.38 2015/07/24 06:56:41 dholland Exp $ */ +/* $NetBSD: utilities.c,v 1.39 2015/07/24 06:59:32 dholland Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -120,8 +120,8 @@ write_superblocks(void) if (debug) pwarn("writing superblocks with lfs_idaddr = 0x%jx\n", (uintmax_t)lfs_sb_getidaddr(fs)); - lfs_writesuper(fs, fs->lfs_sboffs[0]); - lfs_writesuper(fs, fs->lfs_sboffs[1]); + lfs_writesuper(fs, lfs_sb_getsboff(fs, 0)); + lfs_writesuper(fs, lfs_sb_getsboff(fs, 1)); fsmodified = 1; } @@ -138,8 +138,8 @@ ckfini(int markclean) } } - if (!nflag && (fs->lfs_pflags & LFS_PF_CLEAN) == 0) { - fs->lfs_pflags |= LFS_PF_CLEAN; + if (!nflag && (lfs_sb_getpflags(fs) & LFS_PF_CLEAN) == 0) { + lfs_sb_setpflags(fs, lfs_sb_getpflags(fs) | LFS_PF_CLEAN); fsmodified = 1; } @@ -156,7 +156,7 @@ ckfini(int markclean) else if (!reply("MARK FILE SYSTEM CLEAN")) markclean = 0; if (markclean) { - fs->lfs_pflags |= LFS_PF_CLEAN; + lfs_sb_setpflags(fs, lfs_sb_getpflags(fs) | LFS_PF_CLEAN); sbdirty(); write_superblocks(); if (!preen) diff --git a/sbin/newfs_lfs/make_lfs.c b/sbin/newfs_lfs/make_lfs.c index b873ad473f51..31a8e3511c0c 100644 --- a/sbin/newfs_lfs/make_lfs.c +++ b/sbin/newfs_lfs/make_lfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: make_lfs.c,v 1.32 2015/07/24 06:56:41 dholland Exp $ */ +/* $NetBSD: make_lfs.c,v 1.33 2015/07/24 06:59:32 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.32 2015/07/24 06:56:41 dholland Exp $"); +__RCSID("$NetBSD: make_lfs.c,v 1.33 2015/07/24 06:59:32 dholland Exp $"); #endif #endif /* not lint */ @@ -231,7 +231,7 @@ make_dinode(ino_t ino, struct ulfs1_dinode *dip, int nfrags, struct lfs *fs) dip->di_nlink = 1; dip->di_blocks = nfrags; - dip->di_size = (nfrags << fs->lfs_ffshift); + dip->di_size = (nfrags << lfs_sb_getffshift(fs)); dip->di_atime = dip->di_mtime = dip->di_ctime = lfs_sb_gettstamp(fs); dip->di_atimensec = dip->di_mtimensec = dip->di_ctimensec = 0; dip->di_inumber = ino; @@ -400,34 +400,34 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree, tryagain: /* Modify parts of superblock overridden by command line arguments */ if (bsize != DFL_LFSBLOCK || fsize != DFL_LFSFRAG) { - fs->lfs_bshift = lfs_log2(bsize); - if (1 << fs->lfs_bshift != bsize) + lfs_sb_setbshift(fs, lfs_log2(bsize)); + if (1 << lfs_sb_getbshift(fs) != bsize) fatal("%d: block size not a power of 2", bsize); lfs_sb_setbsize(fs, bsize); lfs_sb_setfsize(fs, fsize); - fs->lfs_bmask = bsize - 1; - fs->lfs_ffmask = fsize - 1; - fs->lfs_ffshift = lfs_log2(fsize); - if (1 << fs->lfs_ffshift != fsize) + lfs_sb_setbmask(fs, bsize - 1); + lfs_sb_setffmask(fs, fsize - 1); + lfs_sb_setffshift(fs, lfs_log2(fsize)); + if (1 << lfs_sb_getffshift(fs) != fsize) fatal("%d: frag size not a power of 2", fsize); lfs_sb_setfrag(fs, lfs_numfrags(fs, bsize)); - fs->lfs_fbmask = lfs_sb_getfrag(fs) - 1; - fs->lfs_fbshift = lfs_log2(lfs_sb_getfrag(fs)); + lfs_sb_setfbmask(fs, lfs_sb_getfrag(fs) - 1); + lfs_sb_setfbshift(fs, lfs_log2(lfs_sb_getfrag(fs))); lfs_sb_setifpb(fs, bsize / sizeof(IFILE)); /* XXX ondisk32 */ - fs->lfs_nindir = bsize / sizeof(int32_t); + lfs_sb_setnindir(fs, bsize / sizeof(int32_t)); } if (fs->lfs_version == 1) { - fs->lfs_sumsize = LFS_V1_SUMMARY_SIZE; - fs->lfs_segshift = lfs_log2(ssize); - if (1 << fs->lfs_segshift != ssize) + lfs_sb_setsumsize(fs, LFS_V1_SUMMARY_SIZE); + lfs_sb_setsegshift(fs, lfs_log2(ssize)); + if (1 << lfs_sb_getsegshift(fs) != ssize) fatal("%d: segment size not power of 2", ssize); - fs->lfs_segmask = ssize - 1; + lfs_sb_setsegmask(fs, ssize - 1); lfs_sb_setifpb(fs, lfs_sb_getbsize(fs) / sizeof(IFILE_V1)); lfs_sb_setibsize(fs, lfs_sb_getbsize(fs)); lfs_sb_setsepb(fs, bsize / sizeof(SEGUSE_V1)); - lfs_sb_setssize(fs, ssize >> fs->lfs_bshift); + lfs_sb_setssize(fs, ssize >> lfs_sb_getbshift(fs)); } else { if (ssize % fsize) { fprintf(stderr, @@ -437,22 +437,22 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree, fprintf(stderr, "trying size %d.\n", ssize); goto tryagain; } - fs->lfs_sumsize = fsize; - fs->lfs_segshift = 0; - fs->lfs_segmask = 0; + lfs_sb_setsumsize(fs, fsize); + lfs_sb_setsegshift(fs, 0); + lfs_sb_setsegmask(fs, 0); lfs_sb_setsepb(fs, bsize / sizeof(SEGUSE)); lfs_sb_setssize(fs, ssize); lfs_sb_setibsize(fs, ibsize); } - fs->lfs_inopb = fs->lfs_ibsize / sizeof(struct ulfs1_dinode); + lfs_sb_setinopb(fs, lfs_sb_getibsize(fs) / sizeof(struct ulfs1_dinode)); lfs_sb_setminfree(fs, minfree); if (version > 1) { lfs_sb_setinopf(fs, secsize/LFS_DINODE1_SIZE); - fs->lfs_interleave = interleave; + lfs_sb_setinterleave(fs, interleave); if (roll_id == 0) roll_id = arc4random(); - fs->lfs_ident = roll_id; + lfs_sb_setident(fs, roll_id); } /* @@ -460,43 +460,43 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree, * size, disk geometry and current time. * * XXX: this seems to set dlfs_size wrong for version 1... as in, - * sets it and then overwrites it. + * sets it and then overwrites it a few lines later. */ db_per_blk = bsize/secsize; - fs->lfs_blktodb = lfs_log2(db_per_blk); - fs->lfs_fsbtodb = lfs_log2(fsize / secsize); + lfs_sb_setblktodb(fs, lfs_log2(db_per_blk)); + lfs_sb_setfsbtodb(fs, lfs_log2(fsize / secsize)); if (version == 1) { - fs->lfs_sushift = lfs_log2(lfs_sb_getsepb(fs)); - fs->lfs_fsbtodb = 0; - lfs_sb_setsize(fs, dkw->dkw_size >> fs->lfs_blktodb); + lfs_sb_setsushift(fs, lfs_log2(lfs_sb_getsepb(fs))); + lfs_sb_setfsbtodb(fs, 0); + lfs_sb_setsize(fs, dkw->dkw_size >> lfs_sb_getblktodb(fs)); } label_fsb = lfs_btofsb(fs, roundup(LFS_LABELPAD, fsize)); sb_fsb = lfs_btofsb(fs, roundup(LFS_SBPAD, fsize)); - fs->lfs_fsbpseg = LFS_DBTOFSB(fs, ssize / secsize); - lfs_sb_setsize(fs, dkw->dkw_size >> fs->lfs_fsbtodb); + lfs_sb_setfsbpseg(fs, LFS_DBTOFSB(fs, ssize / secsize)); + lfs_sb_setsize(fs, dkw->dkw_size >> lfs_sb_getfsbtodb(fs)); lfs_sb_setdsize(fs, LFS_DBTOFSB(fs, dkw->dkw_size) - MAX(label_fsb, LFS_DBTOFSB(fs, start))); - fs->lfs_nseg = lfs_sb_getdsize(fs) / lfs_segtod(fs, 1); + lfs_sb_setnseg(fs, lfs_sb_getdsize(fs) / lfs_segtod(fs, 1)); - fs->lfs_nclean = fs->lfs_nseg - 1; - fs->lfs_maxfilesize = maxfilesize(fs->lfs_bshift); + lfs_sb_setnclean(fs, lfs_sb_getnseg(fs) - 1); + lfs_sb_setmaxfilesize(fs, maxfilesize(lfs_sb_getbshift(fs))); if (minfreeseg == 0) - fs->lfs_minfreeseg = fs->lfs_nseg / DFL_MIN_FREE_SEGS; + lfs_sb_setminfreeseg(fs, lfs_sb_getnseg(fs) / DFL_MIN_FREE_SEGS); else - fs->lfs_minfreeseg = minfreeseg; - if (fs->lfs_minfreeseg < MIN_FREE_SEGS) - fs->lfs_minfreeseg = MIN_FREE_SEGS; + lfs_sb_setminfreeseg(fs, minfreeseg); + if (lfs_sb_getminfreeseg(fs) < MIN_FREE_SEGS) + lfs_sb_setminfreeseg(fs, MIN_FREE_SEGS); if (resvseg == 0) - fs->lfs_resvseg = fs->lfs_minfreeseg / 2 + 1; + lfs_sb_setresvseg(fs, lfs_sb_getminfreeseg(fs) / 2 + 1); else - fs->lfs_resvseg = resvseg; - if (fs->lfs_resvseg < MIN_RESV_SEGS) - fs->lfs_resvseg = MIN_RESV_SEGS; + lfs_sb_setresvseg(fs, resvseg); + if (lfs_sb_getresvseg(fs) < MIN_RESV_SEGS) + lfs_sb_setresvseg(fs, MIN_RESV_SEGS); - if(fs->lfs_nseg < (4 * fs->lfs_minfreeseg) - || fs->lfs_nseg < LFS_MIN_SBINTERVAL + 1) + if(lfs_sb_getnseg(fs) < (4 * lfs_sb_getminfreeseg(fs)) + || lfs_sb_getnseg(fs) < LFS_MIN_SBINTERVAL + 1) { if(seg_size == 0 && ssize > (bsize<<1)) { if(!warned_segtoobig) { @@ -526,13 +526,13 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree, */ printf("Creating a version %d LFS", fs->lfs_version); if (fs->lfs_version > 1) - printf(" with roll-forward ident 0x%x", fs->lfs_ident); + printf(" with roll-forward ident 0x%x", lfs_sb_getident(fs)); printf("\n"); - fssize = (double)fs->lfs_nseg; + fssize = (double)lfs_sb_getnseg(fs); fssize *= (double)ssize; fssize /= 1048576.0; printf("%.1fMB in %d segments of size %d\n", fssize, - fs->lfs_nseg, ssize); + lfs_sb_getnseg(fs), ssize); /* * The number of free blocks is set from the number of segments @@ -542,7 +542,7 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree, * and segment usage table, and half a block per segment that can't * be written due to fragmentation. */ - lfs_sb_setdsize(fs, (fs->lfs_nseg - fs->lfs_minfreeseg) * + lfs_sb_setdsize(fs, (lfs_sb_getnseg(fs) - lfs_sb_getminfreeseg(fs)) * lfs_segtod(fs, 1)); lfs_sb_setbfree(fs, lfs_sb_getdsize(fs)); lfs_sb_subbfree(fs, LFS_DBTOFSB(fs, ((lfs_sb_getnseg(fs) / 2) << @@ -556,7 +556,7 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree, if (version == 1) lfs_sb_setotstamp(fs, stamp); - if ((sb_interval = fs->lfs_nseg / LFS_MAXNUMSB) < LFS_MIN_SBINTERVAL) + if ((sb_interval = lfs_sb_getnseg(fs) / LFS_MAXNUMSB) < LFS_MIN_SBINTERVAL) sb_interval = LFS_MIN_SBINTERVAL; /* @@ -576,27 +576,27 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree, start, btodb(LFS_LABELPAD), btodb(LFS_LABELPAD + LFS_SBPAD)); } - fs->lfs_sboffs[0] = label_fsb; + lfs_sb_setsboff(fs, 0, label_fsb); if (version == 1) - fs->lfs_s0addr = fs->lfs_sboffs[0]; + lfs_sb_sets0addr(fs, lfs_sb_getsboff(fs, 0)); else - fs->lfs_s0addr = LFS_DBTOFSB(fs, start); + lfs_sb_sets0addr(fs, LFS_DBTOFSB(fs, start)); lfs_sb_setdsize(fs, lfs_sb_getdsize(fs) - sb_fsb); for (i = 1; i < LFS_MAXNUMSB; i++) { sb_addr = ((i * sb_interval) * lfs_segtod(fs, 1)) - + fs->lfs_sboffs[0]; + + lfs_sb_getsboff(fs, 0); /* Segment 0 eats the label, except for version 1 */ - if (fs->lfs_version > 1 && fs->lfs_s0addr < label_fsb) + if (fs->lfs_version > 1 && lfs_sb_gets0addr(fs) < label_fsb) sb_addr -= label_fsb - start; if (sb_addr + sizeof(struct dlfs) >= LFS_DBTOFSB(fs, dkw->dkw_size)) break; - fs->lfs_sboffs[i] = sb_addr; + lfs_sb_setsboff(fs, i, sb_addr); lfs_sb_setdsize(fs, lfs_sb_getdsize(fs) - sb_fsb); } /* We need >= 2 superblocks */ - if(fs->lfs_sboffs[1] == 0x0) { + if (lfs_sb_getsboff(fs, 1) == 0x0) { fatal("Could not assign a disk address for the second " "superblock.\nPlease decrease the segment size.\n"); } @@ -619,8 +619,8 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree, dip->di_flags = SF_IMMUTABLE; make_dinode(LFS_IFILE_INUM, dip, lfs_blkstofrags(fs, lfs_sb_getcleansz(fs) + lfs_sb_getsegtabsz(fs) + 1), fs); - dip->di_size = (lfs_sb_getcleansz(fs) + lfs_sb_getsegtabsz(fs) + 1) << fs->lfs_bshift; - for (i = 0; i < ULFS_NDADDR && i < (dip->di_size >> fs->lfs_bshift); i++) + dip->di_size = (lfs_sb_getcleansz(fs) + lfs_sb_getsegtabsz(fs) + 1) << lfs_sb_getbshift(fs); + for (i = 0; i < ULFS_NDADDR && i < (dip->di_size >> lfs_sb_getbshift(fs)); i++) VTOI(fs->lfs_ivnode)->i_lfs_fragsize[i] = lfs_sb_getbsize(fs); /* @@ -629,10 +629,10 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree, fs->lfs_suflags = (u_int32_t **) malloc(2 * sizeof(u_int32_t *)); if (fs->lfs_suflags == NULL) err(1, NULL); - fs->lfs_suflags[0] = (u_int32_t *) malloc(fs->lfs_nseg * sizeof(u_int32_t)); + fs->lfs_suflags[0] = (u_int32_t *) malloc(lfs_sb_getnseg(fs) * sizeof(u_int32_t)); if (fs->lfs_suflags[0] == NULL) err(1, NULL); - fs->lfs_suflags[1] = (u_int32_t *) malloc(fs->lfs_nseg * sizeof(u_int32_t)); + fs->lfs_suflags[1] = (u_int32_t *) malloc(lfs_sb_getnseg(fs) * sizeof(u_int32_t)); if (fs->lfs_suflags[1] == NULL) err(1, NULL); @@ -640,7 +640,7 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree, * Initialize the cleanerinfo block */ LFS_CLEANERINFO(cip, fs, bp); - cip->clean = fs->lfs_nseg; + cip->clean = lfs_sb_getnseg(fs); cip->dirty = 0; if (version > 1) { cip->free_head = HIGHEST_USED_INO + 1; @@ -651,11 +651,11 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree, /* * Run through segment table and initialize that */ - for (i = j = 0; i < fs->lfs_nseg; i++) { + for (i = j = 0; i < lfs_sb_getnseg(fs); i++) { LFS_SEGENTRY(segp, fs, i, bp); if (i == 0 && - fs->lfs_s0addr < lfs_btofsb(fs, LFS_LABELPAD + LFS_SBPAD)) { + lfs_sb_gets0addr(fs) < lfs_btofsb(fs, LFS_LABELPAD + LFS_SBPAD)) { segp->su_flags = SEGUSE_SUPERBLOCK; lfs_sb_subbfree(fs, sb_fsb); ++j; @@ -770,26 +770,26 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree, */ lfs_sb_setavail(fs, 0); bb = ubb = dmeta = 0; - for (i = 0; i < fs->lfs_nseg; i++) { + for (i = 0; i < lfs_sb_getnseg(fs); i++) { LFS_SEGENTRY(segp, fs, i, bp); if (segp->su_flags & SEGUSE_DIRTY) { bb += lfs_btofsb(fs, segp->su_nbytes + - segp->su_nsums * fs->lfs_sumsize); + segp->su_nsums * lfs_sb_getsumsize(fs)); ubb += lfs_btofsb(fs, segp->su_nbytes + - segp->su_nsums * fs->lfs_sumsize + - segp->su_ninos * fs->lfs_ibsize); + segp->su_nsums * lfs_sb_getsumsize(fs) + + segp->su_ninos * lfs_sb_getibsize(fs)); dmeta += lfs_btofsb(fs, - fs->lfs_sumsize * segp->su_nsums); + lfs_sb_getsumsize(fs) * segp->su_nsums); dmeta += lfs_btofsb(fs, - fs->lfs_ibsize * segp->su_ninos); + lfs_sb_getibsize(fs) * segp->su_ninos); } else { lfs_sb_addavail(fs, lfs_segtod(fs, 1)); if (segp->su_flags & SEGUSE_SUPERBLOCK) lfs_sb_subavail(fs, lfs_btofsb(fs, LFS_SBPAD)); if (i == 0 && fs->lfs_version > 1 && - fs->lfs_s0addr < lfs_btofsb(fs, LFS_LABELPAD)) + lfs_sb_gets0addr(fs) < lfs_btofsb(fs, LFS_LABELPAD)) lfs_sb_subavail(fs, lfs_btofsb(fs, LFS_LABELPAD) - - fs->lfs_s0addr); + lfs_sb_gets0addr(fs)); } brelse(bp, 0); } @@ -797,10 +797,10 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree, i = lfs_dtosn(fs, lfs_sb_getoffset(fs)); lfs_sb_addavail(fs, lfs_sntod(fs, i + 1) - lfs_sb_getoffset(fs)); /* But do not count minfreesegs */ - lfs_sb_subavail(fs, lfs_segtod(fs, (fs->lfs_minfreeseg - (fs->lfs_minfreeseg / 2)))); + lfs_sb_subavail(fs, lfs_segtod(fs, (lfs_sb_getminfreeseg(fs) - (lfs_sb_getminfreeseg(fs) / 2)))); labelskew = 0; - if (fs->lfs_version > 1 && fs->lfs_s0addr < lfs_btofsb(fs, LFS_LABELPAD)) + if (fs->lfs_version > 1 && lfs_sb_gets0addr(fs) < lfs_btofsb(fs, LFS_LABELPAD)) labelskew = lfs_btofsb(fs, LFS_LABELPAD); lfs_sb_setbfree(fs, lfs_sb_getdsize(fs) - labelskew - (ubb + bb) / 2); @@ -818,7 +818,7 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree, printf("super-block backups (for fsck -b #) at:\n"); curw = 0; for (i = 0; i < LFS_MAXNUMSB; i++) { - seg_addr = fs->lfs_sboffs[i]; + seg_addr = lfs_sb_getsboff(fs, i); if (seg_addr == 0) break; @@ -837,7 +837,7 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree, /* Leave the time stamp on the alt sb, zero the rest */ if (i == 2) { lfs_sb_settstamp(fs, 0); - fs->lfs_cksum = lfs_sb_cksum(&(fs->lfs_dlfs)); + lfs_sb_setcksum(fs, lfs_sb_cksum(&(fs->lfs_dlfs))); } if (!Nflag) lfs_writesuper(fs, seg_addr); diff --git a/sbin/resize_lfs/resize_lfs.c b/sbin/resize_lfs/resize_lfs.c index 5b74c68fdd5e..0b725be3bce7 100644 --- a/sbin/resize_lfs/resize_lfs.c +++ b/sbin/resize_lfs/resize_lfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: resize_lfs.c,v 1.10 2015/07/24 06:56:41 dholland Exp $ */ +/* $NetBSD: resize_lfs.c,v 1.11 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. * All rights reserved. @@ -127,7 +127,7 @@ main(int argc, char **argv) pread(devfd, buf, sboff, LFS_SBPAD); memcpy(&fs->lfs_dlfs, buf, sizeof(struct dlfs)); if (sboff == LFS_LABELPAD && lfs_fsbtob(fs, 1) > LFS_LABELPAD) - sboff = lfs_fsbtob(fs, (off_t)fs->lfs_sboffs[0]); + sboff = lfs_fsbtob(fs, (off_t)lfs_sb_getsboff(fs, 0)); else break; } @@ -135,7 +135,7 @@ main(int argc, char **argv) /* Calculate new number of segments. */ newnsegs = (newsize * secsize) / lfs_sb_getssize(fs); - if (newnsegs == fs->lfs_nseg) { + if (newnsegs == lfs_sb_getnseg(fs)) { errx(0, "the filesystem is unchanged."); } @@ -145,7 +145,7 @@ main(int argc, char **argv) * Make the cleaner do this for us. * (XXX make the kernel able to do this instead?) */ - for (i = fs->lfs_nseg - 1; i >= newnsegs; --i) { + for (i = lfs_sb_getnseg(fs) - 1; i >= newnsegs; --i) { char cmd[128]; /* If it's already empty, don't call the cleaner */ @@ -164,7 +164,7 @@ main(int argc, char **argv) } if (verbose) - printf("Successfully resized %s from %d to %lld segments\n", - fsname, fs->lfs_nseg, (long long)newnsegs); + printf("Successfully resized %s from %u to %lld segments\n", + fsname, lfs_sb_getnseg(fs), (long long)newnsegs); return 0; } diff --git a/sbin/scan_ffs/scan_ffs.c b/sbin/scan_ffs/scan_ffs.c index bd7a9830741e..ccf8e51554d6 100644 --- a/sbin/scan_ffs/scan_ffs.c +++ b/sbin/scan_ffs/scan_ffs.c @@ -1,4 +1,4 @@ -/* $NetBSD: scan_ffs.c,v 1.26 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: scan_ffs.c,v 1.27 2015/07/24 06:59:32 dholland Exp $ */ /* * Copyright (c) 2005-2007 Juan Romero Pardines @@ -33,7 +33,7 @@ #include #ifndef lint -__RCSID("$NetBSD: scan_ffs.c,v 1.26 2015/07/24 06:56:42 dholland Exp $"); +__RCSID("$NetBSD: scan_ffs.c,v 1.27 2015/07/24 06:59:32 dholland Exp $"); #endif /* not lint */ #include @@ -251,7 +251,7 @@ lfs_printpart(struct sblockinfo *sbi, int flag, int n) (void)printf("offset: %" PRIu64 " size %" PRIu32 " fsid %" PRIx32 "\n", sbi->lfs_off, lfs_sb_getsize(sbi->lfs), - sbi->lfs->lfs_ident); + lfs_sb_getident(sbi->lfs)); switch (flag) { case LABELS: (void)printf("X: %9" PRIu64, @@ -266,7 +266,7 @@ lfs_printpart(struct sblockinfo *sbi, int flag, int n) case BLOCKS: (void)printf("LFSv%d", sbi->lfs->lfs_version); (void)printf(" sb at %" PRIu64, sbi->lfs_off + btodb(LFS_LABELPAD)); - (void)printf(" fsid %" PRIx32, sbi->lfs->lfs_ident); + (void)printf(" fsid %" PRIx32, lfs_sb_getident(sbi->lfs)); (void)printf(" size %" PRIu64 ", last mounted on %s\n", (uint64_t)(lfs_sb_getsize(sbi->lfs) * lfs_sb_getfsize(sbi->lfs) / 512), sbi->lfs_path); @@ -284,8 +284,10 @@ lfs_printpart(struct sblockinfo *sbi, int flag, int n) static void lfs_scan(struct sblockinfo *sbi, int n) { + size_t namesize; + /* Check to see if the sb checksums correctly */ - if (lfs_sb_cksum(&(sbi->lfs->lfs_dlfs)) != sbi->lfs->lfs_cksum) { + if (lfs_sb_cksum(&(sbi->lfs->lfs_dlfs)) != lfs_sb_getcksum(sbi->lfs)) { if (flags & VERBOSE) printf("LFS bad superblock at %" PRIu64 "\n", BLK_CNT); @@ -315,7 +317,11 @@ lfs_scan(struct sblockinfo *sbi, int n) break; case SECOND_SBLOCK_ADDRESS: /* copy the path of last mount */ - (void)memcpy(sbi->lfs_path, sbi->lfs->lfs_fsmnt, MAXMNTLEN); + namesize = MIN(sizeof(sbi->lfs_path), + sizeof(sbi->lfs->lfs_dlfs.dlfs_fsmnt)); + (void)memcpy(sbi->lfs_path, sbi->lfs->lfs_dlfs.dlfs_fsmnt, + namesize); + sbi->lfs_path[namesize - 1] = '\0'; /* print now that we have the info */ if (flags & LABELS) lfs_printpart(sbi, LABELS, n); diff --git a/sys/ufs/lfs/lfs.h b/sys/ufs/lfs/lfs.h index f56e46f63dde..89671483b96e 100644 --- a/sys/ufs/lfs/lfs.h +++ b/sys/ufs/lfs/lfs.h @@ -1,4 +1,4 @@ -/* $NetBSD: lfs.h,v 1.164 2015/07/24 06:56:42 dholland Exp $ */ +/* $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 */ /* from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp */ @@ -650,7 +650,7 @@ typedef struct _cleanerinfo { } CLEANERINFO; #define CLEANSIZE_SU(fs) \ - ((sizeof(CLEANERINFO) + lfs_sb_getbsize(fs) - 1) >> (fs)->lfs_bshift) + ((sizeof(CLEANERINFO) + lfs_sb_getbsize(fs) - 1) >> lfs_sb_getbshift(fs)) /* Read in the block with the cleaner info from the ifile. */ #define LFS_CLEANERINFO(CP, F, BP) do { \ @@ -842,7 +842,7 @@ struct dlfs { u_int32_t dlfs_sumsize; /* 332: size of summary blocks */ u_int64_t dlfs_serial; /* 336: serial number */ u_int32_t dlfs_ibsize; /* 344: size of inode blocks */ - int32_t dlfs_start; /* 348: start of segment 0 */ + int32_t dlfs_s0addr; /* 348: start of segment 0 */ u_int64_t dlfs_tstamp; /* 352: time stamp */ #define LFS_44INODEFMT 0 #define LFS_MAXINODEFMT 0 @@ -1026,73 +1026,41 @@ LFS_DEF_SB_ACCESSOR(int32_t, offset); LFS_DEF_SB_ACCESSOR(int32_t, lastpseg); LFS_DEF_SB_ACCESSOR(u_int32_t, inopf); LFS_DEF_SB_ACCESSOR(u_int32_t, minfree); -#define lfs_maxfilesize lfs_dlfs.dlfs_maxfilesize LFS_DEF_SB_ACCESSOR(uint64_t, maxfilesize); -#define lfs_fsbpseg lfs_dlfs.dlfs_fsbpseg LFS_DEF_SB_ACCESSOR(u_int32_t, fsbpseg); -#define lfs_inopb lfs_dlfs.dlfs_inopb LFS_DEF_SB_ACCESSOR(u_int32_t, inopb); LFS_DEF_SB_ACCESSOR(u_int32_t, ifpb); LFS_DEF_SB_ACCESSOR(u_int32_t, sepb); -#define lfs_nindir lfs_dlfs.dlfs_nindir LFS_DEF_SB_ACCESSOR(u_int32_t, nindir); -#define lfs_nseg lfs_dlfs.dlfs_nseg LFS_DEF_SB_ACCESSOR(u_int32_t, nseg); -#define lfs_nspf lfs_dlfs.dlfs_nspf LFS_DEF_SB_ACCESSOR(u_int32_t, nspf); LFS_DEF_SB_ACCESSOR(u_int32_t, cleansz); LFS_DEF_SB_ACCESSOR(u_int32_t, segtabsz); -#define lfs_segmask lfs_dlfs.dlfs_segmask LFS_DEF_SB_ACCESSOR(u_int32_t, segmask); -#define lfs_segshift lfs_dlfs.dlfs_segshift LFS_DEF_SB_ACCESSOR(u_int32_t, segshift); -#define lfs_bmask lfs_dlfs.dlfs_bmask LFS_DEF_SB_ACCESSOR(u_int64_t, bmask); -#define lfs_bshift lfs_dlfs.dlfs_bshift LFS_DEF_SB_ACCESSOR(u_int32_t, bshift); -#define lfs_ffmask lfs_dlfs.dlfs_ffmask LFS_DEF_SB_ACCESSOR(u_int64_t, ffmask); -#define lfs_ffshift lfs_dlfs.dlfs_ffshift LFS_DEF_SB_ACCESSOR(u_int32_t, ffshift); -#define lfs_fbmask lfs_dlfs.dlfs_fbmask LFS_DEF_SB_ACCESSOR(u_int64_t, fbmask); -#define lfs_fbshift lfs_dlfs.dlfs_fbshift LFS_DEF_SB_ACCESSOR(u_int32_t, fbshift); -#define lfs_blktodb lfs_dlfs.dlfs_blktodb LFS_DEF_SB_ACCESSOR(u_int32_t, blktodb); -#define lfs_fsbtodb lfs_dlfs.dlfs_fsbtodb LFS_DEF_SB_ACCESSOR(u_int32_t, fsbtodb); -#define lfs_sushift lfs_dlfs.dlfs_sushift LFS_DEF_SB_ACCESSOR(u_int32_t, sushift); -#define lfs_maxsymlinklen lfs_dlfs.dlfs_maxsymlinklen LFS_DEF_SB_ACCESSOR(int32_t, maxsymlinklen); -#define lfs_sboffs lfs_dlfs.dlfs_sboffs -#define lfs_cksum lfs_dlfs.dlfs_cksum LFS_DEF_SB_ACCESSOR(u_int32_t, cksum); -#define lfs_pflags lfs_dlfs.dlfs_pflags LFS_DEF_SB_ACCESSOR(u_int16_t, pflags); -#define lfs_fsmnt lfs_dlfs.dlfs_fsmnt -#define lfs_nclean lfs_dlfs.dlfs_nclean LFS_DEF_SB_ACCESSOR(u_int32_t, nclean); -#define lfs_dmeta lfs_dlfs.dlfs_dmeta LFS_DEF_SB_ACCESSOR(int32_t, dmeta); -#define lfs_minfreeseg lfs_dlfs.dlfs_minfreeseg LFS_DEF_SB_ACCESSOR(u_int32_t, minfreeseg); -#define lfs_sumsize lfs_dlfs.dlfs_sumsize LFS_DEF_SB_ACCESSOR(u_int32_t, sumsize); LFS_DEF_SB_ACCESSOR(u_int64_t, serial); -#define lfs_ibsize lfs_dlfs.dlfs_ibsize LFS_DEF_SB_ACCESSOR(u_int32_t, ibsize); -#define lfs_s0addr lfs_dlfs.dlfs_start -LFS_DEF_SB_ACCESSOR(int32_t, start); +LFS_DEF_SB_ACCESSOR(int32_t, s0addr); LFS_DEF_SB_ACCESSOR(u_int64_t, tstamp); -#define lfs_inodefmt lfs_dlfs.dlfs_inodefmt LFS_DEF_SB_ACCESSOR(u_int32_t, inodefmt); -#define lfs_interleave lfs_dlfs.dlfs_interleave LFS_DEF_SB_ACCESSOR(u_int32_t, interleave); -#define lfs_ident lfs_dlfs.dlfs_ident LFS_DEF_SB_ACCESSOR(u_int32_t, ident); -#define lfs_resvseg lfs_dlfs.dlfs_resvseg LFS_DEF_SB_ACCESSOR(u_int32_t, resvseg); /* special-case accessors */ @@ -1103,53 +1071,81 @@ LFS_DEF_SB_ACCESSOR(u_int32_t, resvseg); #define lfs_sb_getotstamp(fs) lfs_sb_getinopf(fs) #define lfs_sb_setotstamp(fs, val) lfs_sb_setinopf(fs, val) +/* + * lfs_sboffs is an array + */ +static __unused inline int32_t +lfs_sb_getsboff(struct lfs *fs, unsigned n) +{ +#ifdef KASSERT /* ugh */ + KASSERT(n < LFS_MAXNUMSB); +#endif + return fs->lfs_dlfs.dlfs_sboffs[n]; +} +static __unused inline void +lfs_sb_setsboff(struct lfs *fs, unsigned n, int32_t val) +{ +#ifdef KASSERT /* ugh */ + KASSERT(n < LFS_MAXNUMSB); +#endif + fs->lfs_dlfs.dlfs_sboffs[n] = val; +} + +/* + * lfs_fsmnt is a string + */ +static __unused inline const char * +lfs_sb_getfsmnt(struct lfs *fs) +{ + return fs->lfs_dlfs.dlfs_fsmnt; +} /* LFS_NINDIR is the number of indirects in a file system block. */ -#define LFS_NINDIR(fs) ((fs)->lfs_nindir) +#define LFS_NINDIR(fs) (lfs_sb_getnindir(fs)) /* LFS_INOPB is the number of inodes in a secondary storage block. */ -#define LFS_INOPB(fs) ((fs)->lfs_inopb) +#define LFS_INOPB(fs) (lfs_sb_getinopb(fs)) /* LFS_INOPF is the number of inodes in a fragment. */ -#define LFS_INOPF(fs) ((fs)->lfs_inopf) +#define LFS_INOPF(fs) (lfs_sb_getinopf(fs)) #define lfs_blksize(fs, ip, lbn) \ - (((lbn) >= ULFS_NDADDR || (ip)->i_ffs1_size >= ((lbn) + 1) << (fs)->lfs_bshift) \ + (((lbn) >= ULFS_NDADDR || (ip)->i_ffs1_size >= ((lbn) + 1) << lfs_sb_getbshift(fs)) \ ? lfs_sb_getbsize(fs) \ : (lfs_fragroundup(fs, lfs_blkoff(fs, (ip)->i_ffs1_size)))) -#define lfs_blkoff(fs, loc) ((int)((loc) & (fs)->lfs_bmask)) +#define lfs_blkoff(fs, loc) ((int)((loc) & lfs_sb_getbmask(fs))) #define lfs_fragoff(fs, loc) /* calculates (loc % fs->lfs_fsize) */ \ - ((int)((loc) & (fs)->lfs_ffmask)) + ((int)((loc) & lfs_sb_getffmask(fs))) #if defined(_KERNEL) -#define LFS_FSBTODB(fs, b) ((b) << ((fs)->lfs_ffshift - DEV_BSHIFT)) -#define LFS_DBTOFSB(fs, b) ((b) >> ((fs)->lfs_ffshift - DEV_BSHIFT)) +#define LFS_FSBTODB(fs, b) ((b) << (lfs_sb_getffshift(fs) - DEV_BSHIFT)) +#define LFS_DBTOFSB(fs, b) ((b) >> (lfs_sb_getffshift(fs) - DEV_BSHIFT)) #else -#define LFS_FSBTODB(fs, b) ((b) << (fs)->lfs_fsbtodb) -#define LFS_DBTOFSB(fs, b) ((b) >> (fs)->lfs_fsbtodb) +#define LFS_FSBTODB(fs, b) ((b) << lfs_sb_getfsbtodb(fs)) +#define LFS_DBTOFSB(fs, b) ((b) >> lfs_sb_getfsbtodb(fs)) #endif -#define lfs_lblkno(fs, loc) ((loc) >> (fs)->lfs_bshift) -#define lfs_lblktosize(fs, blk) ((blk) << (fs)->lfs_bshift) +#define lfs_lblkno(fs, loc) ((loc) >> lfs_sb_getbshift(fs)) +#define lfs_lblktosize(fs, blk) ((blk) << lfs_sb_getbshift(fs)) -#define lfs_fsbtob(fs, b) ((b) << (fs)->lfs_ffshift) -#define lfs_btofsb(fs, b) ((b) >> (fs)->lfs_ffshift) +#define lfs_fsbtob(fs, b) ((b) << lfs_sb_getffshift(fs)) +#define lfs_btofsb(fs, b) ((b) >> lfs_sb_getffshift(fs)) #define lfs_numfrags(fs, loc) /* calculates (loc / fs->lfs_fsize) */ \ - ((loc) >> (fs)->lfs_ffshift) + ((loc) >> lfs_sb_getffshift(fs)) #define lfs_blkroundup(fs, size)/* calculates roundup(size, lfs_sb_getbsize(fs)) */ \ - ((off_t)(((size) + (fs)->lfs_bmask) & (~(fs)->lfs_bmask))) + ((off_t)(((size) + lfs_sb_getbmask(fs)) & (~lfs_sb_getbmask(fs)))) #define lfs_fragroundup(fs, size)/* calculates roundup(size, fs->lfs_fsize) */ \ - ((off_t)(((size) + (fs)->lfs_ffmask) & (~(fs)->lfs_ffmask))) + ((off_t)(((size) + lfs_sb_getffmask(fs)) & (~lfs_sb_getffmask(fs)))) #define lfs_fragstoblks(fs, frags)/* calculates (frags / fs->fs_frag) */ \ - ((frags) >> (fs)->lfs_fbshift) + ((frags) >> lfs_sb_getfbshift(fs)) #define lfs_blkstofrags(fs, blks)/* calculates (blks * fs->fs_frag) */ \ - ((blks) << (fs)->lfs_fbshift) + ((blks) << lfs_sb_getfbshift(fs)) #define lfs_fragnum(fs, fsb) /* calculates (fsb % fs->lfs_frag) */ \ ((fsb) & ((fs)->lfs_frag - 1)) #define lfs_blknum(fs, fsb) /* calculates rounddown(fsb, fs->lfs_frag) */ \ ((fsb) &~ ((fs)->lfs_frag - 1)) #define lfs_dblksize(fs, dp, lbn) \ - (((lbn) >= ULFS_NDADDR || (dp)->di_size >= ((lbn) + 1) << (fs)->lfs_bshift)\ + (((lbn) >= ULFS_NDADDR || (dp)->di_size >= ((lbn) + 1) << lfs_sb_getbshift(fs)) \ ? lfs_sb_getbsize(fs) \ : (lfs_fragroundup(fs, lfs_blkoff(fs, (dp)->di_size)))) @@ -1157,12 +1153,12 @@ LFS_DEF_SB_ACCESSOR(u_int32_t, resvseg); lfs_lblktosize((fs), lfs_sb_getssize(fs)) : \ lfs_sb_getssize(fs)) #define lfs_segtod(fs, seg) (((fs)->lfs_version == 1 ? \ - lfs_sb_getssize(fs) << (fs)->lfs_blktodb : \ + lfs_sb_getssize(fs) << lfs_sb_getblktodb(fs) : \ lfs_btofsb((fs), lfs_sb_getssize(fs))) * (seg)) #define lfs_dtosn(fs, daddr) /* block address to segment number */ \ - ((uint32_t)(((daddr) - (fs)->lfs_s0addr) / lfs_segtod((fs), 1))) + ((uint32_t)(((daddr) - lfs_sb_gets0addr(fs)) / lfs_segtod((fs), 1))) #define lfs_sntod(fs, sn) /* segment number to disk address */ \ - ((daddr_t)(lfs_segtod((fs), (sn)) + (fs)->lfs_s0addr)) + ((daddr_t)(lfs_segtod((fs), (sn)) + lfs_sb_gets0addr(fs))) /* * Structures used by lfs_bmapv and lfs_markv to communicate information diff --git a/sys/ufs/lfs/lfs_alloc.c b/sys/ufs/lfs/lfs_alloc.c index a7e7c6fa6529..a877b5dfbf03 100644 --- a/sys/ufs/lfs/lfs_alloc.c +++ b/sys/ufs/lfs/lfs_alloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_alloc.c,v 1.122 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: lfs_alloc.c,v 1.123 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.122 2015/07/24 06:56:42 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.123 2015/07/24 06:59:32 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -136,7 +136,7 @@ lfs_extend_ifile(struct lfs *fs, kauth_cred_t cred) ip->i_ffs1_size = ip->i_size; uvm_vnp_setsize(vp, ip->i_size); - maxino = ((ip->i_size >> fs->lfs_bshift) - lfs_sb_getcleansz(fs) - + maxino = ((ip->i_size >> lfs_sb_getbshift(fs)) - lfs_sb_getcleansz(fs) - lfs_sb_getsegtabsz(fs)) * lfs_sb_getifpb(fs); fs->lfs_ino_bitmap = (lfs_bm_t *) realloc(fs->lfs_ino_bitmap, ((maxino + BMMASK) >> BMSHIFT) * @@ -268,7 +268,7 @@ lfs_valloc_fixed(struct lfs *fs, ino_t ino, int vers) /* If the Ifile is too short to contain this inum, extend it */ while (VTOI(fs->lfs_ivnode)->i_size <= (ino / lfs_sb_getifpb(fs) + lfs_sb_getcleansz(fs) + lfs_sb_getsegtabsz(fs)) - << fs->lfs_bshift) { + << lfs_sb_getbshift(fs)) { lfs_extend_ifile(fs, NOCRED); } @@ -311,7 +311,7 @@ lfs_last_alloc_ino(struct lfs *fs) { ino_t ino, maxino; - maxino = ((fs->lfs_ivnode->v_size >> fs->lfs_bshift) - + maxino = ((fs->lfs_ivnode->v_size >> lfs_sb_getbshift(fs)) - lfs_sb_getcleansz(fs) - lfs_sb_getsegtabsz(fs)) * fs->lfs_ifpb; for (ino = maxino - 1; ino > LFS_UNUSED_INUM; --ino) { if (ISSET_BITMAP_FREE(fs, ino) == 0) @@ -553,7 +553,7 @@ lfs_order_freelist(struct lfs *fs) ASSERT_NO_SEGLOCK(fs); lfs_seglock(fs, SEGM_PROT); - maxino = ((fs->lfs_ivnode->v_size >> fs->lfs_bshift) - + maxino = ((fs->lfs_ivnode->v_size >> lfs_sb_getbshift(fs)) - lfs_sb_getcleansz(fs) - lfs_sb_getsegtabsz(fs)) * lfs_sb_getifpb(fs); fs->lfs_ino_bitmap = malloc(((maxino + BMMASK) >> BMSHIFT) * sizeof(lfs_bm_t), diff --git a/sys/ufs/lfs/lfs_balloc.c b/sys/ufs/lfs/lfs_balloc.c index d967e892cdc0..75498b9a7840 100644 --- a/sys/ufs/lfs/lfs_balloc.c +++ b/sys/ufs/lfs/lfs_balloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_balloc.c,v 1.82 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: lfs_balloc.c,v 1.83 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.82 2015/07/24 06:56:42 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.83 2015/07/24 06:59:32 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -501,7 +501,7 @@ lfs_register_block(struct vnode *vp, daddr_t lbn) ASSERT_NO_SEGLOCK(fs); /* If no space, wait for the cleaner */ - lfs_availwait(fs, lfs_btofsb(fs, 1 << fs->lfs_bshift)); + lfs_availwait(fs, lfs_btofsb(fs, 1 << lfs_sb_getbshift(fs))); lbp = (struct lbnentry *)pool_get(&lfs_lbnentry_pool, PR_WAITOK); lbp->lbn = lbn; @@ -514,7 +514,7 @@ lfs_register_block(struct vnode *vp, daddr_t lbn) } ++ip->i_lfs_nbtree; - fs->lfs_favail += lfs_btofsb(fs, (1 << fs->lfs_bshift)); + fs->lfs_favail += lfs_btofsb(fs, (1 << lfs_sb_getbshift(fs))); fs->lfs_pages += lfs_sb_getbsize(fs) >> PAGE_SHIFT; ++locked_fakequeue_count; lfs_subsys_pages += lfs_sb_getbsize(fs) >> PAGE_SHIFT; @@ -529,8 +529,8 @@ lfs_do_deregister(struct lfs *fs, struct inode *ip, struct lbnentry *lbp) mutex_enter(&lfs_lock); --ip->i_lfs_nbtree; SPLAY_REMOVE(lfs_splay, &ip->i_lfs_lbtree, lbp); - if (fs->lfs_favail > lfs_btofsb(fs, (1 << fs->lfs_bshift))) - fs->lfs_favail -= lfs_btofsb(fs, (1 << fs->lfs_bshift)); + if (fs->lfs_favail > lfs_btofsb(fs, (1 << lfs_sb_getbshift(fs)))) + fs->lfs_favail -= lfs_btofsb(fs, (1 << lfs_sb_getbshift(fs))); fs->lfs_pages -= lfs_sb_getbsize(fs) >> PAGE_SHIFT; if (locked_fakequeue_count > 0) --locked_fakequeue_count; diff --git a/sys/ufs/lfs/lfs_bio.c b/sys/ufs/lfs/lfs_bio.c index 54193f56bdae..0d68e5320383 100644 --- a/sys/ufs/lfs/lfs_bio.c +++ b/sys/ufs/lfs/lfs_bio.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_bio.c,v 1.129 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: lfs_bio.c,v 1.130 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2008 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.129 2015/07/24 06:56:42 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.130 2015/07/24 06:59:32 dholland Exp $"); #include #include @@ -361,7 +361,7 @@ lfs_fits(struct lfs *fs, int fsb) needed = fsb + lfs_btofsb(fs, lfs_sb_getsumsize(fs)) + ((howmany(lfs_sb_getuinodes(fs) + 1, LFS_INOPB(fs)) + lfs_sb_getsegtabsz(fs) + - 1) << (fs->lfs_bshift - fs->lfs_ffshift)); + 1) << (lfs_sb_getbshift(fs) - lfs_sb_getffshift(fs))); if (needed >= lfs_sb_getavail(fs)) { #ifdef DEBUG @@ -443,7 +443,7 @@ lfs_bwrite_ext(struct buf *bp, int flags) * * In particular the cleaner can't write blocks either. */ - if (fs->lfs_ronly || (fs->lfs_pflags & LFS_PF_CLEAN)) { + if (fs->lfs_ronly || (lfs_sb_getpflags(fs) & LFS_PF_CLEAN)) { bp->b_oflags &= ~BO_DELWRI; bp->b_flags |= B_READ; /* XXX is this right? --ks */ bp->b_error = 0; diff --git a/sys/ufs/lfs/lfs_inode.c b/sys/ufs/lfs/lfs_inode.c index c646fe8e6080..3893be97fafd 100644 --- a/sys/ufs/lfs/lfs_inode.c +++ b/sys/ufs/lfs/lfs_inode.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_inode.c,v 1.138 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: lfs_inode.c,v 1.139 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.138 2015/07/24 06:56:42 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.139 2015/07/24 06:59:32 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -285,7 +285,7 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred) if (ioflag & IO_SYNC) { mutex_enter(ovp->v_interlock); VOP_PUTPAGES(ovp, - trunc_page(osize & fs->lfs_bmask), + trunc_page(osize & lfs_sb_getbmask(fs)), round_page(eob), PGO_CLEANIT | PGO_SYNCIO); } @@ -305,13 +305,13 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred) return (lfs_update(ovp, NULL, NULL, 0)); } else { error = lfs_reserve(fs, ovp, NULL, - lfs_btofsb(fs, (ULFS_NIADDR + 2) << fs->lfs_bshift)); + lfs_btofsb(fs, (ULFS_NIADDR + 2) << lfs_sb_getbshift(fs))); if (error) return (error); error = lfs_balloc(ovp, length - 1, 1, cred, aflags, &bp); lfs_reserve(fs, ovp, NULL, - -lfs_btofsb(fs, (ULFS_NIADDR + 2) << fs->lfs_bshift)); + -lfs_btofsb(fs, (ULFS_NIADDR + 2) << lfs_sb_getbshift(fs))); if (error) return (error); oip->i_ffs1_size = oip->i_size = length; @@ -324,7 +324,7 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred) } if ((error = lfs_reserve(fs, ovp, NULL, - lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << fs->lfs_bshift))) != 0) + lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << lfs_sb_getbshift(fs)))) != 0) return (error); /* @@ -351,7 +351,7 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred) error = lfs_balloc(ovp, length - 1, 1, cred, aflags, &bp); if (error) { lfs_reserve(fs, ovp, NULL, - -lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << fs->lfs_bshift)); + -lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << lfs_sb_getbshift(fs))); goto errout; } obufsize = bp->b_bufsize; @@ -391,7 +391,7 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred) error = ulfs_balloc_range(ovp, length - 1, 1, cred, aflags); if (error) { lfs_reserve(fs, ovp, NULL, - -lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << fs->lfs_bshift)); + -lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << lfs_sb_getbshift(fs))); goto errout; } xlbn = lfs_lblkno(fs, length); @@ -407,7 +407,7 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred) ((ioflag & IO_SYNC) ? PGO_SYNCIO : 0)); if (error) { lfs_reserve(fs, ovp, NULL, - -lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << fs->lfs_bshift)); + -lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << lfs_sb_getbshift(fs))); goto errout; } } @@ -593,7 +593,7 @@ done: (void) lfs_chkdq(oip, -blocksreleased, NOCRED, 0); #endif lfs_reserve(fs, ovp, NULL, - -lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << fs->lfs_bshift)); + -lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << lfs_sb_getbshift(fs))); genfs_node_unlock(ovp); errout: oip->i_lfs_hiblk = lfs_lblkno(fs, oip->i_size + lfs_sb_getbsize(fs) - 1) - 1; diff --git a/sys/ufs/lfs/lfs_pages.c b/sys/ufs/lfs/lfs_pages.c index efc5b88d85b8..a577e52c5a41 100644 --- a/sys/ufs/lfs/lfs_pages.c +++ b/sys/ufs/lfs/lfs_pages.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_pages.c,v 1.2 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: lfs_pages.c,v 1.3 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.2 2015/07/24 06:56:42 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.3 2015/07/24 06:59:32 dholland Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -278,7 +278,7 @@ check_dirty(struct lfs *fs, struct vnode *vp, || (curpg->flags & PG_MARKER) == 0); if (pages_per_block > 1) { while (curpg && - ((curpg->offset & fs->lfs_bmask) || + ((curpg->offset & lfs_sb_getbmask(fs)) || curpg->offset >= vp->v_size || curpg->offset >= endoffset)) { curpg = TAILQ_NEXT(curpg, listq.queue); @@ -550,9 +550,9 @@ lfs_putpages(void *v) */ origoffset = ap->a_offlo; origendoffset = ap->a_offhi; - startoffset = origoffset & ~(fs->lfs_bmask); - max_endoffset = (trunc_page(LLONG_MAX) >> fs->lfs_bshift) - << fs->lfs_bshift; + startoffset = origoffset & ~(lfs_sb_getbmask(fs)); + max_endoffset = (trunc_page(LLONG_MAX) >> lfs_sb_getbshift(fs)) + << lfs_sb_getbshift(fs); if (origendoffset == 0 || ap->a_flags & PGO_ALLPAGES) { endoffset = max_endoffset; diff --git a/sys/ufs/lfs/lfs_rfw.c b/sys/ufs/lfs/lfs_rfw.c index 64f1b97e3a0a..685e1e620584 100644 --- a/sys/ufs/lfs/lfs_rfw.c +++ b/sys/ufs/lfs/lfs_rfw.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_rfw.c,v 1.22 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: lfs_rfw.c,v 1.23 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_rfw.c,v 1.22 2015/07/24 06:56:42 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_rfw.c,v 1.23 2015/07/24 06:59:32 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -184,7 +184,7 @@ update_meta(struct lfs *fs, ino_t ino, int vers, daddr_t lbn, return error; } - if ((error = lfs_balloc(vp, (lbn << fs->lfs_bshift), size, + if ((error = lfs_balloc(vp, (lbn << lfs_sb_getbshift(fs)), size, NOCRED, 0, &bp)) != 0) { vput(vp); return (error); @@ -204,14 +204,14 @@ update_meta(struct lfs *fs, ino_t ino, int vers, daddr_t lbn, * XXX appear later to give the correct size. */ ip = VTOI(vp); - if (ip->i_size <= (lbn << fs->lfs_bshift)) { + if (ip->i_size <= (lbn << lfs_sb_getbshift(fs))) { u_int64_t newsize; if (lbn < ULFS_NDADDR) - newsize = ip->i_ffs1_size = (lbn << fs->lfs_bshift) + + newsize = ip->i_ffs1_size = (lbn << lfs_sb_getbshift(fs)) + (size - lfs_sb_getfsize(fs)) + 1; else - newsize = ip->i_ffs1_size = (lbn << fs->lfs_bshift) + 1; + newsize = ip->i_ffs1_size = (lbn << lfs_sb_getbshift(fs)) + 1; if (ip->i_size < newsize) { ip->i_size = newsize; @@ -268,7 +268,7 @@ update_inoblk(struct lfs *fs, daddr_t offset, kauth_cred_t cred, * Get the inode, update times and perms. * DO NOT update disk blocks, we do that separately. */ - error = bread(devvp, LFS_FSBTODB(fs, offset), fs->lfs_ibsize, + error = bread(devvp, LFS_FSBTODB(fs, offset), lfs_sb_getibsize(fs), 0, &dbp); if (error) { DLOG((DLOG_RF, "update_inoblk: bread returned %d\n", error)); @@ -368,7 +368,7 @@ check_segsum(struct lfs *fs, daddr_t offset, u_int64_t nextserial, } /* Read in the segment summary */ - error = bread(devvp, LFS_FSBTODB(fs, offset), fs->lfs_sumsize, + error = bread(devvp, LFS_FSBTODB(fs, offset), lfs_sb_getsumsize(fs), 0, &bp); if (error) return -1; @@ -377,7 +377,7 @@ check_segsum(struct lfs *fs, daddr_t offset, u_int64_t nextserial, ssp = (SEGSUM *)bp->b_data; if (flags & CHECK_CKSUM) { if (ssp->ss_sumsum != cksum(&ssp->ss_datasum, - fs->lfs_sumsize - + lfs_sb_getsumsize(fs) - sizeof(ssp->ss_sumsum))) { DLOG((DLOG_RF, "Sumsum error at 0x%" PRIx64 "\n", offset)); offset = -1; @@ -401,9 +401,9 @@ check_segsum(struct lfs *fs, daddr_t offset, u_int64_t nextserial, offset = -1; goto err1; } - if (ssp->ss_ident != fs->lfs_ident) { + if (ssp->ss_ident != lfs_sb_getident(fs)) { DLOG((DLOG_RF, "Incorrect fsid (0x%x vs 0x%x) at 0x%" - PRIx64 "\n", ssp->ss_ident, fs->lfs_ident, offset)); + PRIx64 "\n", ssp->ss_ident, lfs_sb_getident(fs), offset)); offset = -1; goto err1; } @@ -411,11 +411,11 @@ check_segsum(struct lfs *fs, daddr_t offset, u_int64_t nextserial, if (pseg_flags) *pseg_flags = ssp->ss_flags; oldoffset = offset; - offset += lfs_btofsb(fs, fs->lfs_sumsize); + offset += lfs_btofsb(fs, lfs_sb_getsumsize(fs)); ninos = howmany(ssp->ss_ninos, LFS_INOPB(fs)); /* XXX ondisk32 */ - iaddr = (int32_t *)((char*)bp->b_data + fs->lfs_sumsize - sizeof(int32_t)); + iaddr = (int32_t *)((char*)bp->b_data + lfs_sb_getsumsize(fs) - sizeof(int32_t)); if (flags & CHECK_CKSUM) { /* Count blocks */ nblocks = 0; @@ -457,7 +457,7 @@ check_segsum(struct lfs *fs, daddr_t offset, u_int64_t nextserial, goto err2; } } - offset += lfs_btofsb(fs, fs->lfs_ibsize); + offset += lfs_btofsb(fs, lfs_sb_getibsize(fs)); --iaddr; --ninos; --i; /* compensate */ @@ -503,7 +503,7 @@ check_segsum(struct lfs *fs, daddr_t offset, u_int64_t nextserial, } /* If we're at the end of the segment, move to the next */ - if (lfs_dtosn(fs, offset + lfs_btofsb(fs, fs->lfs_sumsize + lfs_sb_getbsize(fs))) != + if (lfs_dtosn(fs, offset + lfs_btofsb(fs, lfs_sb_getsumsize(fs) + lfs_sb_getbsize(fs))) != lfs_dtosn(fs, offset)) { if (lfs_dtosn(fs, offset) == lfs_dtosn(fs, ssp->ss_next)) { offset = -1; @@ -561,7 +561,7 @@ lfs_roll_forward(struct lfs *fs, struct mount *mp, struct lwp *l) * v2 filesystems don't have this problem because they use a * monotonically increasing serial number instead of a timestamp. */ - do_rollforward = (!(fs->lfs_pflags & LFS_PF_CLEAN) && + do_rollforward = (!(lfs_sb_getpflags(fs) & LFS_PF_CLEAN) && lfs_do_rfw && fs->lfs_version > 1 && p != NULL); if (do_rollforward) { u_int64_t nextserial; @@ -577,7 +577,7 @@ lfs_roll_forward(struct lfs *fs, struct mount *mp, struct lwp *l) PRIx64 "\n", offset)); LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, offset), bp); if (!(sup->su_flags & SEGUSE_DIRTY)) - --fs->lfs_nclean; + lfs_sb_subnclean(fs, 1); sup->su_flags |= SEGUSE_DIRTY; LFS_WRITESEGENTRY(sup, fs, lfs_dtosn(fs, offset), bp); nextserial = lfs_sb_getserial(fs) + 1; @@ -588,7 +588,7 @@ lfs_roll_forward(struct lfs *fs, struct mount *mp, struct lwp *l) LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, oldoffset), bp); if (!(sup->su_flags & SEGUSE_DIRTY)) - --fs->lfs_nclean; + lfs_sb_subnclean(fs, 1); sup->su_flags |= SEGUSE_DIRTY; LFS_WRITESEGENTRY(sup, fs, lfs_dtosn(fs, oldoffset), bp); @@ -621,7 +621,7 @@ lfs_roll_forward(struct lfs *fs, struct mount *mp, struct lwp *l) lfs_sb_setoffset(fs, lastgoodpseg); lfs_sb_setcurseg(fs, lfs_sntod(fs, lfs_dtosn(fs, lfs_sb_getoffset(fs)))); for (sn = curseg = lfs_dtosn(fs, lfs_sb_getcurseg(fs));;) { - sn = (sn + 1) % fs->lfs_nseg; + sn = (sn + 1) % lfs_sb_getnseg(fs); if (sn == curseg) panic("lfs_mountfs: no clean segments"); LFS_SEGENTRY(sup, fs, sn, bp); diff --git a/sys/ufs/lfs/lfs_segment.c b/sys/ufs/lfs/lfs_segment.c index 9261d934b8bb..4dbbacc1a9b8 100644 --- a/sys/ufs/lfs/lfs_segment.c +++ b/sys/ufs/lfs/lfs_segment.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_segment.c,v 1.242 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: lfs_segment.c,v 1.243 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.242 2015/07/24 06:56:42 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.243 2015/07/24 06:59:32 dholland Exp $"); #define _VFS_VNODE_PRIVATE /* XXX: check for VI_MARKER, this has to go */ @@ -133,7 +133,7 @@ static void lfs_cluster_callback(struct buf *); ((flags & SEGM_CLEAN) == 0 && \ ((fs->lfs_nactive > LFS_MAX_ACTIVE || \ (flags & SEGM_CKP) || \ - fs->lfs_nclean < LFS_MAX_ACTIVE))) + lfs_sb_getnclean(fs) < LFS_MAX_ACTIVE))) int lfs_match_fake(struct lfs *, struct buf *); void lfs_newseg(struct lfs *); @@ -692,7 +692,7 @@ lfs_segwrite(struct mount *mp, int flags) * last checkpoint as no longer ACTIVE. */ if (do_ckp || fs->lfs_doifile) { - segleft = fs->lfs_nseg; + segleft = lfs_sb_getnseg(fs); curseg = 0; for (n = 0; n < lfs_sb_getsegtabsz(fs); n++) { dirty = 0; @@ -964,7 +964,7 @@ lfs_update_iaddr(struct lfs *fs, struct segment *sp, struct inode *ip, daddr_t n */ if (ip->i_number == LFS_IFILE_INUM) { sn = lfs_dtosn(fs, lfs_sb_getoffset(fs)); - if (lfs_sntod(fs, sn) + lfs_btofsb(fs, fs->lfs_sumsize) == + if (lfs_sntod(fs, sn) + lfs_btofsb(fs, lfs_sb_getsumsize(fs)) == lfs_sb_getoffset(fs)) { LFS_SEGENTRY(sup, fs, sn, bp); KASSERT(bp->b_oflags & BO_DELWRI); @@ -1070,7 +1070,7 @@ lfs_writeinode(struct lfs *fs, struct segment *sp, struct inode *ip) int redo = 0; if (sp->idp == NULL && sp->ibp == NULL && - (sp->seg_bytes_left < fs->lfs_ibsize || + (sp->seg_bytes_left < lfs_sb_getibsize(fs) || sp->sum_bytes_left < sizeof(int32_t))) { (void) lfs_writeseg(fs, sp); continue; @@ -1103,7 +1103,7 @@ lfs_writeinode(struct lfs *fs, struct segment *sp, struct inode *ip) 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 || + if (sp->seg_bytes_left < lfs_sb_getibsize(fs) || sp->sum_bytes_left < sizeof(int32_t)) (void) lfs_writeseg(fs, sp); @@ -1112,7 +1112,7 @@ lfs_writeinode(struct lfs *fs, struct segment *sp, struct inode *ip) lfs_sb_addoffset(fs, lfs_btofsb(fs, lfs_sb_getibsize(fs))); sp->ibp = *sp->cbpp++ = getblk(VTOI(fs->lfs_ivnode)->i_devvp, - LFS_FSBTODB(fs, daddr), fs->lfs_ibsize, 0, 0); + LFS_FSBTODB(fs, daddr), lfs_sb_getibsize(fs), 0, 0); gotblk++; /* Zero out inode numbers */ @@ -1123,9 +1123,9 @@ lfs_writeinode(struct lfs *fs, struct segment *sp, struct inode *ip) ++sp->start_bpp; lfs_sb_subavail(fs, lfs_btofsb(fs, lfs_sb_getibsize(fs))); /* Set remaining space counters. */ - sp->seg_bytes_left -= fs->lfs_ibsize; + sp->seg_bytes_left -= lfs_sb_getibsize(fs); sp->sum_bytes_left -= sizeof(int32_t); - ndx = fs->lfs_sumsize / sizeof(int32_t) - + ndx = lfs_sb_getsumsize(fs) / sizeof(int32_t) - sp->ninodes / LFS_INOPB(fs) - 1; ((int32_t *)(sp->segsum))[ndx] = daddr; } @@ -1207,8 +1207,8 @@ lfs_writeinode(struct lfs *fs, struct segment *sp, struct inode *ip) /* Check file size based on highest allocated block */ if (((ip->i_ffs1_mode & LFS_IFMT) == LFS_IFREG || (ip->i_ffs1_mode & LFS_IFMT) == LFS_IFDIR) && - ip->i_size > ((ip->i_lfs_hiblk + 1) << fs->lfs_bshift)) { - cdp->di_size = (ip->i_lfs_hiblk + 1) << fs->lfs_bshift; + ip->i_size > ((ip->i_lfs_hiblk + 1) << lfs_sb_getbshift(fs))) { + cdp->di_size = (ip->i_lfs_hiblk + 1) << lfs_sb_getbshift(fs); DLOG((DLOG_SEG, "lfs_writeinode: ino %d size %" PRId64 " -> %" PRId64 "\n", (int)ip->i_number, ip->i_size, cdp->di_size)); } @@ -1230,7 +1230,7 @@ lfs_writeinode(struct lfs *fs, struct segment *sp, struct inode *ip) * Check dinode held blocks against dinode size. * This should be identical to the check in lfs_vget(). */ - for (i = (cdp->di_size + lfs_sb_getbsize(fs) - 1) >> fs->lfs_bshift; + for (i = (cdp->di_size + lfs_sb_getbsize(fs) - 1) >> lfs_sb_getbshift(fs); i < ULFS_NDADDR; i++) { KASSERT(i >= 0); if ((cdp->di_mode & LFS_IFMT) == LFS_IFLNK) @@ -1541,7 +1541,7 @@ lfs_update_single(struct lfs *fs, struct segment *sp, ndupino = 0; } #endif - KASSERT(oldsn < fs->lfs_nseg); + KASSERT(oldsn < lfs_sb_getnseg(fs)); if (lbn >= 0 && lbn < ULFS_NDADDR) osize = ip->i_lfs_fragsize[lbn]; else @@ -1651,7 +1651,7 @@ lfs_updatemeta(struct segment *sp) * XXX fake blocks (including fake inodes and fake indirect blocks). */ sp->fip->fi_lastlength = ((sp->start_bpp[nblocks - 1]->b_bcount - 1) & - fs->lfs_bmask) + 1; + lfs_sb_getbmask(fs)) + 1; /* * Assign disk addresses, and update references to the logical @@ -1671,7 +1671,7 @@ lfs_updatemeta(struct segment *sp) * that the indirect block that actually ends the list * is of a smaller size!) */ - if ((sbp->b_bcount & fs->lfs_bmask) && i != 0) + if ((sbp->b_bcount & lfs_sb_getbmask(fs)) && i != 0) panic("lfs_updatemeta: fragment is not last block"); /* @@ -1713,10 +1713,10 @@ lfs_rewind(struct lfs *fs, int newsn) return 0; /* lfs_avail eats the remaining space in this segment */ - lfs_sb_subavail(fs, fs->lfs_fsbpseg - (lfs_sb_getoffset(fs) - lfs_sb_getcurseg(fs))); + lfs_sb_subavail(fs, lfs_sb_getfsbpseg(fs) - (lfs_sb_getoffset(fs) - lfs_sb_getcurseg(fs))); /* Find a low-numbered segment */ - for (sn = 0; sn < fs->lfs_nseg; ++sn) { + for (sn = 0; sn < lfs_sb_getnseg(fs); ++sn) { LFS_SEGENTRY(sup, fs, sn, bp); isdirty = sup->su_flags & SEGUSE_DIRTY; brelse(bp, 0); @@ -1724,7 +1724,7 @@ lfs_rewind(struct lfs *fs, int newsn) if (!isdirty) break; } - if (sn == fs->lfs_nseg) + if (sn == lfs_sb_getnseg(fs)) panic("lfs_rewind: no clean segments"); if (newsn >= 0 && sn >= newsn) return ENOENT; @@ -1756,7 +1756,7 @@ lfs_initseg(struct lfs *fs) struct buf *bp; /* lfs_avail eats the remaining space */ - lfs_sb_subavail(fs, fs->lfs_fsbpseg - (lfs_sb_getoffset(fs) - + lfs_sb_subavail(fs, lfs_sb_getfsbpseg(fs) - (lfs_sb_getoffset(fs) - lfs_sb_getcurseg(fs))); /* Wake up any cleaning procs waiting on this file system. */ lfs_wakeup_cleaner(fs); @@ -1765,7 +1765,7 @@ lfs_initseg(struct lfs *fs) lfs_sb_setoffset(fs, lfs_sb_getcurseg(fs)); sp->seg_number = lfs_dtosn(fs, lfs_sb_getcurseg(fs)); - sp->seg_bytes_left = lfs_fsbtob(fs, fs->lfs_fsbpseg); + sp->seg_bytes_left = lfs_fsbtob(fs, lfs_sb_getfsbpseg(fs)); /* * If the segment contains a superblock, update the offset @@ -1779,15 +1779,15 @@ lfs_initseg(struct lfs *fs) brelse(bp, 0); /* Segment zero could also contain the labelpad */ if (fs->lfs_version > 1 && sp->seg_number == 0 && - fs->lfs_s0addr < lfs_btofsb(fs, LFS_LABELPAD)) { + lfs_sb_gets0addr(fs) < lfs_btofsb(fs, LFS_LABELPAD)) { lfs_sb_addoffset(fs, - lfs_btofsb(fs, LFS_LABELPAD) - fs->lfs_s0addr); + lfs_btofsb(fs, LFS_LABELPAD) - lfs_sb_gets0addr(fs)); sp->seg_bytes_left -= - LFS_LABELPAD - lfs_fsbtob(fs, fs->lfs_s0addr); + LFS_LABELPAD - lfs_fsbtob(fs, lfs_sb_gets0addr(fs)); } } else { sp->seg_number = lfs_dtosn(fs, lfs_sb_getcurseg(fs)); - sp->seg_bytes_left = lfs_fsbtob(fs, fs->lfs_fsbpseg - + sp->seg_bytes_left = lfs_fsbtob(fs, lfs_sb_getfsbpseg(fs) - (lfs_sb_getoffset(fs) - lfs_sb_getcurseg(fs))); } lfs_sb_setlastpseg(fs, lfs_sb_getoffset(fs)); @@ -1817,7 +1817,7 @@ lfs_initseg(struct lfs *fs) /* Get a new buffer for SEGSUM */ sbp = lfs_newbuf(fs, VTOI(fs->lfs_ivnode)->i_devvp, - LFS_FSBTODB(fs, lfs_sb_getoffset(fs)), fs->lfs_sumsize, LFS_NB_SUMMARY); + LFS_FSBTODB(fs, lfs_sb_getoffset(fs)), lfs_sb_getsumsize(fs), LFS_NB_SUMMARY); /* ... and enter it into the buffer list. */ *sp->cbpp = sbp; @@ -1828,7 +1828,7 @@ lfs_initseg(struct lfs *fs) /* Set point to SEGSUM, initialize it. */ ssp = sp->segsum = sbp->b_data; - memset(ssp, 0, fs->lfs_sumsize); + memset(ssp, 0, lfs_sb_getsumsize(fs)); ssp->ss_next = lfs_sb_getnextseg(fs); ssp->ss_nfinfo = ssp->ss_ninos = 0; ssp->ss_magic = SS_MAGIC; @@ -1839,8 +1839,8 @@ lfs_initseg(struct lfs *fs) sp->start_lbp = &sp->fip->fi_blocks[0]; sp->fip->fi_lastlength = 0; - sp->seg_bytes_left -= fs->lfs_sumsize; - sp->sum_bytes_left = fs->lfs_sumsize - SEGSUM_SIZE(fs); + sp->seg_bytes_left -= lfs_sb_getsumsize(fs); + sp->sum_bytes_left = lfs_sb_getsumsize(fs) - SEGSUM_SIZE(fs); return (repeat); } @@ -1855,7 +1855,7 @@ lfs_unset_inval_all(struct lfs *fs) struct buf *bp; int i; - for (i = 0; i < fs->lfs_nseg; i++) { + for (i = 0; i < lfs_sb_getnseg(fs); i++) { LFS_SEGENTRY(sup, fs, i, bp); if (sup->su_flags & SEGUSE_INVAL) { sup->su_flags &= ~SEGUSE_INVAL; @@ -1883,13 +1883,13 @@ lfs_newseg(struct lfs *fs) while (lfs_sb_getnextseg(fs) < lfs_sb_getcurseg(fs) && fs->lfs_nowrap) { if (fs->lfs_wrappass) { log(LOG_NOTICE, "%s: wrappass=%d\n", - fs->lfs_fsmnt, fs->lfs_wrappass); + lfs_sb_getfsmnt(fs), fs->lfs_wrappass); fs->lfs_wrappass = 0; break; } fs->lfs_wrapstatus = LFS_WRAP_WAITING; wakeup(&fs->lfs_nowrap); - log(LOG_NOTICE, "%s: waiting at log wrap\n", fs->lfs_fsmnt); + log(LOG_NOTICE, "%s: waiting at log wrap\n", lfs_sb_getfsmnt(fs)); mtsleep(&fs->lfs_wrappass, PVFS, "newseg", 10 * hz, &lfs_lock); } @@ -1908,14 +1908,14 @@ lfs_newseg(struct lfs *fs) LFS_CLEANERINFO(cip, fs, bp); --cip->clean; ++cip->dirty; - fs->lfs_nclean = cip->clean; + lfs_sb_setnclean(fs, cip->clean); LFS_SYNC_CLEANERINFO(cip, fs, bp, 1); lfs_sb_setlastseg(fs, lfs_sb_getcurseg(fs)); lfs_sb_setcurseg(fs, lfs_sb_getnextseg(fs)); skip_inval = 1; - for (sn = curseg = lfs_dtosn(fs, lfs_sb_getcurseg(fs)) + fs->lfs_interleave;;) { - sn = (sn + 1) % fs->lfs_nseg; + for (sn = curseg = lfs_dtosn(fs, lfs_sb_getcurseg(fs)) + lfs_sb_getinterleave(fs);;) { + sn = (sn + 1) % lfs_sb_getnseg(fs); if (sn == curseg) { if (skip_inval) @@ -2058,7 +2058,7 @@ lfs_writeseg(struct lfs *fs, struct segment *sp) sp->seg_number, ssp->ss_ninos * sizeof (struct ulfs1_dinode), ssp->ss_ninos)); sup->su_nbytes += ssp->ss_ninos * sizeof (struct ulfs1_dinode); - /* sup->su_nbytes += fs->lfs_sumsize; */ + /* sup->su_nbytes += lfs_sb_getsumsize(fs); */ if (fs->lfs_version == 1) sup->su_olastmod = time_second; else @@ -2207,17 +2207,17 @@ lfs_writeseg(struct lfs *fs, struct segment *sp) ssp->ss_create = time_second; lfs_sb_addserial(fs, 1); ssp->ss_serial = lfs_sb_getserial(fs); - ssp->ss_ident = fs->lfs_ident; + ssp->ss_ident = lfs_sb_getident(fs); } ssp->ss_datasum = lfs_cksum_fold(sum); ssp->ss_sumsum = cksum(&ssp->ss_datasum, - fs->lfs_sumsize - sizeof(ssp->ss_sumsum)); + lfs_sb_getsumsize(fs) - sizeof(ssp->ss_sumsum)); mutex_enter(&lfs_lock); - lfs_sb_subbfree(fs, (lfs_btofsb(fs, ninos * fs->lfs_ibsize) + - lfs_btofsb(fs, fs->lfs_sumsize))); - lfs_sb_adddmeta(fs, (lfs_btofsb(fs, ninos * fs->lfs_ibsize) + - lfs_btofsb(fs, fs->lfs_sumsize))); + lfs_sb_subbfree(fs, (lfs_btofsb(fs, ninos * lfs_sb_getibsize(fs)) + + lfs_btofsb(fs, lfs_sb_getsumsize(fs)))); + lfs_sb_adddmeta(fs, (lfs_btofsb(fs, ninos * lfs_sb_getibsize(fs)) + + lfs_btofsb(fs, lfs_sb_getsumsize(fs)))); mutex_exit(&lfs_lock); /* @@ -2243,7 +2243,7 @@ lfs_writeseg(struct lfs *fs, struct segment *sp) cbp->b_bcount = 0; #if defined(DEBUG) && defined(DIAGNOSTIC) - if (bpp - sp->bpp > (fs->lfs_sumsize - SEGSUM_SIZE(fs)) + if (bpp - sp->bpp > (lfs_sb_getsumsize(fs) - SEGSUM_SIZE(fs)) / sizeof(int32_t)) { panic("lfs_writeseg: real bpp overwrite"); } @@ -2387,7 +2387,7 @@ lfs_writesuper(struct lfs *fs, daddr_t daddr) lfs_sb_settstamp(fs, time_second); /* Checksum the superblock and copy it into a buffer. */ - fs->lfs_cksum = lfs_sb_cksum(&(fs->lfs_dlfs)); + lfs_sb_setcksum(fs, lfs_sb_cksum(&(fs->lfs_dlfs))); bp = lfs_newbuf(fs, devvp, LFS_FSBTODB(fs, daddr), LFS_SBPAD, LFS_NB_SBLOCK); memset((char *)bp->b_data + sizeof(struct dlfs), 0, diff --git a/sys/ufs/lfs/lfs_subr.c b/sys/ufs/lfs/lfs_subr.c index a05ada063c78..5b1877adfc63 100644 --- a/sys/ufs/lfs/lfs_subr.c +++ b/sys/ufs/lfs/lfs_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_subr.c,v 1.82 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: lfs_subr.c,v 1.83 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.82 2015/07/24 06:56:42 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.83 2015/07/24 06:59:32 dholland Exp $"); #include #include @@ -120,7 +120,7 @@ lfs_setup_resblks(struct lfs *fs) * so we can't use the pool subsystem for them. */ for (i = 0, j = 0; j < LFS_N_SUMMARIES; j++, i++) - fs->lfs_resblk[i].size = fs->lfs_sumsize; + fs->lfs_resblk[i].size = lfs_sb_getsumsize(fs); for (j = 0; j < LFS_N_SBLOCKS; j++, i++) fs->lfs_resblk[i].size = LFS_SBPAD; for (j = 0; j < LFS_N_IBLOCKS; j++, i++) @@ -144,7 +144,7 @@ lfs_setup_resblks(struct lfs *fs) "lfsclpl", &pool_allocator_nointr, IPL_NONE); pool_init(&fs->lfs_segpool, sizeof(struct segment), 0, 0, 0, "lfssegpool", &pool_allocator_nointr, IPL_NONE); - maxbpp = ((fs->lfs_sumsize - SEGSUM_SIZE(fs)) / sizeof(int32_t) + 2); + maxbpp = ((lfs_sb_getsumsize(fs) - SEGSUM_SIZE(fs)) / sizeof(int32_t) + 2); maxbpp = MIN(maxbpp, lfs_segsize(fs) / lfs_sb_getfsize(fs) + 2); pool_init(&fs->lfs_bpppool, maxbpp * sizeof(struct buf *), 0, 0, 0, "lfsbpppl", &pool_allocator_nointr, IPL_NONE); @@ -396,7 +396,7 @@ lfs_auto_segclean(struct lfs *fs) * XXX - do we really need to do them all at once? */ waited = 0; - for (i = 0; i < fs->lfs_nseg; i++) { + for (i = 0; i < lfs_sb_getnseg(fs); i++) { if ((fs->lfs_suflags[0][i] & (SEGUSE_ACTIVE | SEGUSE_DIRTY | SEGUSE_EMPTY)) == (SEGUSE_DIRTY | SEGUSE_EMPTY) && @@ -522,8 +522,8 @@ lfs_segunlock(struct lfs *fs) /* If we *know* everything's on disk, write both sbs */ /* XXX should wait for this one */ if (sync) - lfs_writesuper(fs, fs->lfs_sboffs[fs->lfs_activesb]); - lfs_writesuper(fs, fs->lfs_sboffs[1 - fs->lfs_activesb]); + lfs_writesuper(fs, lfs_sb_getsboff(fs, fs->lfs_activesb)); + lfs_writesuper(fs, lfs_sb_getsboff(fs, 1 - fs->lfs_activesb)); if (!(fs->lfs_ivnode->v_mount->mnt_iflag & IMNT_UNMOUNT)) { lfs_auto_segclean(fs); /* If sync, we can clean the remainder too */ diff --git a/sys/ufs/lfs/lfs_syscalls.c b/sys/ufs/lfs/lfs_syscalls.c index e5cb6125c4c2..e180abf46ba2 100644 --- a/sys/ufs/lfs/lfs_syscalls.c +++ b/sys/ufs/lfs/lfs_syscalls.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_syscalls.c,v 1.161 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: lfs_syscalls.c,v 1.162 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007, 2008 @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.161 2015/07/24 06:56:42 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.162 2015/07/24 06:59:32 dholland Exp $"); #ifndef LFS # define LFS /* for prototypes in syscallargs.h */ @@ -872,12 +872,12 @@ lfs_do_segclean(struct lfs *fs, unsigned long segnum) if (sup->su_flags & SEGUSE_SUPERBLOCK) lfs_sb_subavail(fs, lfs_btofsb(fs, LFS_SBPAD)); if (fs->lfs_version > 1 && segnum == 0 && - fs->lfs_s0addr < lfs_btofsb(fs, LFS_LABELPAD)) - lfs_sb_subavail(fs, lfs_btofsb(fs, LFS_LABELPAD) - fs->lfs_s0addr); + lfs_sb_gets0addr(fs) < lfs_btofsb(fs, LFS_LABELPAD)) + lfs_sb_subavail(fs, lfs_btofsb(fs, LFS_LABELPAD) - lfs_sb_gets0addr(fs)); mutex_enter(&lfs_lock); - lfs_sb_addbfree(fs, sup->su_nsums * lfs_btofsb(fs, fs->lfs_sumsize) + + lfs_sb_addbfree(fs, sup->su_nsums * lfs_btofsb(fs, lfs_sb_getsumsize(fs)) + lfs_btofsb(fs, sup->su_ninos * lfs_sb_getibsize(fs))); - lfs_sb_subdmeta(fs, sup->su_nsums * lfs_btofsb(fs, fs->lfs_sumsize) + + lfs_sb_subdmeta(fs, sup->su_nsums * lfs_btofsb(fs, lfs_sb_getsumsize(fs)) + lfs_btofsb(fs, sup->su_ninos * lfs_sb_getibsize(fs))); if (lfs_sb_getdmeta(fs) < 0) lfs_sb_setdmeta(fs, 0); @@ -888,7 +888,7 @@ lfs_do_segclean(struct lfs *fs, unsigned long segnum) LFS_CLEANERINFO(cip, fs, bp); ++cip->clean; --cip->dirty; - fs->lfs_nclean = cip->clean; + lfs_sb_setnclean(fs, cip->clean); mutex_enter(&lfs_lock); cip->bfree = lfs_sb_getbfree(fs); cip->avail = lfs_sb_getavail(fs) - fs->lfs_ravail - fs->lfs_favail; diff --git a/sys/ufs/lfs/lfs_vfsops.c b/sys/ufs/lfs/lfs_vfsops.c index cf4841c36142..812dc7fd8e3a 100644 --- a/sys/ufs/lfs/lfs_vfsops.c +++ b/sys/ufs/lfs/lfs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_vfsops.c,v 1.327 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: lfs_vfsops.c,v 1.328 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007 @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.327 2015/07/24 06:56:42 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.328 2015/07/24 06:59:32 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_lfs.h" @@ -605,8 +605,8 @@ lfs_mountroot(void) mountlist_append(mp); ump = VFSTOULFS(mp); fs = ump->um_lfs; - memset(fs->lfs_fsmnt, 0, sizeof(fs->lfs_fsmnt)); - (void)copystr(mp->mnt_stat.f_mntonname, fs->lfs_fsmnt, MNAMELEN - 1, 0); + memset(fs->lfs_dlfs.dlfs_fsmnt, 0, sizeof(fs->lfs_dlfs.dlfs_fsmnt)); + (void)copystr(mp->mnt_stat.f_mntonname, fs->lfs_dlfs.dlfs_fsmnt, sizeof(fs->lfs_dlfs.dlfs_fsmnt), 0); (void)lfs_statvfs(mp, &mp->mnt_stat); vfs_unbusy(mp, false, NULL); setrootfstime((time_t)lfs_sb_gettstamp(VFSTOULFS(mp)->um_lfs)); @@ -795,10 +795,10 @@ lfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len) } fs->lfs_ronly = 0; - if (fs->lfs_pflags & LFS_PF_CLEAN) { - fs->lfs_pflags &= ~LFS_PF_CLEAN; - lfs_writesuper(fs, fs->lfs_sboffs[0]); - lfs_writesuper(fs, fs->lfs_sboffs[1]); + if (lfs_sb_getpflags(fs) & LFS_PF_CLEAN) { + lfs_sb_setpflags(fs, lfs_sb_getpflags(fs) & ~LFS_PF_CLEAN); + lfs_writesuper(fs, lfs_sb_getsboff(fs, 0)); + lfs_writesuper(fs, lfs_sb_getsboff(fs, 1)); } } if (args->fspec == NULL) @@ -808,8 +808,9 @@ lfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len) error = set_statvfs_info(path, UIO_USERSPACE, args->fspec, UIO_USERSPACE, mp->mnt_op->vfs_name, mp, l); if (error == 0) - (void)strncpy(fs->lfs_fsmnt, mp->mnt_stat.f_mntonname, - sizeof(fs->lfs_fsmnt)); + (void)strncpy(fs->lfs_dlfs.dlfs_fsmnt, + mp->mnt_stat.f_mntonname, + sizeof(fs->lfs_dlfs.dlfs_fsmnt)); return error; fail: @@ -952,15 +953,15 @@ lfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l) /* Compatibility */ if (fs->lfs_version < 2) { - fs->lfs_sumsize = LFS_V1_SUMMARY_SIZE; + lfs_sb_setsumsize(fs, LFS_V1_SUMMARY_SIZE); lfs_sb_setibsize(fs, lfs_sb_getbsize(fs)); - fs->lfs_s0addr = fs->lfs_sboffs[0]; + lfs_sb_sets0addr(fs, lfs_sb_getsboff(fs, 0)); lfs_sb_settstamp(fs, lfs_sb_getotstamp(fs)); lfs_sb_setfsbtodb(fs, 0); } - if (fs->lfs_resvseg == 0) - fs->lfs_resvseg = MIN(fs->lfs_minfreeseg - 1, \ - MAX(MIN_RESV_SEGS, fs->lfs_minfreeseg / 2 + 1)); + if (lfs_sb_getresvseg(fs) == 0) + lfs_sb_setresvseg(fs, MIN(lfs_sb_getminfreeseg(fs) - 1, \ + MAX(MIN_RESV_SEGS, lfs_sb_getminfreeseg(fs) / 2 + 1))); /* * If we aren't going to be able to write meaningfully to this @@ -1028,13 +1029,13 @@ lfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l) /* ulfs-level information */ fs->um_flags = 0; - fs->um_bptrtodb = fs->lfs_ffshift - DEV_BSHIFT; + fs->um_bptrtodb = lfs_sb_getffshift(fs) - DEV_BSHIFT; fs->um_seqinc = lfs_sb_getfrag(fs); - fs->um_nindir = fs->lfs_nindir; - fs->um_lognindir = ffs(fs->lfs_nindir) - 1; - fs->um_maxsymlinklen = fs->lfs_maxsymlinklen; + fs->um_nindir = lfs_sb_getnindir(fs); + fs->um_lognindir = ffs(lfs_sb_getnindir(fs)) - 1; + fs->um_maxsymlinklen = lfs_sb_getmaxsymlinklen(fs); fs->um_dirblksiz = LFS_DIRBLKSIZ; - fs->um_maxfilesize = fs->lfs_maxfilesize; + fs->um_maxfilesize = lfs_sb_getmaxfilesize(fs); /* quota stuff */ /* XXX: these need to come from the on-disk superblock to be used */ @@ -1053,7 +1054,7 @@ lfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l) mp->mnt_stat.f_namemax = LFS_MAXNAMLEN; mp->mnt_stat.f_iosize = lfs_sb_getbsize(fs); mp->mnt_flag |= MNT_LOCAL; - mp->mnt_fs_bshift = fs->lfs_bshift; + mp->mnt_fs_bshift = lfs_sb_getbshift(fs); if (fs->um_maxsymlinklen > 0) mp->mnt_iflag |= IMNT_DTYPE; @@ -1093,12 +1094,12 @@ lfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l) fs->lfs_nactive = 0; fs->lfs_suflags = malloc(2 * sizeof(u_int32_t *), M_SEGMENT, M_WAITOK); - fs->lfs_suflags[0] = malloc(fs->lfs_nseg * sizeof(u_int32_t), + fs->lfs_suflags[0] = malloc(lfs_sb_getnseg(fs) * sizeof(u_int32_t), M_SEGMENT, M_WAITOK); - fs->lfs_suflags[1] = malloc(fs->lfs_nseg * sizeof(u_int32_t), + fs->lfs_suflags[1] = malloc(lfs_sb_getnseg(fs) * sizeof(u_int32_t), M_SEGMENT, M_WAITOK); - memset(fs->lfs_suflags[1], 0, fs->lfs_nseg * sizeof(u_int32_t)); - for (i = 0; i < fs->lfs_nseg; i++) { + memset(fs->lfs_suflags[1], 0, lfs_sb_getnseg(fs) * sizeof(u_int32_t)); + for (i = 0; i < lfs_sb_getnseg(fs); i++) { int changed; LFS_SEGENTRY(sup, fs, i, bp); @@ -1183,9 +1184,9 @@ lfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l) /* If writing, sb is not clean; record in case of immediate crash */ if (!fs->lfs_ronly) { - fs->lfs_pflags &= ~LFS_PF_CLEAN; - lfs_writesuper(fs, fs->lfs_sboffs[0]); - lfs_writesuper(fs, fs->lfs_sboffs[1]); + lfs_sb_setpflags(fs, lfs_sb_getpflags(fs) & ~LFS_PF_CLEAN); + lfs_writesuper(fs, lfs_sb_getsboff(fs, 0)); + lfs_writesuper(fs, lfs_sb_getsboff(fs, 1)); } /* Allow vget now that roll-forward is complete */ @@ -1303,9 +1304,9 @@ lfs_unmount(struct mount *mp, int mntflags) mutex_exit(vp->v_interlock); /* Explicitly write the superblock, to update serial and pflags */ - fs->lfs_pflags |= LFS_PF_CLEAN; - lfs_writesuper(fs, fs->lfs_sboffs[0]); - lfs_writesuper(fs, fs->lfs_sboffs[1]); + lfs_sb_setpflags(fs, lfs_sb_getpflags(fs) | LFS_PF_CLEAN); + lfs_writesuper(fs, lfs_sb_getsboff(fs, 0)); + lfs_writesuper(fs, lfs_sb_getsboff(fs, 1)); mutex_enter(&lfs_lock); while (fs->lfs_iocount) mtsleep(&fs->lfs_iocount, PRIBIO + 1, "lfs_umount", 0, @@ -1581,7 +1582,7 @@ lfs_loadvnode(struct mount *mp, struct vnode *vp, retries = 0; again: error = bread(ump->um_devvp, LFS_FSBTODB(fs, daddr), - (fs->lfs_version == 1 ? lfs_sb_getbsize(fs) : fs->lfs_ibsize), + (fs->lfs_version == 1 ? lfs_sb_getbsize(fs) : lfs_sb_getibsize(fs)), 0, &bp); if (error) { lfs_deinit_vnode(ump, vp); @@ -1767,11 +1768,11 @@ lfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) return ESTALE; fs = VFSTOULFS(mp)->um_lfs; - if (lfh.lfid_ident != fs->lfs_ident) + if (lfh.lfid_ident != lfs_sb_getident(fs)) return ESTALE; if (lfh.lfid_ino > - ((VTOI(fs->lfs_ivnode)->i_ffs1_size >> fs->lfs_bshift) - + ((VTOI(fs->lfs_ivnode)->i_ffs1_size >> lfs_sb_getbshift(fs)) - lfs_sb_getcleansz(fs) - lfs_sb_getsegtabsz(fs)) * lfs_sb_getifpb(fs)) return ESTALE; @@ -1798,7 +1799,7 @@ lfs_vptofh(struct vnode *vp, struct fid *fhp, size_t *fh_size) lfh.lfid_len = sizeof(struct lfid); lfh.lfid_ino = ip->i_number; lfh.lfid_gen = ip->i_gen; - lfh.lfid_ident = ip->i_lfs->lfs_ident; + lfh.lfid_ident = lfs_sb_getident(ip->i_lfs); memcpy(fhp, &lfh, sizeof(lfh)); return (0); } @@ -1919,7 +1920,7 @@ lfs_gop_write(struct vnode *vp, struct vm_page **pgs, int npages, failreason = "Inode with no_gop_write"; goto tryagain; } - if ((pgs[0]->offset & fs->lfs_bmask) != 0) { + if ((pgs[0]->offset & lfs_sb_getbmask(fs)) != 0) { failreason = "Bad page offset"; goto tryagain; } @@ -1968,12 +1969,12 @@ lfs_gop_write(struct vnode *vp, struct vm_page **pgs, int npages, * We'll check later to make sure we always write entire * blocks (or fragments). */ - if (startoffset & fs->lfs_bmask) - printf("%" PRId64 " & %" PRId64 " = %" PRId64 "\n", - startoffset, fs->lfs_bmask, - startoffset & fs->lfs_bmask); - KASSERT((startoffset & fs->lfs_bmask) == 0); - if (bytes & fs->lfs_ffmask) { + if (startoffset & lfs_sb_getbmask(fs)) + printf("%" PRId64 " & %" PRIu64 " = %" PRId64 "\n", + startoffset, lfs_sb_getbmask(fs), + startoffset & lfs_sb_getbmask(fs)); + KASSERT((startoffset & lfs_sb_getbmask(fs)) == 0); + if (bytes & lfs_sb_getffmask(fs)) { printf("lfs_gop_write: asked to write %ld bytes\n", (long)bytes); panic("lfs_gop_write: non-integer blocks"); } @@ -2043,7 +2044,7 @@ lfs_gop_write(struct vnode *vp, struct vm_page **pgs, int npages, */ /* If no room in the current segment, finish it up */ if (sp->sum_bytes_left < sizeof(int32_t) || - sp->seg_bytes_left < (1 << fs->lfs_bshift)) { + sp->seg_bytes_left < (1 << lfs_sb_getbshift(fs))) { int vers; lfs_updatemeta(sp); @@ -2202,7 +2203,7 @@ lfs_vinit(struct mount *mp, struct vnode **vpp) memset(ip->i_lfs_fragsize, 0, ULFS_NDADDR * sizeof(*ip->i_lfs_fragsize)); if (vp->v_type != VLNK || ip->i_size >= ip->i_lfs->um_maxsymlinklen) { #ifdef DEBUG - for (i = (ip->i_size + lfs_sb_getbsize(fs) - 1) >> fs->lfs_bshift; + for (i = (ip->i_size + lfs_sb_getbsize(fs) - 1) >> lfs_sb_getbshift(fs); i < ULFS_NDADDR; i++) { if ((vp->v_type == VBLK || vp->v_type == VCHR) && i == 0) @@ -2273,12 +2274,13 @@ lfs_resize_fs(struct lfs *fs, int newnsegs) return EOPNOTSUPP; /* If we're doing nothing, do it fast */ - oldnsegs = fs->lfs_nseg; + oldnsegs = lfs_sb_getnseg(fs); if (newnsegs == oldnsegs) return 0; /* We always have to have two superblocks */ - if (newnsegs <= lfs_dtosn(fs, fs->lfs_sboffs[1])) + if (newnsegs <= lfs_dtosn(fs, lfs_sb_getsboff(fs, 1))) + /* XXX this error code is rather nonsense */ return EFBIG; ivp = fs->lfs_ivnode; @@ -2316,7 +2318,7 @@ lfs_resize_fs(struct lfs *fs, int newnsegs) /* Note old and new segment table endpoints, and old ifile size */ olast = lfs_sb_getcleansz(fs) + lfs_sb_getsegtabsz(fs); nlast = howmany(newnsegs, lfs_sb_getsepb(fs)) + lfs_sb_getcleansz(fs); - ilast = ivp->v_size >> fs->lfs_bshift; + ilast = ivp->v_size >> lfs_sb_getbshift(fs); noff = nlast - olast; /* @@ -2388,8 +2390,8 @@ lfs_resize_fs(struct lfs *fs, int newnsegs) /* Zero out unused superblock offsets */ for (i = 2; i < LFS_MAXNUMSB; i++) - if (lfs_dtosn(fs, fs->lfs_sboffs[i]) >= newnsegs) - fs->lfs_sboffs[i] = 0x0; + if (lfs_dtosn(fs, lfs_sb_getsboff(fs, i)) >= newnsegs) + lfs_sb_setsboff(fs, i, 0x0); /* * Correct superblock entries that depend on fs size. @@ -2405,39 +2407,39 @@ lfs_resize_fs(struct lfs *fs, int newnsegs) * XXX - we should probably adjust minfreeseg as well. */ gain = (newnsegs - oldnsegs); - fs->lfs_nseg = newnsegs; + lfs_sb_setnseg(fs, newnsegs); lfs_sb_setsegtabsz(fs, nlast - lfs_sb_getcleansz(fs)); lfs_sb_addsize(fs, gain * lfs_btofsb(fs, lfs_sb_getssize(fs))); lfs_sb_adddsize(fs, gain * lfs_btofsb(fs, lfs_sb_getssize(fs)) - lfs_btofsb(fs, sbbytes)); lfs_sb_addbfree(fs, gain * lfs_btofsb(fs, lfs_sb_getssize(fs)) - lfs_btofsb(fs, sbbytes) - gain * lfs_btofsb(fs, lfs_sb_getbsize(fs) / 2)); if (gain > 0) { - fs->lfs_nclean += gain; + lfs_sb_addnclean(fs, gain); lfs_sb_addavail(fs, gain * lfs_btofsb(fs, lfs_sb_getssize(fs))); } else { - fs->lfs_nclean -= cgain; + lfs_sb_subnclean(fs, cgain); lfs_sb_subavail(fs, cgain * lfs_btofsb(fs, lfs_sb_getssize(fs)) - lfs_btofsb(fs, csbbytes)); } /* Resize segment flag cache */ fs->lfs_suflags[0] = realloc(fs->lfs_suflags[0], - fs->lfs_nseg * sizeof(u_int32_t), M_SEGMENT, M_WAITOK); + lfs_sb_getnseg(fs) * sizeof(u_int32_t), M_SEGMENT, M_WAITOK); fs->lfs_suflags[1] = realloc(fs->lfs_suflags[1], - fs->lfs_nseg * sizeof(u_int32_t), M_SEGMENT, M_WAITOK); + lfs_sb_getnseg(fs) * sizeof(u_int32_t), M_SEGMENT, M_WAITOK); for (i = oldnsegs; i < newnsegs; i++) fs->lfs_suflags[0][i] = fs->lfs_suflags[1][i] = 0x0; /* Truncate Ifile if necessary */ if (noff < 0) - lfs_truncate(ivp, ivp->v_size + (noff << fs->lfs_bshift), 0, + lfs_truncate(ivp, ivp->v_size + (noff << lfs_sb_getbshift(fs)), 0, NOCRED); /* Update cleaner info so the cleaner can die */ /* XXX what to do if bread fails? */ bread(ivp, 0, lfs_sb_getbsize(fs), B_MODIFY, &bp); - ((CLEANERINFO *)bp->b_data)->clean = fs->lfs_nclean; - ((CLEANERINFO *)bp->b_data)->dirty = fs->lfs_nseg - fs->lfs_nclean; + ((CLEANERINFO *)bp->b_data)->clean = lfs_sb_getnclean(fs); + ((CLEANERINFO *)bp->b_data)->dirty = lfs_sb_getnseg(fs) - lfs_sb_getnclean(fs); VOP_BWRITE(bp->b_vp, bp); /* Let Ifile accesses proceed */ diff --git a/sys/ufs/lfs/lfs_vnops.c b/sys/ufs/lfs/lfs_vnops.c index 29c38639dc4f..b401a7599ead 100644 --- a/sys/ufs/lfs/lfs_vnops.c +++ b/sys/ufs/lfs/lfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_vnops.c,v 1.274 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: lfs_vnops.c,v 1.275 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -125,7 +125,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.274 2015/07/24 06:56:42 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.275 2015/07/24 06:59:32 dholland Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -1229,7 +1229,8 @@ lfs_wrapgo(struct lfs *fs, struct inode *ip, int waitfor) } if (--fs->lfs_nowrap == 0) { - log(LOG_NOTICE, "%s: re-enabled log wrap\n", fs->lfs_fsmnt); + log(LOG_NOTICE, "%s: re-enabled log wrap\n", + lfs_sb_getfsmnt(fs)); wakeup(&fs->lfs_wrappass); lfs_wakeup_cleaner(fs); } @@ -1363,7 +1364,7 @@ lfs_reclaim(void *v) mutex_enter(&lfs_lock); if (ip->i_flags & IN_PAGING) { log(LOG_WARNING, "%s: reclaimed vnode is IN_PAGING\n", - fs->lfs_fsmnt); + lfs_sb_getfsmnt(fs)); ip->i_flags &= ~IN_PAGING; TAILQ_REMOVE(&fs->lfs_pchainhd, ip, i_lfs_pchain); } @@ -1935,7 +1936,8 @@ segwait_common: cv_wait(&fs->lfs_stopcv, &lfs_lock); fs->lfs_stoplwp = curlwp; if (fs->lfs_nowrap == 0) - log(LOG_NOTICE, "%s: disabled log wrap\n", fs->lfs_fsmnt); + log(LOG_NOTICE, "%s: disabled log wrap\n", + lfs_sb_getfsmnt(fs)); ++fs->lfs_nowrap; if (*(int *)ap->a_data == 1 || ap->a_command == LFCNWRAPSTOP_COMPAT) { diff --git a/sys/ufs/lfs/ulfs_inode.h b/sys/ufs/lfs/ulfs_inode.h index 47cfb1730172..e9f9b9a0ba34 100644 --- a/sys/ufs/lfs/ulfs_inode.h +++ b/sys/ufs/lfs/ulfs_inode.h @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_inode.h,v 1.13 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: ulfs_inode.h,v 1.14 2015/07/24 06:59:32 dholland Exp $ */ /* from NetBSD: inode.h,v 1.64 2012/11/19 00:36:21 jakllsch Exp */ /* @@ -78,8 +78,8 @@ void lfs_unset_dirop(struct lfs *, struct vnode *, const char *); #define LFS_MAX_DIROP ((desiredvnodes >> 2) + (desiredvnodes >> 3)) #define SIZEOF_DIROP(fs) (2 * (lfs_sb_getbsize(fs) + LFS_DINODE1_SIZE)) #define LFS_MAX_FSDIROP(fs) \ - ((fs)->lfs_nclean <= (fs)->lfs_resvseg ? 0 : \ - (((fs)->lfs_nclean - (fs)->lfs_resvseg) * lfs_sb_getssize(fs)) / \ + (lfs_sb_getnclean(fs) <= lfs_sb_getresvseg(fs) ? 0 : \ + ((lfs_sb_getnclean(fs) - lfs_sb_getresvseg(fs)) * lfs_sb_getssize(fs)) / \ (2 * SIZEOF_DIROP(fs))) #define LFS_MAX_PAGES lfs_max_pages() #define LFS_WAIT_PAGES lfs_wait_pages() @@ -93,7 +93,7 @@ int lfs_max_pages(void); #endif /* _KERNEL */ /* How starved can we be before we start holding back page writes */ -#define LFS_STARVED_FOR_SEGS(fs) ((fs)->lfs_nclean < (fs)->lfs_resvseg) +#define LFS_STARVED_FOR_SEGS(fs) (lfs_sb_getnclean(fs) < lfs_sb_getresvseg(fs)) /* * Reserved blocks for lfs_malloc diff --git a/sys/ufs/lfs/ulfs_quota2.c b/sys/ufs/lfs/ulfs_quota2.c index 6496f0dd7bb3..4e475142c6b1 100644 --- a/sys/ufs/lfs/ulfs_quota2.c +++ b/sys/ufs/lfs/ulfs_quota2.c @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_quota2.c,v 1.19 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: ulfs_quota2.c,v 1.20 2015/07/24 06:59:32 dholland Exp $ */ /* from NetBSD: ufs_quota2.c,v 1.35 2012/09/27 07:47:56 bouyer Exp */ /* from NetBSD: ffs_quota2.c,v 1.4 2011/06/12 03:36:00 rmind Exp */ @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ulfs_quota2.c,v 1.19 2015/07/24 06:56:42 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ulfs_quota2.c,v 1.20 2015/07/24 06:59:32 dholland Exp $"); #include #include @@ -1563,7 +1563,7 @@ lfs_quota2_mount(struct mount *mp) fs->um_flags |= ULFS_QUOTA2; ump->umq2_bsize = lfs_sb_getbsize(fs); - ump->umq2_bmask = fs->lfs_bmask; + ump->umq2_bmask = lfs_sb_getbmask(fs); if (fs->lfs_quota_magic != Q2_HEAD_MAGIC) { printf("%s: Invalid quota magic number\n", mp->mnt_stat.f_mntonname); diff --git a/sys/ufs/lfs/ulfs_readwrite.c b/sys/ufs/lfs/ulfs_readwrite.c index 3ff5a2b9bb2f..53a549c74f33 100644 --- a/sys/ufs/lfs/ulfs_readwrite.c +++ b/sys/ufs/lfs/ulfs_readwrite.c @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_readwrite.c,v 1.18 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: ulfs_readwrite.c,v 1.19 2015/07/24 06:59:32 dholland Exp $ */ /* from NetBSD: ufs_readwrite.c,v 1.105 2013/01/22 09:39:18 dholland Exp */ /*- @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.18 2015/07/24 06:56:42 dholland Exp $"); +__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.19 2015/07/24 06:59:32 dholland Exp $"); #ifdef LFS_READWRITE #define FS struct lfs @@ -337,7 +337,7 @@ WRITE(void *v) goto out; if (flags & B_SYNC) { mutex_enter(vp->v_interlock); - VOP_PUTPAGES(vp, trunc_page(osize & fs->fs_bmask), + VOP_PUTPAGES(vp, trunc_page(osize & lfs_sb_getbmask(fs)), round_page(eob), PGO_CLEANIT | PGO_SYNCIO); } @@ -443,7 +443,7 @@ WRITE(void *v) } if (error == 0 && ioflag & IO_SYNC) { mutex_enter(vp->v_interlock); - error = VOP_PUTPAGES(vp, trunc_page(origoff & fs->fs_bmask), + error = VOP_PUTPAGES(vp, trunc_page(origoff & lfs_sb_getbmask(fs)), round_page(lfs_blkroundup(fs, uio->uio_offset)), PGO_CLEANIT | PGO_SYNCIO); } @@ -523,7 +523,7 @@ BUFWR(struct vnode *vp, struct uio *uio, int ioflag, kauth_cred_t cred) #ifdef LFS_READWRITE error = lfs_reserve(fs, vp, NULL, - lfs_btofsb(fs, (ULFS_NIADDR + 1) << fs->lfs_bshift)); + lfs_btofsb(fs, (ULFS_NIADDR + 1) << lfs_sb_getbshift(fs))); if (error) break; need_unreserve = true; @@ -557,7 +557,7 @@ BUFWR(struct vnode *vp, struct uio *uio, int ioflag, kauth_cred_t cred) #ifdef LFS_READWRITE (void)VOP_BWRITE(bp->b_vp, bp); lfs_reserve(fs, vp, NULL, - -lfs_btofsb(fs, (ULFS_NIADDR + 1) << fs->lfs_bshift)); + -lfs_btofsb(fs, (ULFS_NIADDR + 1) << lfs_sb_getbshift(fs))); need_unreserve = false; #else if (ioflag & IO_SYNC) @@ -573,7 +573,7 @@ BUFWR(struct vnode *vp, struct uio *uio, int ioflag, kauth_cred_t cred) #ifdef LFS_READWRITE if (need_unreserve) { lfs_reserve(fs, vp, NULL, - -lfs_btofsb(fs, (ULFS_NIADDR + 1) << fs->lfs_bshift)); + -lfs_btofsb(fs, (ULFS_NIADDR + 1) << lfs_sb_getbshift(fs))); } #endif diff --git a/usr.sbin/dumplfs/dumplfs.c b/usr.sbin/dumplfs/dumplfs.c index 961395105e42..8afb995f5ae2 100644 --- a/usr.sbin/dumplfs/dumplfs.c +++ b/usr.sbin/dumplfs/dumplfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: dumplfs.c,v 1.43 2015/07/24 06:56:42 dholland Exp $ */ +/* $NetBSD: dumplfs.c,v 1.44 2015/07/24 06:59:32 dholland Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\ #if 0 static char sccsid[] = "@(#)dumplfs.c 8.5 (Berkeley) 5/24/95"; #else -__RCSID("$NetBSD: dumplfs.c,v 1.43 2015/07/24 06:56:42 dholland Exp $"); +__RCSID("$NetBSD: dumplfs.c,v 1.44 2015/07/24 06:59:32 dholland Exp $"); #endif #endif /* not lint */ @@ -189,8 +189,8 @@ main(int argc, char **argv) /* If that wasn't the real first sb, get the real first sb */ if (lfs_sb1.lfs_version > 1 && - lfs_sb1.lfs_sboffs[0] > lfs_btofsb(&lfs_sb1, LFS_LABELPAD)) - get(fd, lfs_fsbtob(&lfs_sb1, lfs_sb1.lfs_sboffs[0]), + lfs_sb_getsboff(&lfs_sb1, 0) > lfs_btofsb(&lfs_sb1, LFS_LABELPAD)) + get(fd, lfs_fsbtob(&lfs_sb1, lfs_sb_getsboff(&lfs_sb1, 0)), &(lfs_sb1.lfs_dlfs), sizeof(struct dlfs)); /* @@ -198,7 +198,7 @@ main(int argc, char **argv) * most up to date. */ get(fd, - fsbtobyte(&lfs_sb1, lfs_sb1.lfs_sboffs[1]), + fsbtobyte(&lfs_sb1, lfs_sb_getsboff(&lfs_sb1, 1)), sbuf, LFS_SBPAD); memcpy(&(lfs_sb2.lfs_dlfs), sbuf, sizeof(struct dlfs)); @@ -206,15 +206,15 @@ main(int argc, char **argv) if (lfs_sb1.lfs_version > 1) { if (lfs_sb_getserial(&lfs_sb1) > lfs_sb_getserial(&lfs_sb2)) { lfs_master = &lfs_sb2; - sbdaddr = lfs_sb1.lfs_sboffs[1]; + sbdaddr = lfs_sb_getsboff(&lfs_sb1, 1); } else - sbdaddr = lfs_sb1.lfs_sboffs[0]; + sbdaddr = lfs_sb_getsboff(&lfs_sb1, 0); } else { if (lfs_sb_getotstamp(&lfs_sb1) > lfs_sb_getotstamp(&lfs_sb2)) { lfs_master = &lfs_sb2; - sbdaddr = lfs_sb1.lfs_sboffs[1]; + sbdaddr = lfs_sb_getsboff(&lfs_sb1, 1); } else - sbdaddr = lfs_sb1.lfs_sboffs[0]; + sbdaddr = lfs_sb_getsboff(&lfs_sb1, 0); } } else { /* Read the first superblock */ @@ -227,11 +227,11 @@ main(int argc, char **argv) /* Compatibility */ if (lfs_master->lfs_version == 1) { - lfs_master->lfs_sumsize = LFS_V1_SUMMARY_SIZE; - lfs_master->lfs_ibsize = lfs_sb_getbsize(lfs_master); - lfs_master->lfs_s0addr = lfs_master->lfs_sboffs[0]; + lfs_sb_setsumsize(lfs_master, LFS_V1_SUMMARY_SIZE); + lfs_sb_setibsize(lfs_master, lfs_sb_getbsize(lfs_master)); + lfs_sb_sets0addr(lfs_master, lfs_sb_getsboff(lfs_master, 0)); lfs_sb_settstamp(lfs_master, lfs_sb_getotstamp(lfs_master)); - lfs_master->lfs_fsbtodb = 0; + lfs_sb_setfsbtodb(lfs_master, 0); } (void)printf("Master Superblock at 0x%llx:\n", (long long)sbdaddr); @@ -247,7 +247,7 @@ main(int argc, char **argv) } else for (segnum = 0, seg_addr = lfs_sntod(lfs_master, 0); - segnum < lfs_master->lfs_nseg; + segnum < lfs_sb_getnseg(lfs_master); segnum++, seg_addr = lfs_sntod(lfs_master, segnum)) dump_segment(fd, segnum, seg_addr, lfs_master, do_allsb); @@ -507,7 +507,7 @@ dump_sum(int fd, struct lfs *lfsp, SEGSUM *sp, int segnum, daddr_t addr) (long long)addr); return -1; } - if (lfsp->lfs_version > 1 && sp->ss_ident != lfsp->lfs_ident) { + if (lfsp->lfs_version > 1 && sp->ss_ident != lfs_sb_getident(lfsp)) { (void)printf("dumplfs: %s %d address 0x%llx\n", "summary from a former life; segment", segnum, (long long)addr); @@ -661,12 +661,12 @@ dump_segment(int fd, int segnum, daddr_t addr, struct lfs *lfsp, int dump_sb) sumblock = malloc(lfs_sb_getsumsize(lfsp)); if (lfsp->lfs_version > 1 && segnum == 0) { - if (lfs_fsbtob(lfsp, lfsp->lfs_s0addr) < LFS_LABELPAD) { + if (lfs_fsbtob(lfsp, lfs_sb_gets0addr(lfsp)) < LFS_LABELPAD) { /* First segment eats the disklabel */ sum_offset += lfs_fragroundup(lfsp, LFS_LABELPAD) - - lfs_fsbtob(lfsp, lfsp->lfs_s0addr); + lfs_fsbtob(lfsp, lfs_sb_gets0addr(lfsp)); addr += lfs_btofsb(lfsp, lfs_fragroundup(lfsp, LFS_LABELPAD)) - - lfsp->lfs_s0addr; + lfs_sb_gets0addr(lfsp); printf("Disklabel at 0x0\n"); } } @@ -771,13 +771,13 @@ dump_super(struct lfs *lfsp) "interleave ", lfs_sb_getinterleave(lfsp), "sumsize ", lfs_sb_getsumsize(lfsp)); (void)printf(" %s%-10d %s0x%-8jx\n", - "seg0addr ", lfsp->lfs_s0addr, + "seg0addr ", lfs_sb_gets0addr(lfsp), "maxfilesize ", (uintmax_t)lfs_sb_getmaxfilesize(lfsp)); (void)printf(" Superblock disk addresses:\n "); for (i = 0; i < LFS_MAXNUMSB; i++) { - (void)printf(" 0x%-8x", lfsp->lfs_sboffs[i]); + (void)printf(" 0x%-8x", lfs_sb_getsboff(lfsp, i)); if (i == (LFS_MAXNUMSB >> 1)) (void)printf("\n "); }