Prefix most of the cpp macros with lfs_ and LFS_ to avoid conflicts with ffs.

This was done so that boot blocks that want to compile both FFS and LFS in
the same file work.
This commit is contained in:
christos 2013-06-18 18:18:57 +00:00
parent e6d3356bdb
commit 855bb66ef7
35 changed files with 686 additions and 677 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: coalesce.c,v 1.22 2013/06/08 21:15:30 dholland Exp $ */
/* $NetBSD: coalesce.c,v 1.23 2013/06/18 18:18:57 christos Exp $ */
/*-
* Copyright (c) 2002, 2005 The NetBSD Foundation, Inc.
@ -160,7 +160,7 @@ clean_inode(struct clfs *fs, ino_t ino)
return COALESCE_NOINODE;
/* Compute file block size, set up for bmapv */
onb = nb = lblkno(fs, dip->di_size);
onb = nb = lfs_lblkno(fs, dip->di_size);
/* XXX for now, don't do any file small enough to have fragments */
if (nb < ULFS_NDADDR) {
@ -229,7 +229,7 @@ clean_inode(struct clfs *fs, ino_t ino)
* can have a break or two and it's okay.
*/
if (nb <= 1 || noff == 0 || noff < log2int(nb) ||
segtod(fs, noff) * 2 < nb) {
lfs_segtod(fs, noff) * 2 < nb) {
retval = COALESCE_NOTWORTHIT;
goto out;
} else if (debug)
@ -241,7 +241,7 @@ clean_inode(struct clfs *fs, ino_t ino)
for (i = 0; i < nb; i++) {
if (bip[i].bi_daddr <= 0)
continue;
sup = &fs->clfs_segtab[dtosn(fs, bip[i].bi_daddr)];
sup = &fs->clfs_segtab[lfs_dtosn(fs, bip[i].bi_daddr)];
if (sup->flags & SEGUSE_ACTIVE)
bip[i].bi_daddr = LFS_UNUSED_DADDR; /* 0 */
}
@ -280,7 +280,7 @@ clean_inode(struct clfs *fs, ino_t ino)
}
if (kops.ko_pread(fs->clfs_devfd, bip[i].bi_bp, bip[i].bi_size,
fsbtob(fs, bip[i].bi_daddr)) < 0) {
lfs_fsbtob(fs, bip[i].bi_daddr)) < 0) {
retval = COALESCE_EIO;
goto out;
}
@ -294,7 +294,7 @@ clean_inode(struct clfs *fs, ino_t ino)
* than half of the available segments, sleep until that's not
* true any more.
*/
bps = segtod(fs, 1);
bps = lfs_segtod(fs, 1);
for (tbip = bip; tbip < bip + nb; tbip += bps) {
do {
bread(fs->lfs_ivnode, 0, fs->lfs_bsize, NOCRED, 0, &bp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: fdfs.c,v 1.9 2012/04/12 10:30:17 joerg Exp $ */
/* $NetBSD: fdfs.c,v 1.10 2013/06/18 18:18:57 christos Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@ -64,12 +64,11 @@ fd_vget(int fd, int bsize, int segsize, int nseg)
struct uvnode *vp;
int i;
fs = (struct fdfs *)malloc(sizeof(*fs));
fs = malloc(sizeof(*fs));
if (fs == NULL)
return NULL;
if (segsize > 0) {
fs->fd_bufp = (struct fd_buf *)malloc(nseg *
sizeof(struct fd_buf));
fs->fd_bufp = malloc(nseg * sizeof(struct fd_buf));
if (fs->fd_bufp == NULL) {
free(fs);
return NULL;
@ -77,7 +76,7 @@ fd_vget(int fd, int bsize, int segsize, int nseg)
for (i = 0; i < nseg; i++) {
fs->fd_bufp[i].start = 0x0;
fs->fd_bufp[i].end = 0x0;
fs->fd_bufp[i].buf = (char *)malloc(segsize);
fs->fd_bufp[i].buf = malloc(segsize);
if (fs->fd_bufp[i].buf == NULL) {
while (--i >= 0)
free(fs->fd_bufp[i].buf);
@ -95,7 +94,7 @@ fd_vget(int fd, int bsize, int segsize, int nseg)
fs->fd_bsize = bsize;
fs->fd_ssize = segsize;
vp = (struct uvnode *) malloc(sizeof(*vp));
vp = malloc(sizeof(*vp));
if (vp == NULL) {
if (fs->fd_bufp) {
for (i = 0; i < nseg; i++)
@ -190,7 +189,7 @@ fd_preload(struct uvnode *vp, daddr_t start)
fs->fd_bufp = t;
fs->fd_bufp[fs->fd_bufi].start = 0x0;
fs->fd_bufp[fs->fd_bufi].end = 0x0;
fs->fd_bufp[fs->fd_bufi].buf = (char *)malloc(fs->fd_ssize);
fs->fd_bufp[fs->fd_bufi].buf = malloc(fs->fd_ssize);
if (fs->fd_bufp[fs->fd_bufi].buf == NULL) {
syslog(LOG_NOTICE, "failed to allocate buffer #%d\n",
fs->fd_bufc);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_cleanerd.c,v 1.35 2013/06/08 21:15:30 dholland Exp $ */
/* $NetBSD: lfs_cleanerd.c,v 1.36 2013/06/18 18:18:57 christos Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@ -438,7 +438,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, dtosn(fs, odaddr));
fs->lfs_fsmnt, odaddr, lfs_dtosn(fs, odaddr));
*bipp = bip;
return 0x0;
}
@ -487,7 +487,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 += btofsb(fs, fs->lfs_ibsize);
daddr += lfs_btofsb(fs, fs->lfs_ibsize);
--iaddrp;
continue;
}
@ -512,7 +512,7 @@ parse_pseg(struct clfs *fs, daddr_t daddr, BLOCK_INFO **bipp, int *bic)
SEGSUM *nssp;
syslog(LOG_WARNING, "fixing short FINFO at %x (seg %d)",
odaddr, dtosn(fs, odaddr));
odaddr, lfs_dtosn(fs, odaddr));
bread(fs->clfs_devvp, odaddr, fs->lfs_fsize,
NOCRED, 0, &nbp);
nssp = (SEGSUM *)nbp->b_data;
@ -522,7 +522,7 @@ parse_pseg(struct clfs *fs, daddr_t daddr, BLOCK_INFO **bipp, int *bic)
bwrite(nbp);
#endif
syslog(LOG_WARNING, "zero-length FINFO at %x (seg %d)",
odaddr, dtosn(fs, odaddr));
odaddr, lfs_dtosn(fs, odaddr));
continue;
}
@ -545,7 +545,7 @@ parse_pseg(struct clfs *fs, daddr_t daddr, BLOCK_INFO **bipp, int *bic)
fip->fi_lastlength : fs->lfs_bsize;
cp = fd_ptrget(fs->clfs_devvp, daddr);
ck = lfs_cksum_part(cp, sizeof(u_int32_t), ck);
daddr += btofsb(fs, size);
daddr += lfs_btofsb(fs, size);
}
fip = (FINFO *)(fip->fi_blocks + fip->fi_nblocks);
continue;
@ -572,7 +572,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);
bip[*bic + i].bi_bp = cp;
daddr += btofsb(fs, bip[*bic + i].bi_size);
daddr += lfs_btofsb(fs, bip[*bic + i].bi_size);
#ifdef TEST_PATTERN
check_test_pattern(bip + *bic + i); /* XXXDEBUG */
@ -613,7 +613,7 @@ log_segment_read(struct clfs *fs, int sn)
* indexed by the segment serial numbers; but it is not suitable
* for everyday use since the copylog will be simply enormous.
*/
cp = fd_ptrget(fs->clfs_devvp, sntod(fs, sn));
cp = fd_ptrget(fs->clfs_devvp, lfs_sntod(fs, sn));
fp = fopen(copylog_filename, "ab");
if (fp != NULL) {
@ -634,18 +634,18 @@ load_segment(struct clfs *fs, int sn, BLOCK_INFO **bipp, int *bic)
int32_t daddr;
int i, npseg;
daddr = sntod(fs, sn);
if (daddr < btofsb(fs, LFS_LABELPAD))
daddr = btofsb(fs, LFS_LABELPAD);
daddr = lfs_sntod(fs, sn);
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) {
daddr += btofsb(fs, LFS_SBPAD);
daddr += lfs_btofsb(fs, LFS_SBPAD);
break;
}
}
/* Preload the segment buffer */
if (fd_preload(fs->clfs_devvp, sntod(fs, sn)) < 0)
if (fd_preload(fs->clfs_devvp, lfs_sntod(fs, sn)) < 0)
return -1;
if (copylog_filename)
@ -657,8 +657,8 @@ load_segment(struct clfs *fs, int sn, BLOCK_INFO **bipp, int *bic)
++fs->clfs_nactive;
npseg = 0;
while(dtosn(fs, daddr) == sn &&
dtosn(fs, daddr + btofsb(fs, fs->lfs_bsize)) == sn) {
while(lfs_dtosn(fs, daddr) == sn &&
lfs_dtosn(fs, daddr + lfs_btofsb(fs, fs->lfs_bsize)) == sn) {
daddr = parse_pseg(fs, daddr, bipp, bic);
if (daddr == 0x0) {
++cleaner_stats.segs_error;
@ -1237,7 +1237,7 @@ needs_cleaning(struct clfs *fs, CLEANERINFO *cip)
}
/* Compute theoretical "free segments" maximum based on usage */
fsb_per_seg = segtod(fs, 1);
fsb_per_seg = lfs_segtod(fs, 1);
max_free_segs = MAX(cip->bfree, 0) / fsb_per_seg + fs->lfs_minfreeseg;
dlog("%s: bfree = %d, avail = %d, clean = %d/%d",

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.31 2013/06/08 02:16:03 dholland Exp $ */
/* $NetBSD: dir.c,v 1.32 2013/06/18 18:18:58 christos Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -563,7 +563,7 @@ expanddir(struct uvnode *vp, struct ulfs1_dinode *dp, char *name)
struct ubuf *bp;
char *cp, firstblk[LFS_DIRBLKSIZ];
lastbn = lblkno(fs, dp->di_size);
lastbn = lfs_lblkno(fs, dp->di_size);
if (lastbn >= ULFS_NDADDR - 1 || dp->di_db[lastbn] == 0 || dp->di_size == 0)
return (0);
dp->di_db[lastbn + 1] = dp->di_db[lastbn];
@ -571,9 +571,9 @@ expanddir(struct uvnode *vp, struct ulfs1_dinode *dp, char *name)
bp = getblk(vp, lastbn, fs->lfs_bsize);
VOP_BWRITE(bp);
dp->di_size += fs->lfs_bsize;
dp->di_blocks += btofsb(fs, fs->lfs_bsize);
dp->di_blocks += lfs_btofsb(fs, fs->lfs_bsize);
bread(vp, dp->di_db[lastbn + 1],
(long) dblksize(fs, dp, lastbn + 1), NOCRED, 0, &bp);
(long) lfs_dblksize(fs, dp, lastbn + 1), NOCRED, 0, &bp);
if (bp->b_flags & B_ERROR)
goto bad;
memcpy(firstblk, bp->b_data, LFS_DIRBLKSIZ);
@ -587,7 +587,7 @@ expanddir(struct uvnode *vp, struct ulfs1_dinode *dp, char *name)
memcpy(cp, &emptydir, sizeof emptydir);
VOP_BWRITE(bp);
bread(vp, dp->di_db[lastbn + 1],
(long) dblksize(fs, dp, lastbn + 1), NOCRED, 0, &bp);
(long) lfs_dblksize(fs, dp, lastbn + 1), NOCRED, 0, &bp);
if (bp->b_flags & B_ERROR)
goto bad;
memcpy(bp->b_data, &emptydir, sizeof emptydir);
@ -603,7 +603,7 @@ bad:
dp->di_db[lastbn] = dp->di_db[lastbn + 1];
dp->di_db[lastbn + 1] = 0;
dp->di_size -= fs->lfs_bsize;
dp->di_blocks -= btofsb(fs, fs->lfs_bsize);
dp->di_blocks -= lfs_btofsb(fs, fs->lfs_bsize);
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: inode.c,v 1.50 2013/06/08 02:16:03 dholland Exp $ */
/* $NetBSD: inode.c,v 1.51 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -111,7 +111,7 @@ ginode(ino_t ino)
if (din_table[ino] == 0x0) {
LFS_IENTRY(ifp, fs, ino, bp);
din_table[ino] = ifp->if_daddr;
seg_table[dtosn(fs, ifp->if_daddr)].su_nbytes += LFS_DINODE1_SIZE;
seg_table[lfs_dtosn(fs, ifp->if_daddr)].su_nbytes += LFS_DINODE1_SIZE;
brelse(bp, 0);
}
return (VTOI(vp)->i_din.ffs1_din);
@ -149,11 +149,11 @@ ckinode(struct ulfs1_dinode *dp, struct inodesc *idesc)
ap = dino.di_db + lbn;
if (thisvp)
idesc->id_numfrags =
numfrags(fs, VTOI(thisvp)->i_lfs_fragsize[lbn]);
lfs_numfrags(fs, VTOI(thisvp)->i_lfs_fragsize[lbn]);
else {
if (--ndb == 0 && (offset = blkoff(fs, dino.di_size)) != 0) {
if (--ndb == 0 && (offset = lfs_blkoff(fs, dino.di_size)) != 0) {
idesc->id_numfrags =
numfrags(fs, fragroundup(fs, offset));
lfs_numfrags(fs, lfs_fragroundup(fs, offset));
} else
idesc->id_numfrags = fs->lfs_frag;
}
@ -217,7 +217,7 @@ ckinode(struct ulfs1_dinode *dp, struct inodesc *idesc)
break;
}
}
sizepb *= NINDIR(fs);
sizepb *= LFS_NINDIR(fs);
remsize -= sizepb;
}
return (KEEPON);
@ -245,17 +245,17 @@ iblock(struct inodesc *idesc, long ilevel, u_int64_t isize)
return (SKIP);
devvp = fs->lfs_devvp;
bread(devvp, fsbtodb(fs, idesc->id_blkno), fs->lfs_bsize,
bread(devvp, LFS_FSBTODB(fs, idesc->id_blkno), fs->lfs_bsize,
NOCRED, 0, &bp);
ilevel--;
for (sizepb = fs->lfs_bsize, i = 0; i < ilevel; i++)
sizepb *= NINDIR(fs);
if (isize > sizepb * NINDIR(fs))
nif = NINDIR(fs);
sizepb *= LFS_NINDIR(fs);
if (isize > sizepb * LFS_NINDIR(fs))
nif = LFS_NINDIR(fs);
else
nif = howmany(isize, sizepb);
if (idesc->id_func == pass1check && nif < NINDIR(fs)) {
aplim = ((ulfs_daddr_t *) bp->b_data) + NINDIR(fs);
if (idesc->id_func == pass1check && nif < LFS_NINDIR(fs)) {
aplim = ((ulfs_daddr_t *) bp->b_data) + LFS_NINDIR(fs);
for (ap = ((ulfs_daddr_t *) bp->b_data) + nif; ap < aplim; ap++) {
if (*ap == 0)
continue;
@ -273,7 +273,7 @@ iblock(struct inodesc *idesc, long ilevel, u_int64_t isize)
idesc->id_blkno = *ap;
if (ilevel == 0) {
/*
* dirscan needs lblkno.
* dirscan needs lfs_lblkno.
*/
idesc->id_lblkno++;
n = (*func) (idesc);
@ -326,13 +326,13 @@ iblock(struct inodesc *idesc, long ilevel, u_int64_t isize)
int
chkrange(daddr_t blk, int cnt)
{
if (blk < sntod(fs, 0)) {
if (blk < lfs_sntod(fs, 0)) {
return (1);
}
if (blk > maxfsblock) {
return (1);
}
if (blk + cnt < sntod(fs, 0)) {
if (blk + cnt < lfs_sntod(fs, 0)) {
return (1);
}
if (blk + cnt > maxfsblock) {
@ -472,7 +472,7 @@ clearinode(ino_t inumber)
*/
if (daddr != LFS_UNUSED_DADDR) {
SEGUSE *sup;
u_int32_t oldsn = dtosn(fs, daddr);
u_int32_t oldsn = lfs_dtosn(fs, daddr);
seg_table[oldsn].su_nbytes -= LFS_DINODE1_SIZE;
LFS_SEGENTRY(sup, fs, oldsn, bp);
@ -614,7 +614,7 @@ allocino(ino_t request, int type)
dp->di_atime = t;
dp->di_mtime = dp->di_ctime = dp->di_atime;
dp->di_size = fs->lfs_fsize;
dp->di_blocks = btofsb(fs, fs->lfs_fsize);
dp->di_blocks = lfs_btofsb(fs, fs->lfs_fsize);
n_files++;
inodirty(VTOI(vp));
typemap[ino] = LFS_IFTODT(type);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs.c,v 1.39 2013/06/08 02:16:03 dholland Exp $ */
/* $NetBSD: lfs.c,v 1.40 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@ -143,7 +143,7 @@ lfs_vop_bwrite(struct ubuf * bp)
fs = bp->b_vp->v_fs;
if (!(bp->b_flags & B_DELWRI)) {
fs->lfs_avail -= btofsb(fs, bp->b_bcount);
fs->lfs_avail -= lfs_btofsb(fs, bp->b_bcount);
}
bp->b_flags |= B_DELWRI | B_LOCKED;
reassignbuf(bp, bp->b_vp);
@ -172,7 +172,7 @@ ulfs_bmaparray(struct lfs * fs, struct uvnode * vp, daddr_t bn, daddr_t * bnp, s
if (bn >= 0 && bn < ULFS_NDADDR) {
if (nump != NULL)
*nump = 0;
*bnp = fsbtodb(fs, ip->i_ffs1_db[bn]);
*bnp = LFS_FSBTODB(fs, ip->i_ffs1_db[bn]);
if (*bnp == 0)
*bnp = -1;
return (0);
@ -207,7 +207,7 @@ ulfs_bmaparray(struct lfs * fs, struct uvnode * vp, daddr_t bn, daddr_t * bnp, s
bp = getblk(vp, metalbn, fs->lfs_bsize);
if (!(bp->b_flags & (B_DONE | B_DELWRI))) {
bp->b_blkno = fsbtodb(fs, daddr);
bp->b_blkno = LFS_FSBTODB(fs, daddr);
bp->b_flags |= B_READ;
VOP_STRATEGY(bp);
}
@ -216,7 +216,7 @@ ulfs_bmaparray(struct lfs * fs, struct uvnode * vp, daddr_t bn, daddr_t * bnp, s
if (bp)
brelse(bp, 0);
daddr = fsbtodb(fs, (ulfs_daddr_t) daddr);
daddr = LFS_FSBTODB(fs, (ulfs_daddr_t) daddr);
*bnp = daddr == 0 ? -1 : daddr;
return (0);
}
@ -315,7 +315,7 @@ lfs_ifind(struct lfs * fs, ino_t ino, struct ubuf * bp)
struct ulfs1_dinode *dip = (struct ulfs1_dinode *) bp->b_data;
struct ulfs1_dinode *ldip, *fin;
fin = dip + INOPB(fs);
fin = dip + LFS_INOPB(fs);
/*
* Read the inode block backwards, since later versions of the
@ -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, fsbtodb(fs, daddr), fs->lfs_ibsize,
bread(fs->lfs_devvp, LFS_FSBTODB(fs, daddr), fs->lfs_ibsize,
NULL, 0, &bp);
bp->b_flags |= B_AGE;
dip = lfs_ifind(fs, ino, bp);
@ -395,7 +395,7 @@ lfs_raw_vget(struct lfs * fs, ino_t ino, int fd, ulfs_daddr_t daddr)
memset(ip->i_lfs_fragsize, 0, ULFS_NDADDR * sizeof(*ip->i_lfs_fragsize));
for (i = 0; i < ULFS_NDADDR; i++)
if (ip->i_ffs1_db[i] != 0)
ip->i_lfs_fragsize[i] = blksize(fs, ip, i);
ip->i_lfs_fragsize[i] = lfs_blksize(fs, ip, i);
++nvnodes;
hash = ((int)(intptr_t)fs + ino) & (VNODE_HASH_MAX - 1);
@ -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 || dtosn(fs, daddr) >= fs->lfs_nseg)
if (daddr <= 0 || lfs_dtosn(fs, daddr) >= fs->lfs_nseg)
return NULL;
return lfs_raw_vget(fs, ino, fs->lfs_ivnode->v_fd, daddr);
}
@ -490,7 +490,7 @@ lfs_init(int devfd, daddr_t sblkno, daddr_t idaddr, int dummy_read, int debug)
dev_bsize = fs->lfs_fsize >> fs->lfs_fsbtodb;
if (tryalt) {
error = bread(devvp, fsbtodb(fs, fs->lfs_sboffs[1]),
error = bread(devvp, LFS_FSBTODB(fs, fs->lfs_sboffs[1]),
LFS_SBPAD, NOCRED, 0, &bp);
altfs = ecalloc(1, sizeof(*altfs));
altfs->lfs_dlfs = *((struct dlfs *) bp->b_data);
@ -586,19 +586,19 @@ 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 (sntod(osb, dtosn(osb, daddr)) == daddr) {
if (lfs_sntod(osb, lfs_dtosn(osb, daddr)) == daddr) {
if (daddr == osb->lfs_start)
daddr += btofsb(osb, LFS_LABELPAD);
daddr += lfs_btofsb(osb, LFS_LABELPAD);
for (i = 0; i < LFS_MAXNUMSB; i++) {
if (osb->lfs_sboffs[i] < daddr)
break;
if (osb->lfs_sboffs[i] == daddr)
daddr += btofsb(osb, LFS_SBPAD);
daddr += lfs_btofsb(osb, LFS_SBPAD);
}
}
/* Read in summary block */
bread(devvp, fsbtodb(osb, daddr), osb->lfs_sumsize,
bread(devvp, LFS_FSBTODB(osb, daddr), osb->lfs_sumsize,
NULL, 0, &bp);
sp = (SEGSUM *)bp->b_data;
@ -647,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 += btofsb(osb, osb->lfs_sumsize + bc);
if (dtosn(osb, odaddr) != dtosn(osb, daddr) ||
dtosn(osb, daddr) != dtosn(osb, daddr +
btofsb(osb, osb->lfs_sumsize + osb->lfs_bsize) - 1)) {
daddr += lfs_btofsb(osb, osb->lfs_sumsize + bc);
if (lfs_dtosn(osb, odaddr) != lfs_dtosn(osb, daddr) ||
lfs_dtosn(osb, daddr) != lfs_dtosn(osb, daddr +
lfs_btofsb(osb, osb->lfs_sumsize + osb->lfs_bsize) - 1)) {
daddr = sp->ss_next;
}
@ -752,13 +752,13 @@ check_summary(struct lfs *fs, SEGSUM *sp, ulfs_daddr_t pseg_addr, int debug,
u_int32_t *datap;
u_int32_t ccksum;
sn = dtosn(fs, pseg_addr);
seg_addr = sntod(fs, sn);
sn = lfs_dtosn(fs, pseg_addr);
seg_addr = lfs_sntod(fs, sn);
/* We've already checked the sumsum, just do the data bounds and sum */
/* Count the blocks. */
nblocks = howmany(sp->ss_ninos, INOPB(fs));
nblocks = howmany(sp->ss_ninos, LFS_INOPB(fs));
bc = nblocks << (fs->lfs_version > 1 ? fs->lfs_ffshift : fs->lfs_bshift);
assert(bc >= 0);
@ -780,27 +780,27 @@ check_summary(struct lfs *fs, SEGSUM *sp, ulfs_daddr_t pseg_addr, int debug,
dp--;
idp = dp;
daddr = pseg_addr + btofsb(fs, fs->lfs_sumsize);
daddr = pseg_addr + lfs_btofsb(fs, fs->lfs_sumsize);
fp = (FINFO *) (sp + 1);
for (i = 0, j = 0;
i < sp->ss_nfinfo || j < howmany(sp->ss_ninos, INOPB(fs)); i++) {
i < sp->ss_nfinfo || j < howmany(sp->ss_ninos, LFS_INOPB(fs)); i++) {
if (i >= sp->ss_nfinfo && *idp != daddr) {
pwarn("Not enough inode blocks in pseg at 0x%" PRIx32
": found %d, wanted %d\n",
pseg_addr, j, howmany(sp->ss_ninos, INOPB(fs)));
pseg_addr, j, howmany(sp->ss_ninos, LFS_INOPB(fs)));
if (debug)
pwarn("*idp=%x, daddr=%" PRIx32 "\n", *idp,
daddr);
break;
}
while (j < howmany(sp->ss_ninos, INOPB(fs)) && *idp == daddr) {
bread(devvp, fsbtodb(fs, daddr), fs->lfs_ibsize,
while (j < howmany(sp->ss_ninos, LFS_INOPB(fs)) && *idp == daddr) {
bread(devvp, LFS_FSBTODB(fs, daddr), fs->lfs_ibsize,
NOCRED, 0, &bp);
datap[datac++] = ((u_int32_t *) (bp->b_data))[0];
brelse(bp, 0);
++j;
daddr += btofsb(fs, fs->lfs_ibsize);
daddr += lfs_btofsb(fs, fs->lfs_ibsize);
--idp;
}
if (i < sp->ss_nfinfo) {
@ -810,11 +810,11 @@ check_summary(struct lfs *fs, SEGSUM *sp, ulfs_daddr_t pseg_addr, int debug,
len = (k == fp->fi_nblocks - 1 ?
fp->fi_lastlength
: fs->lfs_bsize);
bread(devvp, fsbtodb(fs, daddr), len,
bread(devvp, LFS_FSBTODB(fs, daddr), len,
NOCRED, 0, &bp);
datap[datac++] = ((u_int32_t *) (bp->b_data))[0];
brelse(bp, 0);
daddr += btofsb(fs, len);
daddr += lfs_btofsb(fs, len);
}
fp = (FINFO *) (fp->fi_blocks + fp->fi_nblocks);
}
@ -918,7 +918,7 @@ extend_ifile(struct lfs *fs)
vp = fs->lfs_ivnode;
ip = VTOI(vp);
blkno = lblkno(fs, ip->i_ffs1_size);
blkno = lfs_lblkno(fs, ip->i_ffs1_size);
lfs_balloc(vp, ip->i_ffs1_size, fs->lfs_bsize, &bp);
ip->i_ffs1_size += fs->lfs_bsize;
@ -929,7 +929,7 @@ extend_ifile(struct lfs *fs)
LFS_GET_HEADFREE(fs, cip, cbp, &oldlast);
LFS_PUT_HEADFREE(fs, cip, cbp, i);
max = i + fs->lfs_ifpb;
fs->lfs_bfree -= btofsb(fs, fs->lfs_bsize);
fs->lfs_bfree -= lfs_btofsb(fs, fs->lfs_bsize);
if (fs->lfs_version == 1) {
for (ifp_v1 = (IFILE_V1 *)bp->b_data; i < max; ++ifp_v1) {
@ -987,8 +987,8 @@ lfs_balloc(struct uvnode *vp, off_t startoffset, int iosize, struct ubuf **bpp)
ip = VTOI(vp);
fs = ip->i_lfs;
offset = blkoff(fs, startoffset);
lbn = lblkno(fs, startoffset);
offset = lfs_blkoff(fs, startoffset);
lbn = lfs_lblkno(fs, startoffset);
/*
* Three cases: it's a block beyond the end of file, it's a block in
@ -1010,9 +1010,9 @@ lfs_balloc(struct uvnode *vp, off_t startoffset, int iosize, struct ubuf **bpp)
*bpp = NULL;
/* Check for block beyond end of file and fragment extension needed. */
lastblock = lblkno(fs, ip->i_ffs1_size);
lastblock = lfs_lblkno(fs, ip->i_ffs1_size);
if (lastblock < ULFS_NDADDR && lastblock < lbn) {
osize = blksize(fs, ip, lastblock);
osize = lfs_blksize(fs, ip, lastblock);
if (osize < fs->lfs_bsize && osize > 0) {
if ((error = lfs_fragextend(vp, osize, fs->lfs_bsize,
lastblock,
@ -1033,12 +1033,12 @@ lfs_balloc(struct uvnode *vp, off_t startoffset, int iosize, struct ubuf **bpp)
* size or it already exists and contains some fragments and
* may need to extend it.
*/
if (lbn < ULFS_NDADDR && lblkno(fs, ip->i_ffs1_size) <= lbn) {
osize = blksize(fs, ip, lbn);
nsize = fragroundup(fs, offset + iosize);
if (lblktosize(fs, lbn) >= ip->i_ffs1_size) {
if (lbn < ULFS_NDADDR && lfs_lblkno(fs, ip->i_ffs1_size) <= lbn) {
osize = lfs_blksize(fs, ip, lbn);
nsize = lfs_fragroundup(fs, offset + iosize);
if (lfs_lblktosize(fs, lbn) >= ip->i_ffs1_size) {
/* Brand new block or fragment */
frags = numfrags(fs, nsize);
frags = lfs_numfrags(fs, nsize);
if (bpp) {
*bpp = bp = getblk(vp, lbn, nsize);
bp->b_blkno = UNWRITTEN;
@ -1075,7 +1075,7 @@ lfs_balloc(struct uvnode *vp, off_t startoffset, int iosize, struct ubuf **bpp)
* Do byte accounting all at once, so we can gracefully fail *before*
* we start assigning blocks.
*/
frags = fsbtodb(fs, 1); /* frags = VFSTOULFS(vp->v_mount)->um_seqinc; */
frags = LFS_FSBTODB(fs, 1); /* frags = VFSTOULFS(vp->v_mount)->um_seqinc; */
bcount = 0;
if (daddr == UNASSIGNED) {
bcount = frags;
@ -1105,7 +1105,7 @@ lfs_balloc(struct uvnode *vp, off_t startoffset, int iosize, struct ubuf **bpp)
memset(ibp->b_data, 0, ibp->b_bufsize);
ibp->b_blkno = UNWRITTEN;
} else if (!(ibp->b_flags & (B_DELWRI | B_DONE))) {
ibp->b_blkno = fsbtodb(fs, idaddr);
ibp->b_blkno = LFS_FSBTODB(fs, idaddr);
ibp->b_flags |= B_READ;
VOP_STRATEGY(ibp);
}
@ -1131,7 +1131,7 @@ lfs_balloc(struct uvnode *vp, off_t startoffset, int iosize, struct ubuf **bpp)
* Get the existing block from the cache, if requested.
*/
if (bpp)
*bpp = bp = getblk(vp, lbn, blksize(fs, ip, lbn));
*bpp = bp = getblk(vp, lbn, lfs_blksize(fs, ip, lbn));
/*
* The block we are writing may be a brand new block
@ -1199,7 +1199,7 @@ lfs_fragextend(struct uvnode *vp, int osize, int nsize, daddr_t lbn,
ip = VTOI(vp);
fs = ip->i_lfs;
frags = (long)numfrags(fs, nsize - osize);
frags = (long)lfs_numfrags(fs, nsize - osize);
error = 0;
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: pass1.c,v 1.36 2013/06/08 02:16:03 dholland Exp $ */
/* $NetBSD: pass1.c,v 1.37 2013/06/18 18:18:58 christos Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -233,7 +233,7 @@ checkinode(ino_t inumber, struct inodesc * idesc)
if (ndb > ULFS_NDADDR) {
j = ndb - ULFS_NDADDR;
for (ndb = 1; j > 1; j--)
ndb *= NINDIR(fs);
ndb *= LFS_NINDIR(fs);
ndb += ULFS_NDADDR;
}
}
@ -246,7 +246,7 @@ checkinode(ino_t inumber, struct inodesc * idesc)
goto unknown;
}
for (j = 0, ndb -= ULFS_NDADDR; ndb > 0; j++)
ndb /= NINDIR(fs);
ndb /= LFS_NINDIR(fs);
for (; j < ULFS_NIADDR; j++)
if (dp->di_ib[j] != 0) {
if (debug)
@ -339,7 +339,7 @@ pass1check(struct inodesc *idesc)
return (STOP);
}
} else if (!testbmap(blkno)) {
seg_table[dtosn(fs, blkno)].su_nbytes += idesc->id_numfrags * fs->lfs_fsize;
seg_table[lfs_dtosn(fs, blkno)].su_nbytes += idesc->id_numfrags * fs->lfs_fsize;
}
for (ndblks = idesc->id_numfrags; ndblks > 0; blkno++, ndblks--) {
if (anyout && chkrange(blkno, 1)) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: pass4.c,v 1.21 2013/06/08 02:16:03 dholland Exp $ */
/* $NetBSD: pass4.c,v 1.22 2013/06/18 18:18:58 christos Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -153,7 +153,7 @@ pass4check(struct inodesc * idesc)
struct ubuf *bp;
int sn;
sn = dtosn(fs, blkno);
sn = lfs_dtosn(fs, blkno);
for (ndblks = idesc->id_numfrags; ndblks > 0; blkno++, ndblks--) {
if (chkrange(blkno, 1)) {
res = SKIP;
@ -170,9 +170,9 @@ pass4check(struct inodesc * idesc)
if (dlp == 0) {
clrbmap(blkno);
LFS_SEGENTRY(sup, fs, sn, bp);
sup->su_nbytes -= fsbtob(fs, 1);
sup->su_nbytes -= lfs_fsbtob(fs, 1);
VOP_BWRITE(bp);
seg_table[sn].su_nbytes -= fsbtob(fs, 1);
seg_table[sn].su_nbytes -= lfs_fsbtob(fs, 1);
++fs->lfs_bfree;
n_blks--;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: pass5.c,v 1.27 2013/06/08 02:16:03 dholland Exp $ */
/* $NetBSD: pass5.c,v 1.28 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 2000, 2003 The NetBSD Foundation, Inc.
@ -105,23 +105,23 @@ pass5(void)
}
}
if (su->su_flags & SEGUSE_DIRTY) {
bb += btofsb(fs, su->su_nbytes +
bb += lfs_btofsb(fs, su->su_nbytes +
su->su_nsums * fs->lfs_sumsize);
ubb += btofsb(fs, su->su_nbytes +
ubb += lfs_btofsb(fs, su->su_nbytes +
su->su_nsums * fs->lfs_sumsize +
su->su_ninos * fs->lfs_ibsize);
dmeta += btofsb(fs,
dmeta += lfs_btofsb(fs,
fs->lfs_sumsize * su->su_nsums);
dmeta += btofsb(fs,
dmeta += lfs_btofsb(fs,
fs->lfs_ibsize * su->su_ninos);
} else {
nclean++;
avail += segtod(fs, 1);
avail += lfs_segtod(fs, 1);
if (su->su_flags & SEGUSE_SUPERBLOCK)
avail -= btofsb(fs, LFS_SBPAD);
avail -= lfs_btofsb(fs, LFS_SBPAD);
if (i == 0 && fs->lfs_version > 1 &&
fs->lfs_start < btofsb(fs, LFS_LABELPAD))
avail -= btofsb(fs, LFS_LABELPAD) -
fs->lfs_start < lfs_btofsb(fs, LFS_LABELPAD))
avail -= lfs_btofsb(fs, LFS_LABELPAD) -
fs->lfs_start;
}
if (diddirty)
@ -131,13 +131,13 @@ pass5(void)
}
/* Also may be available bytes in current seg */
i = dtosn(fs, fs->lfs_offset);
avail += sntod(fs, i + 1) - fs->lfs_offset;
i = lfs_dtosn(fs, fs->lfs_offset);
avail += lfs_sntod(fs, i + 1) - fs->lfs_offset;
/* But do not count minfreesegs */
avail -= segtod(fs, (fs->lfs_minfreeseg -
avail -= lfs_segtod(fs, (fs->lfs_minfreeseg -
(fs->lfs_minfreeseg / 2)));
/* Note we may have bytes to write yet */
avail -= btofsb(fs, locked_queue_bytes);
avail -= lfs_btofsb(fs, locked_queue_bytes);
if (idaddr)
pwarn("NOTE: when using -i, expect discrepancies in dmeta,"
@ -169,8 +169,8 @@ pass5(void)
labelskew = 0;
if (fs->lfs_version > 1 &&
fs->lfs_start < btofsb(fs, LFS_LABELPAD))
labelskew = btofsb(fs, LFS_LABELPAD);
fs->lfs_start < lfs_btofsb(fs, LFS_LABELPAD))
labelskew = lfs_btofsb(fs, LFS_LABELPAD);
if (fs->lfs_bfree > fs->lfs_dsize - bb - labelskew ||
fs->lfs_bfree < fs->lfs_dsize - ubb - labelskew) {
pwarn("BFREE GIVEN AS %d, SHOULD BE BETWEEN %ld AND %ld\n",

View File

@ -1,4 +1,4 @@
/* $NetBSD: pass6.c,v 1.30 2013/06/08 23:12:13 dholland Exp $ */
/* $NetBSD: pass6.c,v 1.31 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -97,9 +97,9 @@ rfw_update_single(struct uvnode *vp, daddr_t lbn, ulfs_daddr_t ndaddr, int size)
errx(1, "lfs_updatemeta: ulfs_bmaparray returned %d"
" looking up lbn %" PRId64 "\n", error, lbn);
if (daddr > 0)
daddr = dbtofsb(fs, daddr);
daddr = LFS_DBTOFSB(fs, daddr);
frags = numfrags(fs, size);
frags = lfs_numfrags(fs, size);
switch (num) {
case 0:
ooff = ip->i_ffs1_db[lbn];
@ -107,7 +107,7 @@ rfw_update_single(struct uvnode *vp, daddr_t lbn, ulfs_daddr_t ndaddr, int size)
ip->i_ffs1_blocks += frags;
else {
/* possible fragment truncation or extension */
ofrags = numfrags(fs, ip->i_lfs_fragsize[lbn]);
ofrags = lfs_numfrags(fs, ip->i_lfs_fragsize[lbn]);
ip->i_ffs1_blocks += (frags - ofrags);
}
ip->i_ffs1_db[lbn] = ndaddr;
@ -136,7 +136,7 @@ rfw_update_single(struct uvnode *vp, daddr_t lbn, ulfs_daddr_t ndaddr, int size)
* and location.
*/
if (daddr > 0) {
oldsn = dtosn(fs, daddr);
oldsn = lfs_dtosn(fs, daddr);
if (lbn >= 0 && lbn < ULFS_NDADDR)
osize = ip->i_lfs_fragsize[lbn];
else
@ -147,7 +147,7 @@ rfw_update_single(struct uvnode *vp, daddr_t lbn, ulfs_daddr_t ndaddr, int size)
if (!(bp->b_flags & B_GATHERED))
fs->lfs_flags |= LFS_IFDIRTY;
LFS_WRITESEGENTRY(sup, fs, oldsn, bp);
for (i = 0; i < btofsb(fs, osize); i++)
for (i = 0; i < lfs_btofsb(fs, osize); i++)
clrbmap(daddr + i);
}
@ -170,14 +170,14 @@ rfw_update_single(struct uvnode *vp, daddr_t lbn, ulfs_daddr_t ndaddr, int size)
++nnewblocks;
/* Add block to its new segment */
sn = dtosn(fs, ndaddr);
sn = lfs_dtosn(fs, ndaddr);
LFS_SEGENTRY(sup, fs, sn, bp);
seg_table[sn].su_nbytes += size;
sup->su_nbytes += size;
if (!(bp->b_flags & B_GATHERED))
fs->lfs_flags |= LFS_IFDIRTY;
LFS_WRITESEGENTRY(sup, fs, sn, bp);
for (i = 0; i < btofsb(fs, size); i++)
for (i = 0; i < lfs_btofsb(fs, size); i++)
#ifndef VERBOSE_BLOCKMAP
setbmap(daddr + i);
#else
@ -186,7 +186,7 @@ rfw_update_single(struct uvnode *vp, daddr_t lbn, ulfs_daddr_t ndaddr, int size)
/* Check bfree accounting as well */
if (daddr <= 0) {
fs->lfs_bfree -= btofsb(fs, size);
fs->lfs_bfree -= lfs_btofsb(fs, size);
} else if (size != osize) {
fs->lfs_bfree -= (frags - ofrags);
}
@ -233,10 +233,10 @@ remove_ino(struct uvnode *vp, ino_t ino)
if (vp == NULL)
vp = lfs_raw_vget(fs, ino, fs->lfs_ivnode->v_fd, daddr);
LFS_SEGENTRY(sup, fs, dtosn(fs, daddr), sbp);
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, daddr), sbp);
sup->su_nbytes -= LFS_DINODE1_SIZE;
VOP_BWRITE(sbp);
seg_table[dtosn(fs, daddr)].su_nbytes -= LFS_DINODE1_SIZE;
seg_table[lfs_dtosn(fs, daddr)].su_nbytes -= LFS_DINODE1_SIZE;
} else
brelse(bp, 0);
@ -273,7 +273,7 @@ pass6harvest(ulfs_daddr_t daddr, FINFO *fip)
(long long)fip->fi_blocks[i],
(long)daddr);
rfw_update_single(vp, fip->fi_blocks[i], daddr, size);
daddr += btofsb(fs, size);
daddr += lfs_btofsb(fs, size);
}
}
}
@ -293,14 +293,14 @@ pass6check(struct inodesc * idesc)
/* Check that the blocks do not lie within clean segments. */
anyout = anynew = 0;
for (i = 0; i < idesc->id_numfrags; i++) {
sn = dtosn(fs, idesc->id_blkno + i);
sn = lfs_dtosn(fs, idesc->id_blkno + i);
if (sn < 0 || sn >= fs->lfs_nseg ||
(seg_table[sn].su_flags & SEGUSE_DIRTY) == 0) {
anyout = 1;
break;
}
if (seg_table[sn].su_flags & SEGUSE_ACTIVE) {
if (sn != dtosn(fs, fs->lfs_offset) ||
if (sn != lfs_dtosn(fs, fs->lfs_offset) ||
idesc->id_blkno > fs->lfs_offset) {
++anynew;
}
@ -308,7 +308,7 @@ pass6check(struct inodesc * idesc)
if (!anynew) {
/* Clear so pass1check won't be surprised */
clrbmap(idesc->id_blkno + i);
seg_table[sn].su_nbytes -= fsbtob(fs, 1);
seg_table[sn].su_nbytes -= lfs_fsbtob(fs, 1);
}
}
if (anyout) {
@ -338,7 +338,7 @@ account_indir(struct uvnode *vp, struct ulfs1_dinode *dp, daddr_t ilbn, daddr_t
lbn = -ilbn;
else
lbn = ilbn + 1;
bread(fs->lfs_devvp, fsbtodb(fs, daddr), fs->lfs_bsize, NULL, 0, &bp);
bread(fs->lfs_devvp, LFS_FSBTODB(fs, daddr), fs->lfs_bsize, NULL, 0, &bp);
buf = emalloc(fs->lfs_bsize);
memcpy(buf, bp->b_data, fs->lfs_bsize);
brelse(bp, 0);
@ -355,16 +355,16 @@ account_indir(struct uvnode *vp, struct ulfs1_dinode *dp, daddr_t ilbn, daddr_t
dap < (int32_t *)((char *)buf + fs->lfs_bsize);
++dap, ++odap) {
if (*dap > 0 && *dap != *odap) {
rfw_update_single(vp, lbn, *dap, dblksize(fs, dp, lbn));
rfw_update_single(vp, lbn, *dap, lfs_dblksize(fs, dp, lbn));
if (lvl > 0)
account_indir(vp, dp, lbn, *dap, lvl - 1);
}
if (lvl == 0)
++lbn;
else if (lvl == 1)
lbn -= NINDIR(fs);
lbn -= LFS_NINDIR(fs);
else if (lvl == 2)
lbn -= NINDIR(fs) * NINDIR(fs);
lbn -= LFS_NINDIR(fs) * LFS_NINDIR(fs);
}
free(obuf);
@ -390,7 +390,7 @@ account_block_changes(struct ulfs1_dinode *dp)
odaddr = (ip ? ip->i_ffs1_db[i] : 0x0);
if (dp->di_db[i] > 0 && dp->di_db[i] != odaddr)
rfw_update_single(vp, i, dp->di_db[i],
dblksize(fs, dp, i));
lfs_dblksize(fs, dp, i));
}
/* Check indirect block holdings between existing and new */
@ -403,9 +403,9 @@ account_block_changes(struct ulfs1_dinode *dp)
account_indir(vp, dp, lbn, dp->di_ib[i], i);
}
if (off == 0)
off = NINDIR(fs);
off = LFS_NINDIR(fs);
else
off *= NINDIR(fs);
off *= LFS_NINDIR(fs);
}
}
@ -449,13 +449,13 @@ readdress_inode(struct ulfs1_dinode *dp, ulfs_daddr_t daddr)
memcpy(VTOI(vp)->i_din.ffs1_din, dp, sizeof(*dp));
/* Finally account the inode itself */
sn = dtosn(fs, odaddr);
sn = lfs_dtosn(fs, odaddr);
LFS_SEGENTRY(sup, fs, sn, bp);
sup->su_nbytes -= LFS_DINODE1_SIZE;
VOP_BWRITE(bp);
seg_table[sn].su_nbytes -= LFS_DINODE1_SIZE;
sn = dtosn(fs, daddr);
sn = lfs_dtosn(fs, daddr);
LFS_SEGENTRY(sup, fs, sn, bp);
sup->su_nbytes += LFS_DINODE1_SIZE;
VOP_BWRITE(bp);
@ -517,10 +517,10 @@ alloc_inode(ino_t thisino, ulfs_daddr_t daddr)
}
/* Account for new location */
LFS_SEGENTRY(sup, fs, dtosn(fs, daddr), bp);
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, daddr), bp);
sup->su_nbytes += LFS_DINODE1_SIZE;
VOP_BWRITE(bp);
seg_table[dtosn(fs, daddr)].su_nbytes += LFS_DINODE1_SIZE;
seg_table[lfs_dtosn(fs, daddr)].su_nbytes += LFS_DINODE1_SIZE;
}
/*
@ -592,21 +592,21 @@ pass6(void)
hassuper = 0;
lastserial = 0;
while (daddr != lastgood) {
seg_table[dtosn(fs, daddr)].su_flags |= SEGUSE_DIRTY | SEGUSE_ACTIVE;
LFS_SEGENTRY(sup, fs, dtosn(fs, daddr), sbp);
seg_table[lfs_dtosn(fs, daddr)].su_flags |= SEGUSE_DIRTY | SEGUSE_ACTIVE;
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, daddr), sbp);
sup->su_flags |= SEGUSE_DIRTY;
VOP_BWRITE(sbp);
/* Could be a superblock */
if (sntod(fs, dtosn(fs, daddr)) == daddr) {
if (lfs_sntod(fs, lfs_dtosn(fs, daddr)) == daddr) {
if (daddr == fs->lfs_start) {
++hassuper;
daddr += btofsb(fs, LFS_LABELPAD);
daddr += lfs_btofsb(fs, LFS_LABELPAD);
}
for (i = 0; i < LFS_MAXNUMSB; i++) {
if (daddr == fs->lfs_sboffs[i]) {
++hassuper;
daddr += btofsb(fs, LFS_SBPAD);
daddr += lfs_btofsb(fs, LFS_SBPAD);
}
if (daddr < fs->lfs_sboffs[i])
break;
@ -614,7 +614,7 @@ pass6(void)
}
/* Read in summary block */
bread(devvp, fsbtodb(fs, daddr), fs->lfs_sumsize, NULL, 0, &bp);
bread(devvp, LFS_FSBTODB(fs, daddr), fs->lfs_sumsize, NULL, 0, &bp);
sp = (SEGSUM *)bp->b_data;
if (debug)
pwarn("sum at 0x%x: ninos=%d nfinfo=%d\n",
@ -622,45 +622,45 @@ pass6(void)
(int)sp->ss_nfinfo);
/* We have verified that this is a good summary. */
LFS_SEGENTRY(sup, fs, dtosn(fs, daddr), sbp);
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, daddr), sbp);
++sup->su_nsums;
VOP_BWRITE(sbp);
fs->lfs_bfree -= btofsb(fs, fs->lfs_sumsize);
fs->lfs_dmeta += btofsb(fs, fs->lfs_sumsize);
fs->lfs_bfree -= lfs_btofsb(fs, fs->lfs_sumsize);
fs->lfs_dmeta += lfs_btofsb(fs, fs->lfs_sumsize);
sbdirty();
nextseg = sp->ss_next;
if (sntod(fs, dtosn(fs, daddr)) == daddr +
hassuper * btofsb(fs, LFS_SBPAD) &&
dtosn(fs, daddr) != dtosn(fs, fs->lfs_offset)) {
if (lfs_sntod(fs, lfs_dtosn(fs, daddr)) == daddr +
hassuper * lfs_btofsb(fs, LFS_SBPAD) &&
lfs_dtosn(fs, daddr) != lfs_dtosn(fs, fs->lfs_offset)) {
--fs->lfs_nclean;
sbdirty();
}
/* Find inodes, look at generation number. */
if (sp->ss_ninos) {
LFS_SEGENTRY(sup, fs, dtosn(fs, daddr), sbp);
sup->su_ninos += howmany(sp->ss_ninos, INOPB(fs));
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 += btofsb(fs, howmany(sp->ss_ninos,
INOPB(fs)) *
fs->lfs_dmeta += lfs_btofsb(fs, howmany(sp->ss_ninos,
LFS_INOPB(fs)) *
fs->lfs_ibsize);
}
idaddrp = ((ulfs_daddr_t *)((char *)bp->b_data + fs->lfs_sumsize));
for (i = 0; i < howmany(sp->ss_ninos, INOPB(fs)); i++) {
for (i = 0; i < howmany(sp->ss_ninos, LFS_INOPB(fs)); i++) {
ino_t *inums;
inums = ecalloc(INOPB(fs) + 1, sizeof(*inums));
inums = ecalloc(LFS_INOPB(fs) + 1, sizeof(*inums));
ibdaddr = *--idaddrp;
fs->lfs_bfree -= btofsb(fs, fs->lfs_ibsize);
fs->lfs_bfree -= lfs_btofsb(fs, fs->lfs_ibsize);
sbdirty();
bread(devvp, fsbtodb(fs, ibdaddr), fs->lfs_ibsize,
bread(devvp, LFS_FSBTODB(fs, ibdaddr), fs->lfs_ibsize,
NOCRED, 0, &ibp);
memcpy(ibbuf, ibp->b_data, fs->lfs_ibsize);
brelse(ibp, 0);
j = 0;
for (dp = (struct ulfs1_dinode *)ibbuf;
dp < (struct ulfs1_dinode *)ibbuf + INOPB(fs);
dp < (struct ulfs1_dinode *)ibbuf + LFS_INOPB(fs);
++dp) {
if (dp->di_inumber == 0 ||
dp->di_inumber == fs->lfs_ifile)
@ -781,10 +781,10 @@ pass6(void)
lastserial = sp->ss_serial;
}
odaddr = daddr;
daddr += btofsb(fs, fs->lfs_sumsize + bc);
if (dtosn(fs, odaddr) != dtosn(fs, daddr) ||
dtosn(fs, daddr) != dtosn(fs, daddr +
btofsb(fs, fs->lfs_sumsize + fs->lfs_bsize) - 1)) {
daddr += lfs_btofsb(fs, fs->lfs_sumsize + bc);
if (lfs_dtosn(fs, odaddr) != lfs_dtosn(fs, daddr) ||
lfs_dtosn(fs, daddr) != lfs_dtosn(fs, daddr +
lfs_btofsb(fs, fs->lfs_sumsize + fs->lfs_bsize) - 1)) {
daddr = ((SEGSUM *)bp->b_data)->ss_next;
}
brelse(bp, 0);
@ -820,20 +820,20 @@ pass6(void)
*/
daddr = fs->lfs_offset;
while (daddr != lastgood) {
if (!(seg_table[dtosn(fs, daddr)].su_flags & SEGUSE_DIRTY)) {
seg_table[dtosn(fs, daddr)].su_flags |= SEGUSE_DIRTY;
LFS_SEGENTRY(sup, fs, dtosn(fs, daddr), sbp);
if (!(seg_table[lfs_dtosn(fs, daddr)].su_flags & SEGUSE_DIRTY)) {
seg_table[lfs_dtosn(fs, daddr)].su_flags |= SEGUSE_DIRTY;
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, daddr), sbp);
sup->su_flags |= SEGUSE_DIRTY;
VOP_BWRITE(sbp);
}
/* Could be a superblock */
if (sntod(fs, dtosn(fs, daddr)) == daddr) {
if (lfs_sntod(fs, lfs_dtosn(fs, daddr)) == daddr) {
if (daddr == fs->lfs_start)
daddr += btofsb(fs, LFS_LABELPAD);
daddr += lfs_btofsb(fs, LFS_LABELPAD);
for (i = 0; i < LFS_MAXNUMSB; i++) {
if (daddr == fs->lfs_sboffs[i]) {
daddr += btofsb(fs, LFS_SBPAD);
daddr += lfs_btofsb(fs, LFS_SBPAD);
}
if (daddr < fs->lfs_sboffs[i])
break;
@ -841,7 +841,7 @@ pass6(void)
}
/* Read in summary block */
bread(devvp, fsbtodb(fs, daddr), fs->lfs_sumsize, NULL, 0, &bp);
bread(devvp, LFS_FSBTODB(fs, daddr), fs->lfs_sumsize, NULL, 0, &bp);
sp = (SEGSUM *)bp->b_data;
bc = check_summary(fs, sp, daddr, debug, devvp, pass6harvest);
if (bc == 0) {
@ -851,12 +851,12 @@ pass6(void)
break;
}
odaddr = daddr;
daddr += btofsb(fs, fs->lfs_sumsize + bc);
fs->lfs_avail -= btofsb(fs, fs->lfs_sumsize + bc);
if (dtosn(fs, odaddr) != dtosn(fs, daddr) ||
dtosn(fs, daddr) != dtosn(fs, daddr +
btofsb(fs, fs->lfs_sumsize + fs->lfs_bsize) - 1)) {
fs->lfs_avail -= sntod(fs, dtosn(fs, daddr) + 1) - daddr;
daddr += lfs_btofsb(fs, fs->lfs_sumsize + bc);
fs->lfs_avail -= lfs_btofsb(fs, fs->lfs_sumsize + bc);
if (lfs_dtosn(fs, odaddr) != lfs_dtosn(fs, daddr) ||
lfs_dtosn(fs, daddr) != lfs_dtosn(fs, daddr +
lfs_btofsb(fs, fs->lfs_sumsize + fs->lfs_bsize) - 1)) {
fs->lfs_avail -= lfs_sntod(fs, lfs_dtosn(fs, daddr) + 1) - daddr;
daddr = ((SEGSUM *)bp->b_data)->ss_next;
}
LFS_CLEANERINFO(cip, fs, cbp);
@ -866,12 +866,12 @@ pass6(void)
}
/* Final address could also be a superblock */
if (sntod(fs, dtosn(fs, lastgood)) == lastgood) {
if (lfs_sntod(fs, lfs_dtosn(fs, lastgood)) == lastgood) {
if (lastgood == fs->lfs_start)
lastgood += btofsb(fs, LFS_LABELPAD);
lastgood += lfs_btofsb(fs, LFS_LABELPAD);
for (i = 0; i < LFS_MAXNUMSB; i++) {
if (lastgood == fs->lfs_sboffs[i])
lastgood += btofsb(fs, LFS_SBPAD);
lastgood += lfs_btofsb(fs, LFS_SBPAD);
if (lastgood < fs->lfs_sboffs[i])
break;
}
@ -879,8 +879,8 @@ pass6(void)
/* Update offset to point at correct location */
fs->lfs_offset = lastgood;
fs->lfs_curseg = sntod(fs, dtosn(fs, lastgood));
for (sn = curseg = dtosn(fs, fs->lfs_curseg);;) {
fs->lfs_curseg = lfs_sntod(fs, lfs_dtosn(fs, lastgood));
for (sn = curseg = lfs_dtosn(fs, fs->lfs_curseg);;) {
sn = (sn + 1) % fs->lfs_nseg;
if (sn == curseg)
errx(1, "no clean segments");
@ -892,7 +892,7 @@ pass6(void)
}
brelse(bp, 0);
}
fs->lfs_nextseg = sntod(fs, sn);
fs->lfs_nextseg = lfs_sntod(fs, sn);
if (preen) {
if (ndelfiles)

View File

@ -1,4 +1,4 @@
/* $NetBSD: segwrite.c,v 1.25 2013/06/08 02:16:03 dholland Exp $ */
/* $NetBSD: segwrite.c,v 1.26 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@ -121,7 +121,7 @@ lfs_match_indir(struct lfs * fs, struct ubuf * bp)
daddr_t lbn;
lbn = bp->b_lblkno;
return (lbn < 0 && (-lbn - ULFS_NDADDR) % NINDIR(fs) == 0);
return (lbn < 0 && (-lbn - ULFS_NDADDR) % LFS_NINDIR(fs) == 0);
}
int
@ -130,7 +130,7 @@ lfs_match_dindir(struct lfs * fs, struct ubuf * bp)
daddr_t lbn;
lbn = bp->b_lblkno;
return (lbn < 0 && (-lbn - ULFS_NDADDR) % NINDIR(fs) == 1);
return (lbn < 0 && (-lbn - ULFS_NDADDR) % LFS_NINDIR(fs) == 1);
}
int
@ -139,7 +139,7 @@ lfs_match_tindir(struct lfs * fs, struct ubuf * bp)
daddr_t lbn;
lbn = bp->b_lblkno;
return (lbn < 0 && (-lbn - ULFS_NDADDR) % NINDIR(fs) == 2);
return (lbn < 0 && (-lbn - ULFS_NDADDR) % LFS_NINDIR(fs) == 2);
}
/*
@ -175,15 +175,15 @@ lfs_segwrite(struct lfs * fs, int flags)
lfs_segunlock(fs);
#if 0
printf("wrote %" PRId64 " bytes (%" PRId32 " fsb)\n",
written_bytes, (ulfs_daddr_t)btofsb(fs, written_bytes));
written_bytes, (ulfs_daddr_t)lfs_btofsb(fs, written_bytes));
printf("wrote %" PRId64 " bytes data (%" PRId32 " fsb)\n",
written_data, (ulfs_daddr_t)btofsb(fs, written_data));
written_data, (ulfs_daddr_t)lfs_btofsb(fs, written_data));
printf("wrote %" PRId64 " bytes indir (%" PRId32 " fsb)\n",
written_indir, (ulfs_daddr_t)btofsb(fs, written_indir));
written_indir, (ulfs_daddr_t)lfs_btofsb(fs, written_indir));
printf("wrote %" PRId64 " bytes dev (%" PRId32 " fsb)\n",
written_dev, (ulfs_daddr_t)btofsb(fs, written_dev));
written_dev, (ulfs_daddr_t)lfs_btofsb(fs, written_dev));
printf("wrote %d inodes (%" PRId32 " fsb)\n",
written_inodes, btofsb(fs, written_inodes * fs->lfs_ibsize));
written_inodes, lfs_btofsb(fs, written_inodes * fs->lfs_ibsize));
#endif
return 0;
}
@ -258,24 +258,24 @@ lfs_writeinode(struct lfs * fs, struct segment * sp, struct inode * ip)
/* Get next inode block. */
daddr = fs->lfs_offset;
fs->lfs_offset += btofsb(fs, fs->lfs_ibsize);
fs->lfs_offset += lfs_btofsb(fs, fs->lfs_ibsize);
sp->ibp = *sp->cbpp++ =
getblk(fs->lfs_devvp, fsbtodb(fs, daddr),
getblk(fs->lfs_devvp, LFS_FSBTODB(fs, daddr),
fs->lfs_ibsize);
sp->ibp->b_flags |= B_GATHERED;
gotblk++;
/* Zero out inode numbers */
for (i = 0; i < INOPB(fs); ++i)
for (i = 0; i < LFS_INOPB(fs); ++i)
((struct ulfs1_dinode *) sp->ibp->b_data)[i].di_inumber = 0;
++sp->start_bpp;
fs->lfs_avail -= btofsb(fs, fs->lfs_ibsize);
fs->lfs_avail -= lfs_btofsb(fs, fs->lfs_ibsize);
/* Set remaining space counters. */
sp->seg_bytes_left -= fs->lfs_ibsize;
sp->sum_bytes_left -= sizeof(ulfs_daddr_t);
ndx = fs->lfs_sumsize / sizeof(ulfs_daddr_t) -
sp->ninodes / INOPB(fs) - 1;
sp->ninodes / LFS_INOPB(fs) - 1;
((ulfs_daddr_t *) (sp->segsum))[ndx] = daddr;
}
/* Update the inode times and copy the inode onto the inode page. */
@ -299,7 +299,7 @@ lfs_writeinode(struct lfs * fs, struct segment * sp, struct inode * ip)
return 0;
}
bp = sp->ibp;
cdp = ((struct ulfs1_dinode *) bp->b_data) + (sp->ninodes % INOPB(fs));
cdp = ((struct ulfs1_dinode *) bp->b_data) + (sp->ninodes % LFS_INOPB(fs));
*cdp = *ip->i_din.ffs1_din;
/* If all blocks are goig to disk, update the "size on disk" */
@ -307,7 +307,7 @@ lfs_writeinode(struct lfs * fs, struct segment * sp, struct inode * ip)
if (ip->i_number == LFS_IFILE_INUM) /* We know sp->idp == NULL */
sp->idp = ((struct ulfs1_dinode *) bp->b_data) +
(sp->ninodes % INOPB(fs));
(sp->ninodes % LFS_INOPB(fs));
if (gotblk) {
LFS_LOCK_BUF(bp);
assert(!(bp->b_flags & B_INVAL));
@ -317,7 +317,7 @@ lfs_writeinode(struct lfs * fs, struct segment * sp, struct inode * ip)
++((SEGSUM *) (sp->segsum))->ss_ninos;
/* If this page is full, set flag to allocate a new page. */
if (++sp->ninodes % INOPB(fs) == 0)
if (++sp->ninodes % LFS_INOPB(fs) == 0)
sp->ibp = NULL;
/*
@ -327,12 +327,12 @@ lfs_writeinode(struct lfs * fs, struct segment * sp, struct inode * ip)
ino = ip->i_number;
if (ino == LFS_IFILE_INUM) {
daddr = fs->lfs_idaddr;
fs->lfs_idaddr = dbtofsb(fs, bp->b_blkno);
fs->lfs_idaddr = LFS_DBTOFSB(fs, bp->b_blkno);
sbdirty();
} else {
LFS_IENTRY(ifp, fs, ino, ibp);
daddr = ifp->if_daddr;
ifp->if_daddr = dbtofsb(fs, bp->b_blkno) + fsb;
ifp->if_daddr = LFS_DBTOFSB(fs, bp->b_blkno) + fsb;
error = LFS_BWRITE_LOG(ibp); /* Ifile */
}
@ -342,7 +342,7 @@ lfs_writeinode(struct lfs * fs, struct segment * sp, struct inode * ip)
* is actually written.
*/
if (daddr != LFS_UNUSED_DADDR) {
u_int32_t oldsn = dtosn(fs, daddr);
u_int32_t oldsn = lfs_dtosn(fs, daddr);
LFS_SEGENTRY(sup, fs, oldsn, bp);
sup->su_nbytes -= LFS_DINODE1_SIZE;
redo_ifile =
@ -449,9 +449,9 @@ lfs_update_single(struct lfs * fs, struct segment * sp, daddr_t lbn,
if (error)
errx(1, "lfs_updatemeta: ulfs_bmaparray returned %d looking up lbn %" PRId64 "\n", error, lbn);
if (daddr > 0)
daddr = dbtofsb(fs, daddr);
daddr = LFS_DBTOFSB(fs, daddr);
frags = numfrags(fs, size);
frags = lfs_numfrags(fs, size);
switch (num) {
case 0:
ooff = ip->i_ffs1_db[lbn];
@ -459,7 +459,7 @@ lfs_update_single(struct lfs * fs, struct segment * sp, daddr_t lbn,
ip->i_ffs1_blocks += frags;
else {
/* possible fragment truncation or extension */
ofrags = btofsb(fs, ip->i_lfs_fragsize[lbn]);
ofrags = lfs_btofsb(fs, ip->i_lfs_fragsize[lbn]);
ip->i_ffs1_blocks += (frags - ofrags);
}
ip->i_ffs1_db[lbn] = ndaddr;
@ -488,7 +488,7 @@ lfs_update_single(struct lfs * fs, struct segment * sp, daddr_t lbn,
* and location.
*/
if (daddr > 0) {
u_int32_t oldsn = dtosn(fs, daddr);
u_int32_t oldsn = lfs_dtosn(fs, daddr);
if (lbn >= 0 && lbn < ULFS_NDADDR)
osize = ip->i_lfs_fragsize[lbn];
else
@ -566,7 +566,7 @@ lfs_updatemeta(struct segment * sp)
sbp = *sp->start_bpp;
lbn = *sp->start_lbp;
sbp->b_blkno = fsbtodb(fs, fs->lfs_offset);
sbp->b_blkno = LFS_FSBTODB(fs, fs->lfs_offset);
/*
* If we write a frag in the wrong place, the cleaner won't
@ -585,7 +585,7 @@ lfs_updatemeta(struct segment * sp)
for (bytesleft = sbp->b_bcount; bytesleft > 0;
bytesleft -= fs->lfs_bsize) {
size = MIN(bytesleft, fs->lfs_bsize);
frags = numfrags(fs, size);
frags = lfs_numfrags(fs, size);
lbn = *sp->start_lbp++;
lfs_update_single(fs, sp, lbn, fs->lfs_offset, size);
fs->lfs_offset += frags;
@ -619,8 +619,8 @@ lfs_initseg(struct lfs * fs)
repeat = 1;
fs->lfs_offset = fs->lfs_curseg;
sp->seg_number = dtosn(fs, fs->lfs_curseg);
sp->seg_bytes_left = fsbtob(fs, fs->lfs_fsbpseg);
sp->seg_number = lfs_dtosn(fs, fs->lfs_curseg);
sp->seg_bytes_left = lfs_fsbtob(fs, fs->lfs_fsbpseg);
/*
* If the segment contains a superblock, update the offset
@ -628,19 +628,19 @@ lfs_initseg(struct lfs * fs)
*/
LFS_SEGENTRY(sup, fs, sp->seg_number, bp);
if (sup->su_flags & SEGUSE_SUPERBLOCK) {
fs->lfs_offset += btofsb(fs, LFS_SBPAD);
fs->lfs_offset += lfs_btofsb(fs, LFS_SBPAD);
sp->seg_bytes_left -= LFS_SBPAD;
}
brelse(bp, 0);
/* Segment zero could also contain the labelpad */
if (fs->lfs_version > 1 && sp->seg_number == 0 &&
fs->lfs_start < btofsb(fs, LFS_LABELPAD)) {
fs->lfs_offset += btofsb(fs, LFS_LABELPAD) - fs->lfs_start;
sp->seg_bytes_left -= LFS_LABELPAD - fsbtob(fs, fs->lfs_start);
fs->lfs_start < lfs_btofsb(fs, LFS_LABELPAD)) {
fs->lfs_offset += lfs_btofsb(fs, LFS_LABELPAD) - fs->lfs_start;
sp->seg_bytes_left -= LFS_LABELPAD - lfs_fsbtob(fs, fs->lfs_start);
}
} else {
sp->seg_number = dtosn(fs, fs->lfs_curseg);
sp->seg_bytes_left = fsbtob(fs, fs->lfs_fsbpseg -
sp->seg_number = lfs_dtosn(fs, fs->lfs_curseg);
sp->seg_bytes_left = lfs_fsbtob(fs, fs->lfs_fsbpseg -
(fs->lfs_offset - fs->lfs_curseg));
}
fs->lfs_lastpseg = fs->lfs_offset;
@ -654,11 +654,11 @@ lfs_initseg(struct lfs * fs)
/* Get a new buffer for SEGSUM and enter it into the buffer list. */
sp->cbpp = sp->bpp;
sbp = *sp->cbpp = getblk(fs->lfs_devvp,
fsbtodb(fs, fs->lfs_offset), fs->lfs_sumsize);
LFS_FSBTODB(fs, fs->lfs_offset), fs->lfs_sumsize);
sp->segsum = sbp->b_data;
memset(sp->segsum, 0, fs->lfs_sumsize);
sp->start_bpp = ++sp->cbpp;
fs->lfs_offset += btofsb(fs, fs->lfs_sumsize);
fs->lfs_offset += lfs_btofsb(fs, fs->lfs_sumsize);
/* Set point to SEGSUM, initialize it. */
ssp = sp->segsum;
@ -691,12 +691,12 @@ lfs_newseg(struct lfs * fs)
struct ubuf *bp;
int curseg, isdirty, sn;
LFS_SEGENTRY(sup, fs, dtosn(fs, fs->lfs_nextseg), bp);
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, fs->lfs_nextseg), bp);
sup->su_flags |= SEGUSE_DIRTY | SEGUSE_ACTIVE;
sup->su_nbytes = 0;
sup->su_nsums = 0;
sup->su_ninos = 0;
LFS_WRITESEGENTRY(sup, fs, dtosn(fs, fs->lfs_nextseg), bp);
LFS_WRITESEGENTRY(sup, fs, lfs_dtosn(fs, fs->lfs_nextseg), bp);
LFS_CLEANERINFO(cip, fs, bp);
--cip->clean;
@ -706,7 +706,7 @@ lfs_newseg(struct lfs * fs)
fs->lfs_lastseg = fs->lfs_curseg;
fs->lfs_curseg = fs->lfs_nextseg;
for (sn = curseg = dtosn(fs, fs->lfs_curseg) + fs->lfs_interleave;;) {
for (sn = curseg = lfs_dtosn(fs, fs->lfs_curseg) + fs->lfs_interleave;;) {
sn = (sn + 1) % fs->lfs_nseg;
if (sn == curseg)
errx(1, "lfs_nextseg: no clean segments");
@ -719,7 +719,7 @@ lfs_newseg(struct lfs * fs)
}
++fs->lfs_nactive;
fs->lfs_nextseg = sntod(fs, sn);
fs->lfs_nextseg = lfs_sntod(fs, sn);
}
@ -744,7 +744,7 @@ lfs_writeseg(struct lfs * fs, struct segment * sp)
nblocks = sp->cbpp - sp->bpp;
#if 0
printf("write %d blocks at 0x%x\n",
nblocks, (int)dbtofsb(fs, (*sp->bpp)->b_blkno));
nblocks, (int)LFS_DBTOFSB(fs, (*sp->bpp)->b_blkno));
#endif
if (nblocks == 1)
return 0;
@ -760,13 +760,13 @@ lfs_writeseg(struct lfs * fs, struct segment * sp)
if ((*bpp)->b_vp != devvp) {
sup->su_nbytes += (*bpp)->b_bcount;
}
assert(dtosn(fs, dbtofsb(fs, (*bpp)->b_blkno)) == sp->seg_number);
assert(lfs_dtosn(fs, LFS_DBTOFSB(fs, (*bpp)->b_blkno)) == sp->seg_number);
}
ssp = (SEGSUM *) sp->segsum;
ssp->ss_flags |= SS_RFW;
ninos = (ssp->ss_ninos + INOPB(fs) - 1) / INOPB(fs);
ninos = (ssp->ss_ninos + LFS_INOPB(fs) - 1) / LFS_INOPB(fs);
sup->su_nbytes += ssp->ss_ninos * LFS_DINODE1_SIZE;
if (fs->lfs_version == 1)
@ -775,9 +775,9 @@ lfs_writeseg(struct lfs * fs, struct segment * sp)
sup->su_lastmod = write_time;
sup->su_ninos += ninos;
++sup->su_nsums;
fs->lfs_dmeta += (btofsb(fs, fs->lfs_sumsize) + btofsb(fs, ninos *
fs->lfs_dmeta += (lfs_btofsb(fs, fs->lfs_sumsize) + lfs_btofsb(fs, ninos *
fs->lfs_ibsize));
fs->lfs_avail -= btofsb(fs, fs->lfs_sumsize);
fs->lfs_avail -= lfs_btofsb(fs, fs->lfs_sumsize);
do_again = !(bp->b_flags & B_GATHERED);
LFS_WRITESEGENTRY(sup, fs, sp->seg_number, bp); /* Ifile */
@ -819,8 +819,8 @@ lfs_writeseg(struct lfs * fs, struct segment * sp)
cksum(&ssp->ss_datasum, fs->lfs_sumsize - sizeof(ssp->ss_sumsum));
free(datap);
datap = dp = NULL;
fs->lfs_bfree -= (btofsb(fs, ninos * fs->lfs_ibsize) +
btofsb(fs, fs->lfs_sumsize));
fs->lfs_bfree -= (lfs_btofsb(fs, ninos * fs->lfs_ibsize) +
lfs_btofsb(fs, fs->lfs_sumsize));
if (devvp == NULL)
errx(1, "devvp is NULL");
@ -929,7 +929,7 @@ lfs_segunlock(struct lfs * fs)
if (fs->lfs_seglock == 1) {
if (sp->bpp != sp->cbpp) {
/* Free allocated segment summary */
fs->lfs_offset -= btofsb(fs, fs->lfs_sumsize);
fs->lfs_offset -= lfs_btofsb(fs, fs->lfs_sumsize);
bp = *sp->bpp;
bremfree(bp);
bp->b_flags |= B_DONE | B_INVAL;
@ -1003,7 +1003,7 @@ lfs_writesuper(struct lfs *fs, ulfs_daddr_t daddr)
/* Checksum the superblock and copy it into a buffer. */
fs->lfs_cksum = lfs_sb_cksum(&(fs->lfs_dlfs));
assert(daddr > 0);
bp = getblk(fs->lfs_devvp, fsbtodb(fs, daddr), LFS_SBPAD);
bp = getblk(fs->lfs_devvp, LFS_FSBTODB(fs, daddr), LFS_SBPAD);
memset(bp->b_data + sizeof(struct dlfs), 0,
LFS_SBPAD - sizeof(struct dlfs));
*(struct dlfs *) bp->b_data = fs->lfs_dlfs;

View File

@ -1,4 +1,4 @@
/* $NetBSD: setup.c,v 1.43 2013/06/08 02:16:03 dholland Exp $ */
/* $NetBSD: setup.c,v 1.44 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -238,13 +238,13 @@ setup(const char *dev)
if (debug)
pwarn("adjusting offset, serial for -i 0x%lx\n",
(unsigned long)idaddr);
tdaddr = sntod(fs, dtosn(fs, idaddr));
if (sntod(fs, dtosn(fs, tdaddr)) == tdaddr) {
tdaddr = lfs_sntod(fs, lfs_dtosn(fs, idaddr));
if (lfs_sntod(fs, lfs_dtosn(fs, tdaddr)) == tdaddr) {
if (tdaddr == fs->lfs_start)
tdaddr += btofsb(fs, LFS_LABELPAD);
tdaddr += lfs_btofsb(fs, LFS_LABELPAD);
for (i = 0; i < LFS_MAXNUMSB; i++) {
if (fs->lfs_sboffs[i] == tdaddr)
tdaddr += btofsb(fs, LFS_SBPAD);
tdaddr += lfs_btofsb(fs, LFS_SBPAD);
if (fs->lfs_sboffs[i] > tdaddr)
break;
}
@ -254,7 +254,7 @@ setup(const char *dev)
pwarn("begin with offset/serial 0x%x/%d\n",
(int)fs->lfs_offset, (int)fs->lfs_serial);
while (tdaddr < idaddr) {
bread(fs->lfs_devvp, fsbtodb(fs, tdaddr),
bread(fs->lfs_devvp, LFS_FSBTODB(fs, tdaddr),
fs->lfs_sumsize,
NULL, 0, &bp);
sp = (SEGSUM *)bp->b_data;
@ -268,7 +268,7 @@ setup(const char *dev)
break;
}
fp = (FINFO *)(sp + 1);
bc = howmany(sp->ss_ninos, INOPB(fs)) <<
bc = howmany(sp->ss_ninos, LFS_INOPB(fs)) <<
(fs->lfs_version > 1 ? fs->lfs_ffshift :
fs->lfs_bshift);
for (i = 0; i < sp->ss_nfinfo; i++) {
@ -277,7 +277,7 @@ setup(const char *dev)
fp = (FINFO *)(fp->fi_blocks + fp->fi_nblocks);
}
tdaddr += btofsb(fs, bc) + 1;
tdaddr += lfs_btofsb(fs, bc) + 1;
fs->lfs_offset = tdaddr;
fs->lfs_serial = sp->ss_serial + 1;
brelse(bp, 0);
@ -287,8 +287,8 @@ setup(const char *dev)
* Set curseg, nextseg appropriately -- inlined from
* lfs_newseg()
*/
curseg = dtosn(fs, fs->lfs_offset);
fs->lfs_curseg = sntod(fs, curseg);
curseg = lfs_dtosn(fs, fs->lfs_offset);
fs->lfs_curseg = lfs_sntod(fs, curseg);
for (sn = curseg + fs->lfs_interleave;;) {
sn = (sn + 1) % fs->lfs_nseg;
if (sn == curseg)
@ -304,10 +304,10 @@ setup(const char *dev)
/* Skip superblock if necessary */
for (i = 0; i < LFS_MAXNUMSB; i++)
if (fs->lfs_offset == fs->lfs_sboffs[i])
fs->lfs_offset += btofsb(fs, LFS_SBPAD);
fs->lfs_offset += lfs_btofsb(fs, LFS_SBPAD);
++fs->lfs_nactive;
fs->lfs_nextseg = sntod(fs, sn);
fs->lfs_nextseg = lfs_sntod(fs, sn);
if (debug) {
pwarn("offset = 0x%" PRIx32 ", serial = %" PRId64 "\n",
fs->lfs_offset, fs->lfs_serial);
@ -432,7 +432,7 @@ setup(const char *dev)
/* Initialize Ifile entry */
din_table[fs->lfs_ifile] = fs->lfs_idaddr;
seg_table[dtosn(fs, fs->lfs_idaddr)].su_nbytes += LFS_DINODE1_SIZE;
seg_table[lfs_dtosn(fs, fs->lfs_idaddr)].su_nbytes += LFS_DINODE1_SIZE;
#ifndef VERBOSE_BLOCKMAP
bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(int16_t));

View File

@ -1,4 +1,4 @@
/* $NetBSD: make_lfs.c,v 1.27 2013/06/08 02:16:03 dholland Exp $ */
/* $NetBSD: make_lfs.c,v 1.28 2013/06/18 18:18:58 christos 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.27 2013/06/08 02:16:03 dholland Exp $");
__RCSID("$NetBSD: make_lfs.c,v 1.28 2013/06/18 18:18:58 christos Exp $");
#endif
#endif /* not lint */
@ -237,18 +237,18 @@ make_dinode(ino_t ino, struct ulfs1_dinode *dip, int nfrags, struct lfs *fs)
dip->di_inumber = ino;
dip->di_gen = 1;
fsb_per_blk = blkstofrags(fs, 1);
fsb_per_blk = lfs_blkstofrags(fs, 1);
if (ULFS_NDADDR < nblocks) {
/* Count up how many indirect blocks we need, recursively */
/* XXX We are only called with nblocks > 1 for Ifile */
bb = nblocks - ULFS_NDADDR;
while (bb > 0) {
bb = howmany(bb, NINDIR(fs));
bb = howmany(bb, LFS_NINDIR(fs));
ifibc += bb;
--bb;
}
dip->di_blocks += blkstofrags(fs, ifibc);
dip->di_blocks += lfs_blkstofrags(fs, ifibc);
}
/* Assign the block addresses for the ifile */
@ -257,15 +257,15 @@ make_dinode(ino_t ino, struct ulfs1_dinode *dip, int nfrags, struct lfs *fs)
}
if (nblocks > ULFS_NDADDR) {
dip->di_ib[0] = 0x0;
bb = howmany(nblocks - ULFS_NDADDR, NINDIR(fs)) - 1;
factor = NINDIR(fs);
bb = howmany(nblocks - ULFS_NDADDR, LFS_NINDIR(fs)) - 1;
factor = LFS_NINDIR(fs);
base = -ULFS_NDADDR - factor;
lvl = 1;
while (bb > 0) {
dip->di_ib[lvl] = 0x0;
bb = howmany(bb, NINDIR(fs));
bb = howmany(bb, LFS_NINDIR(fs));
--bb;
factor *= NINDIR(fs);
factor *= LFS_NINDIR(fs);
base -= factor;
++lvl;
}
@ -411,7 +411,7 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
fs->lfs_ffshift = lfs_log2(fsize);
if (1 << fs->lfs_ffshift != fsize)
fatal("%d: frag size not a power of 2", fsize);
fs->lfs_frag = numfrags(fs, bsize);
fs->lfs_frag = lfs_numfrags(fs, bsize);
fs->lfs_fbmask = fs->lfs_frag - 1;
fs->lfs_fbshift = lfs_log2(fs->lfs_frag);
fs->lfs_ifpb = bsize / sizeof(IFILE);
@ -468,13 +468,13 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
fs->lfs_fsbtodb = 0;
fs->lfs_size = dkw->dkw_size >> fs->lfs_blktodb;
}
label_fsb = btofsb(fs, roundup(LFS_LABELPAD, fsize));
sb_fsb = btofsb(fs, roundup(LFS_SBPAD, fsize));
fs->lfs_fsbpseg = dbtofsb(fs, ssize / secsize);
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);
fs->lfs_size = dkw->dkw_size >> fs->lfs_fsbtodb;
fs->lfs_dsize = dbtofsb(fs, dkw->dkw_size) -
MAX(label_fsb, dbtofsb(fs, start));
fs->lfs_nseg = fs->lfs_dsize / segtod(fs, 1);
fs->lfs_dsize = LFS_DBTOFSB(fs, dkw->dkw_size) -
MAX(label_fsb, LFS_DBTOFSB(fs, start));
fs->lfs_nseg = fs->lfs_dsize / lfs_segtod(fs, 1);
fs->lfs_nclean = fs->lfs_nseg - 1;
fs->lfs_maxfilesize = maxfilesize(fs->lfs_bshift);
@ -541,9 +541,9 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
* be written due to fragmentation.
*/
fs->lfs_dsize = (fs->lfs_nseg - fs->lfs_minfreeseg) *
segtod(fs, 1);
lfs_segtod(fs, 1);
fs->lfs_bfree = fs->lfs_dsize;
fs->lfs_bfree -= dbtofsb(fs, ((fs->lfs_nseg / 2) <<
fs->lfs_bfree -= LFS_DBTOFSB(fs, ((fs->lfs_nseg / 2) <<
fs->lfs_blktodb));
fs->lfs_segtabsz = SEGTABSIZE_SU(fs);
@ -563,7 +563,7 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
* >= LFS_SBPAD+LFS_LABELPAD, in order to prevent segment 0
* from having half a superblock in it.
*/
if (fsbtodb(fs, dbtofsb(fs, start)) != start)
if (LFS_FSBTODB(fs, LFS_DBTOFSB(fs, start)) != start)
fatal("Segment 0 offset is not multiple of frag size\n");
if (start != 0 && dbtob(start) != LFS_LABELPAD &&
dbtob(start) < LFS_SBPAD + LFS_LABELPAD) {
@ -577,16 +577,16 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
if (version == 1)
fs->lfs_start = fs->lfs_sboffs[0];
else
fs->lfs_start = dbtofsb(fs, start);
fs->lfs_start = LFS_DBTOFSB(fs, start);
fs->lfs_dsize -= sb_fsb;
for (i = 1; i < LFS_MAXNUMSB; i++) {
sb_addr = ((i * sb_interval) * segtod(fs, 1))
sb_addr = ((i * sb_interval) * lfs_segtod(fs, 1))
+ fs->lfs_sboffs[0];
/* Segment 0 eats the label, except for version 1 */
if (fs->lfs_version > 1 && fs->lfs_start < label_fsb)
sb_addr -= label_fsb - start;
if (sb_addr + sizeof(struct dlfs)
>= dbtofsb(fs, dkw->dkw_size))
>= LFS_DBTOFSB(fs, dkw->dkw_size))
break;
fs->lfs_sboffs[i] = sb_addr;
fs->lfs_dsize -= sb_fsb;
@ -598,10 +598,10 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
"superblock.\nPlease decrease the segment size.\n");
}
fs->lfs_lastseg = sntod(fs, fs->lfs_nseg - 2);
fs->lfs_curseg = sntod(fs, fs->lfs_nseg - 1);
fs->lfs_offset = sntod(fs, fs->lfs_nseg);
fs->lfs_nextseg = sntod(fs, 0);
fs->lfs_lastseg = lfs_sntod(fs, fs->lfs_nseg - 2);
fs->lfs_curseg = lfs_sntod(fs, fs->lfs_nseg - 1);
fs->lfs_offset = lfs_sntod(fs, fs->lfs_nseg);
fs->lfs_nextseg = lfs_sntod(fs, 0);
/*
* Initialize the Ifile inode. Do this before we do anything
@ -615,7 +615,7 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
dip->di_mode = LFS_IFREG | 0600;
dip->di_flags = SF_IMMUTABLE;
make_dinode(LFS_IFILE_INUM, dip,
blkstofrags(fs, fs->lfs_cleansz + fs->lfs_segtabsz + 1), fs);
lfs_blkstofrags(fs, fs->lfs_cleansz + fs->lfs_segtabsz + 1), fs);
dip->di_size = (fs->lfs_cleansz + fs->lfs_segtabsz + 1) << fs->lfs_bshift;
for (i = 0; i < ULFS_NDADDR && i < (dip->di_size >> fs->lfs_bshift); i++)
VTOI(fs->lfs_ivnode)->i_lfs_fragsize[i] = fs->lfs_bsize;
@ -652,7 +652,7 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
LFS_SEGENTRY(segp, fs, i, bp);
if (i == 0 &&
fs->lfs_start < btofsb(fs, LFS_LABELPAD + LFS_SBPAD)) {
fs->lfs_start < lfs_btofsb(fs, LFS_LABELPAD + LFS_SBPAD)) {
segp->su_flags = SEGUSE_SUPERBLOCK;
fs->lfs_bfree -= sb_fsb;
++j;
@ -685,7 +685,7 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
VTOI(vp)->i_nlink = dip->di_nlink = 2;
#endif
VTOI(vp)->i_lfs_effnblks = dip->di_blocks =
btofsb(fs, roundup(LFS_DIRBLKSIZ,fs->lfs_fsize));
lfs_btofsb(fs, roundup(LFS_DIRBLKSIZ,fs->lfs_fsize));
for (i = 0; i < ULFS_NDADDR && i < howmany(LFS_DIRBLKSIZ, fs->lfs_bsize); i++)
VTOI(vp)->i_lfs_fragsize[i] = fs->lfs_bsize;
if (LFS_DIRBLKSIZ < fs->lfs_bsize)
@ -705,7 +705,7 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
VTOI(vp)->i_lfs_osize = dip->di_size = DIRBLKSIZ;
VTOI(vp)->i_nlink = dip->di_nlink = 2;
VTOI(vp)->i_lfs_effnblks = dip->di_blocks =
btofsb(fs, roundup(DIRBLKSIZ,fs->lfs_fsize));
lfs_btofsb(fs, roundup(DIRBLKSIZ,fs->lfs_fsize));
for (i = 0; i < ULFS_NDADDR && i < howmany(DIRBLKSIZ, fs->lfs_bsize); i++)
VTOI(vp)->i_lfs_fragsize[i] = fs->lfs_bsize;
if (DIRBLKSIZ < fs->lfs_bsize)
@ -770,35 +770,35 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
for (i = 0; i < fs->lfs_nseg; i++) {
LFS_SEGENTRY(segp, fs, i, bp);
if (segp->su_flags & SEGUSE_DIRTY) {
bb += btofsb(fs, segp->su_nbytes +
bb += lfs_btofsb(fs, segp->su_nbytes +
segp->su_nsums * fs->lfs_sumsize);
ubb += btofsb(fs, segp->su_nbytes +
ubb += lfs_btofsb(fs, segp->su_nbytes +
segp->su_nsums * fs->lfs_sumsize +
segp->su_ninos * fs->lfs_ibsize);
dmeta += btofsb(fs,
dmeta += lfs_btofsb(fs,
fs->lfs_sumsize * segp->su_nsums);
dmeta += btofsb(fs,
dmeta += lfs_btofsb(fs,
fs->lfs_ibsize * segp->su_ninos);
} else {
fs->lfs_avail += segtod(fs, 1);
fs->lfs_avail += lfs_segtod(fs, 1);
if (segp->su_flags & SEGUSE_SUPERBLOCK)
fs->lfs_avail -= btofsb(fs, LFS_SBPAD);
fs->lfs_avail -= lfs_btofsb(fs, LFS_SBPAD);
if (i == 0 && fs->lfs_version > 1 &&
fs->lfs_start < btofsb(fs, LFS_LABELPAD))
fs->lfs_avail -= btofsb(fs, LFS_LABELPAD) -
fs->lfs_start < lfs_btofsb(fs, LFS_LABELPAD))
fs->lfs_avail -= lfs_btofsb(fs, LFS_LABELPAD) -
fs->lfs_start;
}
brelse(bp, 0);
}
/* Also may be available bytes in current seg */
i = dtosn(fs, fs->lfs_offset);
fs->lfs_avail += sntod(fs, i + 1) - fs->lfs_offset;
i = lfs_dtosn(fs, fs->lfs_offset);
fs->lfs_avail += lfs_sntod(fs, i + 1) - fs->lfs_offset;
/* But do not count minfreesegs */
fs->lfs_avail -= segtod(fs, (fs->lfs_minfreeseg - (fs->lfs_minfreeseg / 2)));
fs->lfs_avail -= lfs_segtod(fs, (fs->lfs_minfreeseg - (fs->lfs_minfreeseg / 2)));
labelskew = 0;
if (fs->lfs_version > 1 && fs->lfs_start < btofsb(fs, LFS_LABELPAD))
labelskew = btofsb(fs, LFS_LABELPAD);
if (fs->lfs_version > 1 && fs->lfs_start < lfs_btofsb(fs, LFS_LABELPAD))
labelskew = lfs_btofsb(fs, LFS_LABELPAD);
fs->lfs_bfree = fs->lfs_dsize - labelskew - (ubb + bb) / 2;
/* Put that in the Ifile version too, and write it */
@ -822,7 +822,7 @@ make_lfs(int devfd, uint secsize, struct dkwedge_info *dkw, int minfree,
if (i != 0)
curw += printf(", ");
ww = snprintf(tbuf, sizeof(tbuf), "%lld",
(long long)fsbtodb(fs, seg_addr));
(long long)LFS_FSBTODB(fs, seg_addr));
curw += ww;
if (curw >= 78) {
printf("\n%s", tbuf);

View File

@ -1,4 +1,4 @@
/* $NetBSD: newfs.c,v 1.28 2013/06/08 02:16:03 dholland Exp $ */
/* $NetBSD: newfs.c,v 1.29 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 1989, 1992, 1993
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1992, 1993\
#if 0
static char sccsid[] = "@(#)newfs.c 8.5 (Berkeley) 5/24/95";
#else
__RCSID("$NetBSD: newfs.c,v 1.28 2013/06/08 02:16:03 dholland Exp $");
__RCSID("$NetBSD: newfs.c,v 1.29 2013/06/18 18:18:58 christos Exp $");
#endif
#endif /* not lint */
@ -166,7 +166,7 @@ main(int argc, char **argv)
struct disk_geom geo;
struct dkwedge_info dkw;
struct stat st;
int debug, force, fsi, fso, segsize, maxpartitions;
int debug, force, fsi, fso, lfs_segsize, maxpartitions;
uint secsize = 0;
daddr_t start;
const char *opstring;
@ -186,14 +186,14 @@ main(int argc, char **argv)
opstring = "AB:b:DFf:I:i:LM:m:NO:R:r:S:s:v:";
debug = force = segsize = start = 0;
debug = force = lfs_segsize = start = 0;
while ((ch = getopt(argc, argv, opstring)) != -1)
switch(ch) {
case 'A': /* Adaptively configure segment size */
segsize = -1;
lfs_segsize = -1;
break;
case 'B': /* LFS segment size */
segsize = strsuftoi64("segment size", optarg, LFS_MINSEGSIZE, INT64_MAX, NULL);
lfs_segsize = strsuftoi64("segment size", optarg, LFS_MINSEGSIZE, INT64_MAX, NULL);
break;
case 'D':
debug = 1;
@ -344,17 +344,17 @@ main(int argc, char **argv)
dkw.dkw_size = fssize;
/* Try autoconfiguring segment size, if asked to */
if (segsize == -1) {
if (lfs_segsize == -1) {
if (!S_ISCHR(st.st_mode)) {
warnx("%s is not a character special device, ignoring -A", special);
segsize = 0;
lfs_segsize = 0;
} else
segsize = auto_segsize(fsi, dkw.dkw_size / secsize,
lfs_segsize = auto_segsize(fsi, dkw.dkw_size / secsize,
version);
}
/* If we're making a LFS, we break out here */
r = make_lfs(fso, secsize, &dkw, minfree, bsize, fsize, segsize,
r = make_lfs(fso, secsize, &dkw, minfree, bsize, fsize, lfs_segsize,
minfreeseg, resvseg, version, start, ibsize, interleave, roll_id);
if (debug)
bufstats();

View File

@ -1,4 +1,4 @@
/* $NetBSD: readufs.h,v 1.7 2013/06/15 00:42:16 christos Exp $ */
/* $NetBSD: readufs.h,v 1.8 2013/06/18 18:18:58 christos Exp $ */
/* from Id: readufs.h,v 1.10 2003/12/16 13:54:11 itohy Exp */
/*
@ -9,8 +9,8 @@
#include <sys/types.h>
#include <sys/param.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ufs/dir.h>
#include <ufs/lfs/ulfs_dinode.h>
#include <ufs/ufs/dir.h>
/*
* UFS1 / UFS2

View File

@ -1,4 +1,4 @@
/* $NetBSD: readufs.h,v 1.11 2013/06/15 01:37:10 christos Exp $ */
/* $NetBSD: readufs.h,v 1.12 2013/06/18 18:18:58 christos Exp $ */
/* from Id: readufs.h,v 1.9 2003/10/15 14:16:58 itohy Exp */
/*
@ -12,6 +12,7 @@
#include <ufs/lfs/lfs.h>
#endif
#include <ufs/ufs/dinode.h>
#include <ufs/lfs/lfs.h>
#include <ufs/ufs/dir.h>
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: readufs_lfs.c,v 1.13 2013/06/15 01:37:10 christos Exp $ */
/* $NetBSD: readufs_lfs.c,v 1.14 2013/06/18 18:18:58 christos Exp $ */
/* from Id: readufs_lfs.c,v 1.7 2003/10/15 14:16:58 itohy Exp */
/*
@ -14,7 +14,6 @@
#include "readufs.h"
#include <sys/mount.h>
#include <ufs/lfs/lfs.h>
#ifndef USE_UFS1
#error LFS currently requires USE_UFS1

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfsv1.c,v 1.6 2013/06/09 00:02:33 dholland Exp $ */
/* $NetBSD: lfsv1.c,v 1.7 2013/06/18 18:18:58 christos Exp $ */
#define LIBSA_LFS
#define REQUIRED_LFS_VERSION 1
@ -19,7 +19,12 @@
#define IFILE_Vx IFILE_V1
#define FSBTODB(fs, daddr) (daddr) /* LFSv1 uses sectors for addresses */
#define INOPBx(fs) INOPB(fs)
#define INOPBx(fs) LFS_INOPB(fs)
#define NINDIR LFS_NINDIR
#define blkoff(a, b) lfs_blkoff((a), (b))
#define lblkno(a, b) lfs_lblkno((a), (b))
#define dblksize(a, b, c) lfs_dblksize((a), (b), (c))
#define FSMOD "lfs"

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfsv2.c,v 1.6 2013/06/09 00:02:33 dholland Exp $ */
/* $NetBSD: lfsv2.c,v 1.7 2013/06/18 18:18:58 christos Exp $ */
#define LIBSA_LFS
#define REQUIRED_LFS_VERSION 2
@ -20,11 +20,17 @@
#define IFILE_Vx IFILE
#ifdef LFS_IFILE_FRAG_ADDRESSING /* XXX see sys/ufs/lfs/ -- not tested */
#define INOPBx(fs) INOPF(fs)
#define INOPBx(fs) LFS_INOPF(fs)
#else
#define INOPBx(fs) INOPB(fs)
#define INOPBx(fs) LFS_INOPB(fs)
#endif
#define NINDIR LFS_NINDIR
#define blkoff(a, b) lfs_blkoff((a), (b))
#define lblkno(a, b) lfs_lblkno((a), (b))
#define dblksize(a, b, c) lfs_dblksize((a), (b), (c))
#define fsbtodb(a, b) LFS_FSBTODB((a), (b))
#define FSMOD "lfs"
#include "lib/libsa/ufs.c"

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs.h,v 1.153 2013/06/18 08:01:00 dholland Exp $ */
/* $NetBSD: lfs.h,v 1.154 2013/06/18 18:18:58 christos 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 */
@ -999,65 +999,65 @@ struct lfs {
LIST_HEAD(, segdelta) lfs_segdhd; /* List of pending trunc accounting events */
};
/* NINDIR is the number of indirects in a file system block. */
#define NINDIR(fs) ((fs)->lfs_nindir)
/* LFS_NINDIR is the number of indirects in a file system block. */
#define LFS_NINDIR(fs) ((fs)->lfs_nindir)
/* INOPB is the number of inodes in a secondary storage block. */
#define INOPB(fs) ((fs)->lfs_inopb)
/* LFS_INOPB is the number of inodes in a secondary storage block. */
#define LFS_INOPB(fs) ((fs)->lfs_inopb)
/* INOPF is the number of inodes in a fragment. */
#define INOPF(fs) ((fs)->lfs_inopf)
#define LFS_INOPF(fs) ((fs)->lfs_inopf)
#define blksize(fs, ip, lbn) \
#define lfs_blksize(fs, ip, lbn) \
(((lbn) >= ULFS_NDADDR || (ip)->i_ffs1_size >= ((lbn) + 1) << (fs)->lfs_bshift) \
? (fs)->lfs_bsize \
: (fragroundup(fs, blkoff(fs, (ip)->i_ffs1_size))))
#define blkoff(fs, loc) ((int)((loc) & (fs)->lfs_bmask))
#define fragoff(fs, loc) /* calculates (loc % fs->lfs_fsize) */ \
: (lfs_fragroundup(fs, lfs_blkoff(fs, (ip)->i_ffs1_size))))
#define lfs_blkoff(fs, loc) ((int)((loc) & (fs)->lfs_bmask))
#define lfs_fragoff(fs, loc) /* calculates (loc % fs->lfs_fsize) */ \
((int)((loc) & (fs)->lfs_ffmask))
#if defined (_KERNEL)
#define fsbtodb(fs, b) ((b) << ((fs)->lfs_ffshift - DEV_BSHIFT))
#define dbtofsb(fs, b) ((b) >> ((fs)->lfs_ffshift - DEV_BSHIFT))
#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))
#else
#define fsbtodb(fs, b) ((b) << (fs)->lfs_fsbtodb)
#define dbtofsb(fs, b) ((b) >> (fs)->lfs_fsbtodb)
#define LFS_FSBTODB(fs, b) ((b) << (fs)->lfs_fsbtodb)
#define LFS_DBTOFSB(fs, b) ((b) >> (fs)->lfs_fsbtodb)
#endif
#define lblkno(fs, loc) ((loc) >> (fs)->lfs_bshift)
#define lblktosize(fs, blk) ((blk) << (fs)->lfs_bshift)
#define lfs_lblkno(fs, loc) ((loc) >> (fs)->lfs_bshift)
#define lfs_lblktosize(fs, blk) ((blk) << (fs)->lfs_bshift)
#define fsbtob(fs, b) ((b) << (fs)->lfs_ffshift)
#define btofsb(fs, b) ((b) >> (fs)->lfs_ffshift)
#define lfs_fsbtob(fs, b) ((b) << (fs)->lfs_ffshift)
#define lfs_btofsb(fs, b) ((b) >> (fs)->lfs_ffshift)
#define numfrags(fs, loc) /* calculates (loc / fs->lfs_fsize) */ \
#define lfs_numfrags(fs, loc) /* calculates (loc / fs->lfs_fsize) */ \
((loc) >> (fs)->lfs_ffshift)
#define blkroundup(fs, size) /* calculates roundup(size, fs->lfs_bsize) */ \
#define lfs_blkroundup(fs, size)/* calculates roundup(size, fs->lfs_bsize) */ \
((off_t)(((size) + (fs)->lfs_bmask) & (~(fs)->lfs_bmask)))
#define fragroundup(fs, size) /* calculates roundup(size, fs->lfs_fsize) */ \
#define lfs_fragroundup(fs, size)/* calculates roundup(size, fs->lfs_fsize) */ \
((off_t)(((size) + (fs)->lfs_ffmask) & (~(fs)->lfs_ffmask)))
#define fragstoblks(fs, frags)/* calculates (frags / fs->fs_frag) */ \
#define lfs_fragstoblks(fs, frags)/* calculates (frags / fs->fs_frag) */ \
((frags) >> (fs)->lfs_fbshift)
#define blkstofrags(fs, blks) /* calculates (blks * fs->fs_frag) */ \
#define lfs_blkstofrags(fs, blks)/* calculates (blks * fs->fs_frag) */ \
((blks) << (fs)->lfs_fbshift)
#define fragnum(fs, fsb) /* calculates (fsb % fs->lfs_frag) */ \
#define lfs_fragnum(fs, fsb) /* calculates (fsb % fs->lfs_frag) */ \
((fsb) & ((fs)->lfs_frag - 1))
#define blknum(fs, fsb) /* calculates rounddown(fsb, fs->lfs_frag) */ \
#define lfs_blknum(fs, fsb) /* calculates rounddown(fsb, fs->lfs_frag) */ \
((fsb) &~ ((fs)->lfs_frag - 1))
#define dblksize(fs, dp, lbn) \
#define lfs_dblksize(fs, dp, lbn) \
(((lbn) >= ULFS_NDADDR || (dp)->di_size >= ((lbn) + 1) << (fs)->lfs_bshift)\
? (fs)->lfs_bsize \
: (fragroundup(fs, blkoff(fs, (dp)->di_size))))
: (lfs_fragroundup(fs, lfs_blkoff(fs, (dp)->di_size))))
#define segsize(fs) ((fs)->lfs_version == 1 ? \
lblktosize((fs), (fs)->lfs_ssize) : \
#define lfs_segsize(fs) ((fs)->lfs_version == 1 ? \
lfs_lblktosize((fs), (fs)->lfs_ssize) : \
(fs)->lfs_ssize)
#define segtod(fs, seg) (((fs)->lfs_version == 1 ? \
#define lfs_segtod(fs, seg) (((fs)->lfs_version == 1 ? \
(fs)->lfs_ssize << (fs)->lfs_blktodb : \
btofsb((fs), (fs)->lfs_ssize)) * (seg))
#define dtosn(fs, daddr) /* block address to segment number */ \
((uint32_t)(((daddr) - (fs)->lfs_start) / segtod((fs), 1)))
#define sntod(fs, sn) /* segment number to disk address */ \
((daddr_t)(segtod((fs), (sn)) + (fs)->lfs_start))
lfs_btofsb((fs), (fs)->lfs_ssize)) * (seg))
#define lfs_dtosn(fs, daddr) /* block address to segment number */ \
((uint32_t)(((daddr) - (fs)->lfs_start) / lfs_segtod((fs), 1)))
#define lfs_sntod(fs, sn) /* segment number to disk address */ \
((daddr_t)(lfs_segtod((fs), (sn)) + (fs)->lfs_start))
/*
* Structures used by lfs_bmapv and lfs_markv to communicate information
@ -1189,7 +1189,7 @@ struct lbnentry {
* directory direct block (1) + ULFS_NIADDR indirect blocks + inode block (1) +
* ifile direct block (1) + ULFS_NIADDR indirect blocks = 3 + 2 * ULFS_NIADDR blocks.
*/
#define LFS_NRESERVE(F) (btofsb((F), (2 * ULFS_NIADDR + 3) << (F)->lfs_bshift))
#define LFS_NRESERVE(F) (lfs_btofsb((F), (2 * ULFS_NIADDR + 3) << (F)->lfs_bshift))
/* Statistics Counters */
struct lfs_stats { /* Must match sysctl list in lfs_vfsops.h ! */

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_alloc.c,v 1.116 2013/06/06 00:48:04 dholland Exp $ */
/* $NetBSD: lfs_alloc.c,v 1.117 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.116 2013/06/06 00:48:04 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.117 2013/06/18 18:18:58 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@ -126,7 +126,7 @@ lfs_extend_ifile(struct lfs *fs, kauth_cred_t cred)
vp = fs->lfs_ivnode;
ip = VTOI(vp);
blkno = lblkno(fs, ip->i_size);
blkno = lfs_lblkno(fs, ip->i_size);
if ((error = lfs_balloc(vp, ip->i_size, fs->lfs_bsize, cred, 0,
&bp)) != 0) {
return (error);
@ -549,12 +549,12 @@ lfs_vfree(struct vnode *vp, ino_t ino, int mode)
}
#endif /* DIAGNOSTIC */
if (old_iaddr != LFS_UNUSED_DADDR) {
LFS_SEGENTRY(sup, fs, dtosn(fs, old_iaddr), bp);
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, old_iaddr), bp);
#ifdef DIAGNOSTIC
if (sup->su_nbytes < sizeof (struct ulfs1_dinode)) {
printf("lfs_vfree: negative byte count"
" (segment %" PRIu32 " short by %d)\n",
dtosn(fs, old_iaddr),
lfs_dtosn(fs, old_iaddr),
(int)sizeof (struct ulfs1_dinode) -
sup->su_nbytes);
panic("lfs_vfree: negative byte count");
@ -562,7 +562,7 @@ lfs_vfree(struct vnode *vp, ino_t ino, int mode)
}
#endif
sup->su_nbytes -= sizeof (struct ulfs1_dinode);
LFS_WRITESEGENTRY(sup, fs, dtosn(fs, old_iaddr), bp); /* Ifile */
LFS_WRITESEGENTRY(sup, fs, lfs_dtosn(fs, old_iaddr), bp); /* Ifile */
}
/* Set superblock modified bit and decrement file count. */
@ -618,10 +618,10 @@ lfs_order_freelist(struct lfs *fs)
VFS_VGET(fs->lfs_ivnode->v_mount, ino, &vp) == 0) {
lfs_truncate(vp, 0, 0, NOCRED);
vput(vp);
LFS_SEGENTRY(sup, fs, dtosn(fs, ifp->if_daddr), bp);
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, ifp->if_daddr), bp);
KASSERT(sup->su_nbytes >= DINODE1_SIZE);
sup->su_nbytes -= DINODE1_SIZE;
LFS_WRITESEGENTRY(sup, fs, dtosn(fs, ifp->if_daddr), bp);
LFS_WRITESEGENTRY(sup, fs, lfs_dtosn(fs, ifp->if_daddr), bp);
/* Set up to fall through to next section */
ifp->if_daddr = LFS_UNUSED_DADDR;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_balloc.c,v 1.76 2013/06/06 00:49:28 dholland Exp $ */
/* $NetBSD: lfs_balloc.c,v 1.77 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.76 2013/06/06 00:49:28 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.77 2013/06/18 18:18:58 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@ -123,9 +123,9 @@ lfs_balloc(struct vnode *vp, off_t startoffset, int iosize, kauth_cred_t cred,
ip = VTOI(vp);
fs = ip->i_lfs;
offset = blkoff(fs, startoffset);
offset = lfs_blkoff(fs, startoffset);
KASSERT(iosize <= fs->lfs_bsize);
lbn = lblkno(fs, startoffset);
lbn = lfs_lblkno(fs, startoffset);
/* (void)lfs_check(vp, lbn, 0); */
ASSERT_MAYBE_SEGLOCK(fs);
@ -150,9 +150,9 @@ lfs_balloc(struct vnode *vp, off_t startoffset, int iosize, kauth_cred_t cred,
*bpp = NULL;
/* Check for block beyond end of file and fragment extension needed. */
lastblock = lblkno(fs, ip->i_size);
lastblock = lfs_lblkno(fs, ip->i_size);
if (lastblock < ULFS_NDADDR && lastblock < lbn) {
osize = blksize(fs, ip, lastblock);
osize = lfs_blksize(fs, ip, lastblock);
if (osize < fs->lfs_bsize && osize > 0) {
if ((error = lfs_fragextend(vp, osize, fs->lfs_bsize,
lastblock,
@ -175,12 +175,12 @@ lfs_balloc(struct vnode *vp, off_t startoffset, int iosize, kauth_cred_t cred,
* size or it already exists and contains some fragments and
* may need to extend it.
*/
if (lbn < ULFS_NDADDR && lblkno(fs, ip->i_size) <= lbn) {
osize = blksize(fs, ip, lbn);
nsize = fragroundup(fs, offset + iosize);
if (lblktosize(fs, lbn) >= ip->i_size) {
if (lbn < ULFS_NDADDR && lfs_lblkno(fs, ip->i_size) <= lbn) {
osize = lfs_blksize(fs, ip, lbn);
nsize = lfs_fragroundup(fs, offset + iosize);
if (lfs_lblktosize(fs, lbn) >= ip->i_size) {
/* Brand new block or fragment */
frags = numfrags(fs, nsize);
frags = lfs_numfrags(fs, nsize);
if (!ISSPACE(fs, frags, cred))
return ENOSPC;
if (bpp) {
@ -260,7 +260,7 @@ lfs_balloc(struct vnode *vp, off_t startoffset, int iosize, kauth_cred_t cred,
clrbuf(ibp);
ibp->b_blkno = UNWRITTEN;
} else if (!(ibp->b_oflags & (BO_DELWRI | BO_DONE))) {
ibp->b_blkno = fsbtodb(fs, idaddr);
ibp->b_blkno = LFS_FSBTODB(fs, idaddr);
ibp->b_flags |= B_READ;
VOP_STRATEGY(vp, ibp);
biowait(ibp);
@ -294,7 +294,7 @@ lfs_balloc(struct vnode *vp, off_t startoffset, int iosize, kauth_cred_t cred,
* Get the existing block from the cache, if requested.
*/
if (bpp)
*bpp = bp = getblk(vp, lbn, blksize(fs, ip, lbn), 0, 0);
*bpp = bp = getblk(vp, lbn, lfs_blksize(fs, ip, lbn), 0, 0);
/*
* Do accounting on blocks that represent pages.
@ -380,7 +380,7 @@ lfs_fragextend(struct vnode *vp, int osize, int nsize, daddr_t lbn, struct buf *
ip = VTOI(vp);
fs = ip->i_lfs;
frags = (long)numfrags(fs, nsize - osize);
frags = (long)lfs_numfrags(fs, nsize - osize);
error = 0;
ASSERT_NO_SEGLOCK(fs);
@ -500,7 +500,7 @@ lfs_register_block(struct vnode *vp, daddr_t lbn)
ASSERT_NO_SEGLOCK(fs);
/* If no space, wait for the cleaner */
lfs_availwait(fs, btofsb(fs, 1 << fs->lfs_bshift));
lfs_availwait(fs, lfs_btofsb(fs, 1 << fs->lfs_bshift));
lbp = (struct lbnentry *)pool_get(&lfs_lbnentry_pool, PR_WAITOK);
lbp->lbn = lbn;
@ -513,7 +513,7 @@ lfs_register_block(struct vnode *vp, daddr_t lbn)
}
++ip->i_lfs_nbtree;
fs->lfs_favail += btofsb(fs, (1 << fs->lfs_bshift));
fs->lfs_favail += lfs_btofsb(fs, (1 << fs->lfs_bshift));
fs->lfs_pages += fs->lfs_bsize >> PAGE_SHIFT;
++locked_fakequeue_count;
lfs_subsys_pages += fs->lfs_bsize >> PAGE_SHIFT;
@ -528,8 +528,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 > btofsb(fs, (1 << fs->lfs_bshift)))
fs->lfs_favail -= btofsb(fs, (1 << fs->lfs_bshift));
if (fs->lfs_favail > lfs_btofsb(fs, (1 << fs->lfs_bshift)))
fs->lfs_favail -= lfs_btofsb(fs, (1 << fs->lfs_bshift));
fs->lfs_pages -= fs->lfs_bsize >> PAGE_SHIFT;
if (locked_fakequeue_count > 0)
--locked_fakequeue_count;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_bio.c,v 1.124 2013/06/06 00:48:04 dholland Exp $ */
/* $NetBSD: lfs_bio.c,v 1.125 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2008 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.124 2013/06/06 00:48:04 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.125 2013/06/18 18:18:58 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -315,7 +315,7 @@ lfs_reserve(struct lfs *fs, struct vnode *vp, struct vnode *vp2, int fsb)
/*
* XXX just a guess. should be more precise.
*/
error = lfs_reservebuf(fs, vp, vp2, fsb, fsbtob(fs, fsb));
error = lfs_reservebuf(fs, vp, vp2, fsb, lfs_fsbtob(fs, fsb));
if (error)
lfs_reserveavail(fs, vp, vp2, -fsb);
@ -357,8 +357,8 @@ lfs_fits(struct lfs *fs, int fsb)
int needed;
ASSERT_NO_SEGLOCK(fs);
needed = fsb + btofsb(fs, fs->lfs_sumsize) +
((howmany(fs->lfs_uinodes + 1, INOPB(fs)) + fs->lfs_segtabsz +
needed = fsb + lfs_btofsb(fs, fs->lfs_sumsize) +
((howmany(fs->lfs_uinodes + 1, LFS_INOPB(fs)) + fs->lfs_segtabsz +
1) << (fs->lfs_bshift - fs->lfs_ffshift));
if (needed >= fs->lfs_avail) {
@ -469,7 +469,7 @@ lfs_bwrite_ext(struct buf *bp, int flags)
* blocks.
*/
if ((bp->b_flags & B_LOCKED) == 0) {
fsb = numfrags(fs, bp->b_bcount);
fsb = lfs_numfrags(fs, bp->b_bcount);
ip = VTOI(vp);
mutex_enter(&lfs_lock);
@ -596,7 +596,7 @@ lfs_flush(struct lfs *fs, int flags, int only_onefs)
wakeup(&lfs_writing);
}
#define INOCOUNT(fs) howmany((fs)->lfs_uinodes, INOPB(fs))
#define INOCOUNT(fs) howmany((fs)->lfs_uinodes, LFS_INOPB(fs))
#define INOBYTES(fs) ((fs)->lfs_uinodes * sizeof (struct ulfs1_dinode))
/*
@ -731,7 +731,7 @@ lfs_newbuf(struct lfs *fs, struct vnode *vp, daddr_t daddr, size_t size, int typ
size_t nbytes;
ASSERT_MAYBE_SEGLOCK(fs);
nbytes = roundup(size, fsbtob(fs, 1));
nbytes = roundup(size, lfs_fsbtob(fs, 1));
bp = getiobuf(NULL, true);
if (nbytes) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_debug.c,v 1.42 2013/06/06 00:48:04 dholland Exp $ */
/* $NetBSD: lfs_debug.c,v 1.43 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_debug.c,v 1.42 2013/06/06 00:48:04 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_debug.c,v 1.43 2013/06/18 18:18:58 christos Exp $");
#ifdef DEBUG
@ -240,7 +240,7 @@ lfs_check_segsum(struct lfs *fs, struct segment *sp, char *file, int line)
/* amount taken up by FINFOs */
- ((char *)&(sp->fip->fi_blocks[sp->fip->fi_nblocks]) - (char *)(sp->segsum))
/* amount taken up by inode blocks */
- sizeof(int32_t)*((sp->ninodes+INOPB(fs)-1) / INOPB(fs));
- sizeof(int32_t)*((sp->ninodes+LFS_INOPB(fs)-1) / LFS_INOPB(fs));
#if 0
if (actual - sp->sum_bytes_left < offset)
{
@ -259,7 +259,7 @@ lfs_check_segsum(struct lfs *fs, struct segment *sp, char *file, int line)
#endif
if (sp->sum_bytes_left > 0
&& ((char *)(sp->segsum))[fs->lfs_sumsize
- sizeof(int32_t) * ((sp->ninodes+INOPB(fs)-1) / INOPB(fs))
- sizeof(int32_t) * ((sp->ninodes+LFS_INOPB(fs)-1) / LFS_INOPB(fs))
- sp->sum_bytes_left] != '\0') {
printf("%s:%d: warning: segsum overwrite at %d (-%d => %d)\n",
file, line, sp->sum_bytes_left,
@ -299,7 +299,7 @@ lfs_check_bpp(struct lfs *fs, struct segment *sp, char *file, int line)
(*bpp)->b_blkno);
}
}
blkno += fsbtodb(fs, btofsb(fs, (*bpp)->b_bcount));
blkno += LFS_FSBTODB(fs, lfs_btofsb(fs, (*bpp)->b_bcount));
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_inode.c,v 1.131 2013/06/06 00:49:28 dholland Exp $ */
/* $NetBSD: lfs_inode.c,v 1.132 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.131 2013/06/06 00:49:28 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.132 2013/06/18 18:18:58 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@ -106,17 +106,17 @@ lfs_ifind(struct lfs *fs, ino_t ino, struct buf *bp)
* inode will supercede earlier ones. Though it is unlikely, it is
* possible that the same inode will appear in the same inode block.
*/
fin = dip + INOPB(fs);
fin = dip + LFS_INOPB(fs);
for (ldip = fin - 1; ldip >= dip; --ldip)
if (ldip->di_inumber == ino)
return (ldip);
printf("searched %d entries\n", (int)(fin - dip));
printf("offset is 0x%x (seg %d)\n", fs->lfs_offset,
dtosn(fs, fs->lfs_offset));
lfs_dtosn(fs, fs->lfs_offset));
printf("block is 0x%llx (seg %lld)\n",
(unsigned long long)dbtofsb(fs, bp->b_blkno),
(long long)dtosn(fs, dbtofsb(fs, bp->b_blkno)));
(unsigned long long)LFS_DBTOFSB(fs, bp->b_blkno),
(long long)lfs_dtosn(fs, LFS_DBTOFSB(fs, bp->b_blkno)));
return NULL;
}
@ -267,12 +267,12 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
if (ioflag & IO_SYNC)
aflags |= B_SYNC;
if (usepc) {
if (lblkno(fs, osize) < ULFS_NDADDR &&
lblkno(fs, osize) != lblkno(fs, length) &&
blkroundup(fs, osize) != osize) {
if (lfs_lblkno(fs, osize) < ULFS_NDADDR &&
lfs_lblkno(fs, osize) != lfs_lblkno(fs, length) &&
lfs_blkroundup(fs, osize) != osize) {
off_t eob;
eob = blkroundup(fs, osize);
eob = lfs_blkroundup(fs, osize);
uvm_vnp_setwritesize(ovp, eob);
error = ulfs_balloc_range(ovp, osize,
eob - osize, cred, aflags);
@ -300,30 +300,30 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
uvm_vnp_setsize(ovp, length);
oip->i_flag |= IN_CHANGE | IN_UPDATE;
KASSERT(ovp->v_size == oip->i_size);
oip->i_lfs_hiblk = lblkno(fs, oip->i_size + fs->lfs_bsize - 1) - 1;
oip->i_lfs_hiblk = lfs_lblkno(fs, oip->i_size + fs->lfs_bsize - 1) - 1;
return (lfs_update(ovp, NULL, NULL, 0));
} else {
error = lfs_reserve(fs, ovp, NULL,
btofsb(fs, (ULFS_NIADDR + 2) << fs->lfs_bshift));
lfs_btofsb(fs, (ULFS_NIADDR + 2) << fs->lfs_bshift));
if (error)
return (error);
error = lfs_balloc(ovp, length - 1, 1, cred,
aflags, &bp);
lfs_reserve(fs, ovp, NULL,
-btofsb(fs, (ULFS_NIADDR + 2) << fs->lfs_bshift));
-lfs_btofsb(fs, (ULFS_NIADDR + 2) << fs->lfs_bshift));
if (error)
return (error);
oip->i_ffs1_size = oip->i_size = length;
uvm_vnp_setsize(ovp, length);
(void) VOP_BWRITE(bp->b_vp, bp);
oip->i_flag |= IN_CHANGE | IN_UPDATE;
oip->i_lfs_hiblk = lblkno(fs, oip->i_size + fs->lfs_bsize - 1) - 1;
oip->i_lfs_hiblk = lfs_lblkno(fs, oip->i_size + fs->lfs_bsize - 1) - 1;
return (lfs_update(ovp, NULL, NULL, 0));
}
}
if ((error = lfs_reserve(fs, ovp, NULL,
btofsb(fs, (2 * ULFS_NIADDR + 3) << fs->lfs_bshift))) != 0)
lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << fs->lfs_bshift))) != 0)
return (error);
/*
@ -334,7 +334,7 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
* of subsequent file growth. Directories however are not
* zero'ed as they should grow back initialized to empty.
*/
offset = blkoff(fs, length);
offset = lfs_blkoff(fs, length);
lastseg = -1;
bc = 0;
@ -343,20 +343,20 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
if (offset == 0) {
oip->i_size = oip->i_ffs1_size = length;
} else if (!usepc) {
lbn = lblkno(fs, length);
lbn = lfs_lblkno(fs, length);
aflags = B_CLRBUF;
if (ioflag & IO_SYNC)
aflags |= B_SYNC;
error = lfs_balloc(ovp, length - 1, 1, cred, aflags, &bp);
if (error) {
lfs_reserve(fs, ovp, NULL,
-btofsb(fs, (2 * ULFS_NIADDR + 3) << fs->lfs_bshift));
-lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << fs->lfs_bshift));
goto errout;
}
obufsize = bp->b_bufsize;
odb = btofsb(fs, bp->b_bcount);
odb = lfs_btofsb(fs, bp->b_bcount);
oip->i_size = oip->i_ffs1_size = length;
size = blksize(fs, oip, lbn);
size = lfs_blksize(fs, oip, lbn);
if (ovp->v_type != VDIR)
memset((char *)bp->b_data + offset, 0,
(u_int)(size - offset));
@ -367,7 +367,7 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
mutex_exit(&lfs_lock);
}
if (bp->b_oflags & BO_DELWRI)
fs->lfs_avail += odb - btofsb(fs, size);
fs->lfs_avail += odb - lfs_btofsb(fs, size);
(void) VOP_BWRITE(bp->b_vp, bp);
} else { /* vp->v_type == VREG && length < osize && offset != 0 */
/*
@ -388,12 +388,12 @@ 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,
-btofsb(fs, (2 * ULFS_NIADDR + 3) << fs->lfs_bshift));
-lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << fs->lfs_bshift));
goto errout;
}
xlbn = lblkno(fs, length);
size = blksize(fs, oip, xlbn);
eoz = MIN(lblktosize(fs, xlbn) + size, osize);
xlbn = lfs_lblkno(fs, length);
size = lfs_blksize(fs, oip, xlbn);
eoz = MIN(lfs_lblktosize(fs, xlbn) + size, osize);
ubc_zerorange(&ovp->v_uobj, length, eoz - length,
UBC_UNMAP_FLAG(ovp));
if (round_page(eoz) > round_page(length)) {
@ -404,7 +404,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,
-btofsb(fs, (2 * ULFS_NIADDR + 3) << fs->lfs_bshift));
-lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << fs->lfs_bshift));
goto errout;
}
}
@ -423,13 +423,13 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
*/
/* Avoid sign overflow - XXX assumes that off_t is a quad_t. */
if (length > QUAD_MAX - fs->lfs_bsize)
lastblock = lblkno(fs, QUAD_MAX - fs->lfs_bsize);
lastblock = lfs_lblkno(fs, QUAD_MAX - fs->lfs_bsize);
else
lastblock = lblkno(fs, length + fs->lfs_bsize - 1) - 1;
lastblock = lfs_lblkno(fs, length + fs->lfs_bsize - 1) - 1;
lastiblock[SINGLE] = lastblock - ULFS_NDADDR;
lastiblock[DOUBLE] = lastiblock[SINGLE] - NINDIR(fs);
lastiblock[TRIPLE] = lastiblock[DOUBLE] - NINDIR(fs) * NINDIR(fs);
nblocks = btofsb(fs, fs->lfs_bsize);
lastiblock[DOUBLE] = lastiblock[SINGLE] - LFS_NINDIR(fs);
lastiblock[TRIPLE] = lastiblock[DOUBLE] - LFS_NINDIR(fs) * LFS_NINDIR(fs);
nblocks = lfs_btofsb(fs, fs->lfs_bsize);
/*
* Record changed file and block pointers before we start
* freeing blocks. lastiblock values are also normalized to -1
@ -453,8 +453,8 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
* Indirect blocks first.
*/
indir_lbn[SINGLE] = -ULFS_NDADDR;
indir_lbn[DOUBLE] = indir_lbn[SINGLE] - NINDIR(fs) - 1;
indir_lbn[TRIPLE] = indir_lbn[DOUBLE] - NINDIR(fs) * NINDIR(fs) - 1;
indir_lbn[DOUBLE] = indir_lbn[SINGLE] - LFS_NINDIR(fs) - 1;
indir_lbn[TRIPLE] = indir_lbn[DOUBLE] - LFS_NINDIR(fs) * LFS_NINDIR(fs) - 1;
for (level = TRIPLE; level >= SINGLE; level--) {
bn = oip->i_ffs1_ib[level];
if (bn != 0) {
@ -489,15 +489,15 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
bn = oip->i_ffs1_db[i];
if (bn == 0)
continue;
bsize = blksize(fs, oip, i);
bsize = lfs_blksize(fs, oip, i);
if (oip->i_ffs1_db[i] > 0) {
/* Check for fragment size changes */
obsize = oip->i_lfs_fragsize[i];
real_released += btofsb(fs, obsize);
real_released += lfs_btofsb(fs, obsize);
oip->i_lfs_fragsize[i] = 0;
} else
obsize = 0;
blocksreleased += btofsb(fs, bsize);
blocksreleased += lfs_btofsb(fs, bsize);
oip->i_ffs1_db[i] = 0;
lfs_blkfree(fs, oip, bn, obsize, &lastseg, &bc);
lfs_deregister_block(ovp, bn);
@ -520,22 +520,22 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
* Calculate amount of space we're giving
* back as old block size minus new block size.
*/
oldspace = blksize(fs, oip, lastblock);
oldspace = lfs_blksize(fs, oip, lastblock);
#if 0
olddspace = oip->i_lfs_fragsize[lastblock];
#endif
oip->i_size = oip->i_ffs1_size = length;
newspace = blksize(fs, oip, lastblock);
newspace = lfs_blksize(fs, oip, lastblock);
if (newspace == 0)
panic("itrunc: newspace");
if (oldspace - newspace > 0) {
blocksreleased += btofsb(fs, oldspace - newspace);
blocksreleased += lfs_btofsb(fs, oldspace - newspace);
}
#if 0
if (bn > 0 && olddspace - newspace > 0) {
/* No segment accounting here, just vnode */
real_released += btofsb(fs, olddspace - newspace);
real_released += lfs_btofsb(fs, olddspace - newspace);
}
#endif
}
@ -590,10 +590,10 @@ done:
(void) lfs_chkdq(oip, -blocksreleased, NOCRED, 0);
#endif
lfs_reserve(fs, ovp, NULL,
-btofsb(fs, (2 * ULFS_NIADDR + 3) << fs->lfs_bshift));
-lfs_btofsb(fs, (2 * ULFS_NIADDR + 3) << fs->lfs_bshift));
genfs_node_unlock(ovp);
errout:
oip->i_lfs_hiblk = lblkno(fs, oip->i_size + fs->lfs_bsize - 1) - 1;
oip->i_lfs_hiblk = lfs_lblkno(fs, oip->i_size + fs->lfs_bsize - 1) - 1;
if (ovp != fs->lfs_ivnode)
lfs_segunlock(fs);
return (allerror ? allerror : error);
@ -608,9 +608,9 @@ lfs_blkfree(struct lfs *fs, struct inode *ip, daddr_t daddr,
int error = 0;
ASSERT_SEGLOCK(fs);
bsize = fragroundup(fs, bsize);
bsize = lfs_fragroundup(fs, bsize);
if (daddr > 0) {
if (*lastseg != (seg = dtosn(fs, daddr))) {
if (*lastseg != (seg = lfs_dtosn(fs, daddr))) {
error = lfs_update_seguse(fs, ip, *lastseg, *num);
*num = bsize;
*lastseg = seg;
@ -720,11 +720,11 @@ lfs_indirtrunc(struct inode *ip, daddr_t lbn, daddr_t dbn,
*/
factor = 1;
for (i = SINGLE; i < level; i++)
factor *= NINDIR(fs);
factor *= LFS_NINDIR(fs);
last = lastbn;
if (lastbn > 0)
last /= factor;
nblocks = btofsb(fs, fs->lfs_bsize);
nblocks = lfs_btofsb(fs, fs->lfs_bsize);
/*
* Get buffer of block pointers, zero those entries corresponding
* to blocks to be free'd, and update on disk copy first. Since
@ -744,7 +744,7 @@ lfs_indirtrunc(struct inode *ip, daddr_t lbn, daddr_t dbn,
bp->b_flags |= B_READ;
if (bp->b_bcount > bp->b_bufsize)
panic("lfs_indirtrunc: bad buffer size");
bp->b_blkno = fsbtodb(fs, dbn);
bp->b_blkno = LFS_FSBTODB(fs, dbn);
VOP_STRATEGY(vp, bp);
error = biowait(bp);
}
@ -760,7 +760,7 @@ lfs_indirtrunc(struct inode *ip, daddr_t lbn, daddr_t dbn,
memcpy((void *)copy, (void *)bap, (u_int)fs->lfs_bsize);
memset((void *)&bap[last + 1], 0,
/* XXX ondisk32 */
(u_int)(NINDIR(fs) - (last + 1)) * sizeof (int32_t));
(u_int)(LFS_NINDIR(fs) - (last + 1)) * sizeof (int32_t));
error = VOP_BWRITE(bp->b_vp, bp);
if (error)
allerror = error;
@ -770,7 +770,7 @@ lfs_indirtrunc(struct inode *ip, daddr_t lbn, daddr_t dbn,
/*
* Recursively free totally unused blocks.
*/
for (i = NINDIR(fs) - 1, nlbn = lbn + 1 - i * factor; i > last;
for (i = LFS_NINDIR(fs) - 1, nlbn = lbn + 1 - i * factor; i > last;
i--, nlbn += factor) {
nb = bap[i];
if (nb == 0)
@ -814,7 +814,7 @@ lfs_indirtrunc(struct inode *ip, daddr_t lbn, daddr_t dbn,
mutex_enter(&bufcache_lock);
if (bp->b_oflags & BO_DELWRI) {
LFS_UNLOCK_BUF(bp);
fs->lfs_avail += btofsb(fs, bp->b_bcount);
fs->lfs_avail += lfs_btofsb(fs, bp->b_bcount);
wakeup(&fs->lfs_avail);
}
brelsel(bp, BC_INVAL);
@ -866,7 +866,7 @@ restart:
mutex_enter(bp->b_objlock);
if (bp->b_oflags & BO_DELWRI) {
bp->b_oflags &= ~BO_DELWRI;
fs->lfs_avail += btofsb(fs, bp->b_bcount);
fs->lfs_avail += lfs_btofsb(fs, bp->b_bcount);
wakeup(&fs->lfs_avail);
}
mutex_exit(bp->b_objlock);
@ -888,7 +888,7 @@ restart:
mutex_enter(bp->b_objlock);
if (bp->b_oflags & BO_DELWRI) {
bp->b_oflags &= ~BO_DELWRI;
fs->lfs_avail += btofsb(fs, bp->b_bcount);
fs->lfs_avail += lfs_btofsb(fs, bp->b_bcount);
wakeup(&fs->lfs_avail);
}
mutex_exit(bp->b_objlock);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_rfw.c,v 1.16 2013/06/08 02:11:11 dholland Exp $ */
/* $NetBSD: lfs_rfw.c,v 1.17 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_rfw.c,v 1.16 2013/06/08 02:11:11 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_rfw.c,v 1.17 2013/06/18 18:18:58 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@ -239,7 +239,7 @@ update_meta(struct lfs *fs, ino_t ino, int vers, daddr_t lbn,
/* No need to write, the block is already on disk */
if (bp->b_oflags & BO_DELWRI) {
LFS_UNLOCK_BUF(bp);
fs->lfs_avail += btofsb(fs, bp->b_bcount);
fs->lfs_avail += lfs_btofsb(fs, bp->b_bcount);
}
brelse(bp, BC_INVAL);
@ -271,12 +271,12 @@ update_meta(struct lfs *fs, ino_t ino, int vers, daddr_t lbn,
lfs_update_single(fs, NULL, vp, lbn, ndaddr, size);
LFS_SEGENTRY(sup, fs, dtosn(fs, ndaddr), bp);
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, ndaddr), bp);
sup->su_nbytes += size;
LFS_WRITESEGENTRY(sup, fs, dtosn(fs, ndaddr), bp);
LFS_WRITESEGENTRY(sup, fs, lfs_dtosn(fs, ndaddr), bp);
/* differences here should be due to UNWRITTEN indirect blocks. */
KASSERT((lblkno(fs, ip->i_size) > ULFS_NDADDR &&
KASSERT((lfs_lblkno(fs, ip->i_size) > ULFS_NDADDR &&
ip->i_lfs_effnblks == ip->i_ffs1_blocks) ||
ip->i_lfs_effnblks >= ip->i_ffs1_blocks);
@ -287,7 +287,7 @@ update_meta(struct lfs *fs, ino_t ino, int vers, daddr_t lbn,
if (!a[i].in_exists)
panic("update_meta: absent %d lv indirect block", i);
}
if (dbtofsb(fs, odaddr) != ndaddr)
if (LFS_DBTOFSB(fs, odaddr) != ndaddr)
DLOG((DLOG_RF, "update_meta: failed setting ino %d lbn %"
PRId64 " to %" PRId64 "\n", ino, lbn, ndaddr));
#endif /* DEBUG */
@ -314,13 +314,13 @@ 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, fsbtodb(fs, offset), fs->lfs_ibsize,
error = bread(devvp, LFS_FSBTODB(fs, offset), fs->lfs_ibsize,
cred, 0, &dbp);
if (error) {
DLOG((DLOG_RF, "update_inoblk: bread returned %d\n", error));
return error;
}
dip = ((struct ulfs1_dinode *)(dbp->b_data)) + INOPB(fs);
dip = ((struct ulfs1_dinode *)(dbp->b_data)) + LFS_INOPB(fs);
while (--dip >= (struct ulfs1_dinode *)dbp->b_data) {
if (dip->di_inumber > LFS_IFILE_INUM) {
error = lfs_rf_valloc(fs, dip->di_inumber, dip->di_gen,
@ -357,23 +357,23 @@ update_inoblk(struct lfs *fs, daddr_t offset, kauth_cred_t cred,
/* Record change in location */
LFS_IENTRY(ifp, fs, dip->di_inumber, ibp);
daddr = ifp->if_daddr;
ifp->if_daddr = dbtofsb(fs, dbp->b_blkno);
ifp->if_daddr = LFS_DBTOFSB(fs, dbp->b_blkno);
error = LFS_BWRITE_LOG(ibp); /* Ifile */
/* And do segment accounting */
if (dtosn(fs, daddr) != dtosn(fs, dbtofsb(fs, dbp->b_blkno))) {
if (lfs_dtosn(fs, daddr) != lfs_dtosn(fs, LFS_DBTOFSB(fs, dbp->b_blkno))) {
if (daddr > 0) {
LFS_SEGENTRY(sup, fs, dtosn(fs, daddr),
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, daddr),
ibp);
sup->su_nbytes -= sizeof (struct ulfs1_dinode);
LFS_WRITESEGENTRY(sup, fs,
dtosn(fs, daddr),
lfs_dtosn(fs, daddr),
ibp);
}
LFS_SEGENTRY(sup, fs, dtosn(fs, dbtofsb(fs, dbp->b_blkno)),
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, LFS_DBTOFSB(fs, dbp->b_blkno)),
ibp);
sup->su_nbytes += sizeof (struct ulfs1_dinode);
LFS_WRITESEGENTRY(sup, fs,
dtosn(fs, dbtofsb(fs, dbp->b_blkno)),
lfs_dtosn(fs, LFS_DBTOFSB(fs, dbp->b_blkno)),
ibp);
}
}
@ -406,15 +406,15 @@ check_segsum(struct lfs *fs, daddr_t offset, u_int64_t nextserial,
* If the segment has a superblock and we're at the top
* of the segment, skip the superblock.
*/
if (sntod(fs, dtosn(fs, offset)) == offset) {
LFS_SEGENTRY(sup, fs, dtosn(fs, offset), bp);
if (lfs_sntod(fs, lfs_dtosn(fs, offset)) == offset) {
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, offset), bp);
if (sup->su_flags & SEGUSE_SUPERBLOCK)
offset += btofsb(fs, LFS_SBPAD);
offset += lfs_btofsb(fs, LFS_SBPAD);
brelse(bp, 0);
}
/* Read in the segment summary */
error = bread(devvp, fsbtodb(fs, offset), fs->lfs_sumsize,
error = bread(devvp, LFS_FSBTODB(fs, offset), fs->lfs_sumsize,
cred, 0, &bp);
if (error)
return -1;
@ -457,9 +457,9 @@ check_segsum(struct lfs *fs, daddr_t offset, u_int64_t nextserial,
if (pseg_flags)
*pseg_flags = ssp->ss_flags;
oldoffset = offset;
offset += btofsb(fs, fs->lfs_sumsize);
offset += lfs_btofsb(fs, fs->lfs_sumsize);
ninos = howmany(ssp->ss_ninos, INOPB(fs));
ninos = howmany(ssp->ss_ninos, LFS_INOPB(fs));
/* XXX ondisk32 */
iaddr = (int32_t *)((char*)bp->b_data + fs->lfs_sumsize - sizeof(int32_t));
if (flags & CHECK_CKSUM) {
@ -487,7 +487,7 @@ check_segsum(struct lfs *fs, daddr_t offset, u_int64_t nextserial,
if (ninos && *iaddr == offset) {
if (flags & CHECK_CKSUM) {
/* Read in the head and add to the buffer */
error = bread(devvp, fsbtodb(fs, offset), fs->lfs_bsize,
error = bread(devvp, LFS_FSBTODB(fs, offset), fs->lfs_bsize,
cred, 0, &dbp);
if (error) {
offset = -1;
@ -503,7 +503,7 @@ check_segsum(struct lfs *fs, daddr_t offset, u_int64_t nextserial,
goto err2;
}
}
offset += btofsb(fs, fs->lfs_ibsize);
offset += lfs_btofsb(fs, fs->lfs_ibsize);
--iaddr;
--ninos;
--i; /* compensate */
@ -514,7 +514,7 @@ check_segsum(struct lfs *fs, daddr_t offset, u_int64_t nextserial,
if (j == fip->fi_nblocks - 1)
size = fip->fi_lastlength;
if (flags & CHECK_CKSUM) {
error = bread(devvp, fsbtodb(fs, offset), size,
error = bread(devvp, LFS_FSBTODB(fs, offset), size,
cred, 0, &dbp);
if (error) {
offset = -1;
@ -530,7 +530,7 @@ check_segsum(struct lfs *fs, daddr_t offset, u_int64_t nextserial,
update_meta(fs, fip->fi_ino, fip->fi_version,
fip->fi_blocks[j], offset, size, l);
}
offset += btofsb(fs, size);
offset += lfs_btofsb(fs, size);
}
/* XXX ondisk32 */
fip = (FINFO *)(((char *)fip) + FINFOSIZE
@ -549,15 +549,15 @@ 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 (dtosn(fs, offset + btofsb(fs, fs->lfs_sumsize + fs->lfs_bsize)) !=
dtosn(fs, offset)) {
if (dtosn(fs, offset) == dtosn(fs, ssp->ss_next)) {
if (lfs_dtosn(fs, offset + lfs_btofsb(fs, fs->lfs_sumsize + fs->lfs_bsize)) !=
lfs_dtosn(fs, offset)) {
if (lfs_dtosn(fs, offset) == lfs_dtosn(fs, ssp->ss_next)) {
offset = -1;
goto err2;
}
offset = ssp->ss_next;
DLOG((DLOG_RF, "LFS roll forward: moving to offset 0x%" PRIx64
" -> segment %d\n", offset, dtosn(fs,offset)));
" -> segment %d\n", offset, lfs_dtosn(fs,offset)));
}
if (flags & CHECK_UPDATE) {
@ -621,22 +621,22 @@ lfs_roll_forward(struct lfs *fs, struct mount *mp, struct lwp *l)
flags = 0x0;
DLOG((DLOG_RF, "LFS roll forward phase 1: start at offset 0x%"
PRIx64 "\n", offset));
LFS_SEGENTRY(sup, fs, dtosn(fs, offset), bp);
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, offset), bp);
if (!(sup->su_flags & SEGUSE_DIRTY))
--fs->lfs_nclean;
sup->su_flags |= SEGUSE_DIRTY;
LFS_WRITESEGENTRY(sup, fs, dtosn(fs, offset), bp);
LFS_WRITESEGENTRY(sup, fs, lfs_dtosn(fs, offset), bp);
nextserial = fs->lfs_serial + 1;
while ((offset = check_segsum(fs, offset, nextserial,
cred, CHECK_CKSUM, &flags, l)) > 0) {
nextserial++;
if (sntod(fs, oldoffset) != sntod(fs, offset)) {
LFS_SEGENTRY(sup, fs, dtosn(fs, oldoffset),
if (lfs_sntod(fs, oldoffset) != lfs_sntod(fs, offset)) {
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, oldoffset),
bp);
if (!(sup->su_flags & SEGUSE_DIRTY))
--fs->lfs_nclean;
sup->su_flags |= SEGUSE_DIRTY;
LFS_WRITESEGENTRY(sup, fs, dtosn(fs, oldoffset),
LFS_WRITESEGENTRY(sup, fs, lfs_dtosn(fs, oldoffset),
bp);
}
@ -665,8 +665,8 @@ lfs_roll_forward(struct lfs *fs, struct mount *mp, struct lwp *l)
/* Don't overwrite what we're trying to preserve */
offset = fs->lfs_offset;
fs->lfs_offset = lastgoodpseg;
fs->lfs_curseg = sntod(fs, dtosn(fs, fs->lfs_offset));
for (sn = curseg = dtosn(fs, fs->lfs_curseg);;) {
fs->lfs_curseg = lfs_sntod(fs, lfs_dtosn(fs, fs->lfs_offset));
for (sn = curseg = lfs_dtosn(fs, fs->lfs_curseg);;) {
sn = (sn + 1) % fs->lfs_nseg;
if (sn == curseg)
panic("lfs_mountfs: no clean segments");
@ -676,7 +676,7 @@ lfs_roll_forward(struct lfs *fs, struct mount *mp, struct lwp *l)
if (!dirty)
break;
}
fs->lfs_nextseg = sntod(fs, sn);
fs->lfs_nextseg = lfs_sntod(fs, sn);
/*
* Phase II: Roll forward from the first superblock.

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_segment.c,v 1.229 2013/06/08 22:23:52 dholland Exp $ */
/* $NetBSD: lfs_segment.c,v 1.230 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.229 2013/06/08 22:23:52 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.230 2013/06/18 18:18:58 christos Exp $");
#ifdef DEBUG
# define vndebug(vp, str) do { \
@ -232,15 +232,15 @@ lfs_vflush(struct vnode *vp)
struct vm_page *pg;
voff_t off;
for (off = lblktosize(fs, bp->b_lblkno);
off < lblktosize(fs, bp->b_lblkno + 1);
for (off = lfs_lblktosize(fs, bp->b_lblkno);
off < lfs_lblktosize(fs, bp->b_lblkno + 1);
off += PAGE_SIZE) {
pg = uvm_pagelookup(&vp->v_uobj, off);
if (pg == NULL)
continue;
if ((pg->flags & PG_CLEAN) == 0 ||
pmap_is_modified(pg)) {
fs->lfs_avail += btofsb(fs,
fs->lfs_avail += lfs_btofsb(fs,
bp->b_bcount);
wakeup(&fs->lfs_avail);
mutex_exit(vp->v_interlock);
@ -259,7 +259,7 @@ lfs_vflush(struct vnode *vp)
&& tbp->b_lblkno == bp->b_lblkno
&& tbp != bp)
{
fs->lfs_avail += btofsb(fs,
fs->lfs_avail += lfs_btofsb(fs,
bp->b_bcount);
wakeup(&fs->lfs_avail);
mutex_exit(vp->v_interlock);
@ -305,7 +305,7 @@ lfs_vflush(struct vnode *vp)
KASSERT((bp->b_flags & B_GATHERED) == 0);
if (bp->b_oflags & BO_DELWRI) { /* XXX always true? */
fs->lfs_avail += btofsb(fs, bp->b_bcount);
fs->lfs_avail += lfs_btofsb(fs, bp->b_bcount);
wakeup(&fs->lfs_avail);
}
/* Copied from lfs_writeseg */
@ -704,7 +704,7 @@ lfs_segwrite(struct mount *mp, int flags)
maxseg = min(segleft, fs->lfs_sepb);
for (i = 0; i < maxseg; i++) {
sn = curseg + i;
if (sn != dtosn(fs, fs->lfs_curseg) &&
if (sn != lfs_dtosn(fs, fs->lfs_curseg) &&
segusep->su_flags & SEGUSE_ACTIVE) {
segusep->su_flags &= ~SEGUSE_ACTIVE;
--fs->lfs_nactive;
@ -951,11 +951,11 @@ lfs_update_iaddr(struct lfs *fs, struct segment *sp, struct inode *ip, daddr_t n
ino = ip->i_number;
if (ino == LFS_IFILE_INUM) {
daddr = fs->lfs_idaddr;
fs->lfs_idaddr = dbtofsb(fs, ndaddr);
fs->lfs_idaddr = LFS_DBTOFSB(fs, ndaddr);
} else {
LFS_IENTRY(ifp, fs, ino, bp);
daddr = ifp->if_daddr;
ifp->if_daddr = dbtofsb(fs, ndaddr);
ifp->if_daddr = LFS_DBTOFSB(fs, ndaddr);
error = LFS_BWRITE_LOG(bp); /* Ifile */
}
@ -965,8 +965,8 @@ lfs_update_iaddr(struct lfs *fs, struct segment *sp, struct inode *ip, daddr_t n
* (XXX should already be dirty?) and tell the caller to do it again.
*/
if (ip->i_number == LFS_IFILE_INUM) {
sn = dtosn(fs, fs->lfs_offset);
if (sntod(fs, sn) + btofsb(fs, fs->lfs_sumsize) ==
sn = lfs_dtosn(fs, fs->lfs_offset);
if (lfs_sntod(fs, sn) + lfs_btofsb(fs, fs->lfs_sumsize) ==
fs->lfs_offset) {
LFS_SEGENTRY(sup, fs, sn, bp);
KASSERT(bp->b_oflags & BO_DELWRI);
@ -998,7 +998,7 @@ lfs_update_iaddr(struct lfs *fs, struct segment *sp, struct inode *ip, daddr_t n
* is actually written.
*/
if (daddr != LFS_UNUSED_DADDR) {
u_int32_t oldsn = dtosn(fs, daddr);
u_int32_t oldsn = lfs_dtosn(fs, daddr);
#ifdef DIAGNOSTIC
int ndupino = (sp->seg_number == oldsn) ? sp->ndupino : 0;
#endif
@ -1012,7 +1012,7 @@ lfs_update_iaddr(struct lfs *fs, struct segment *sp, struct inode *ip, daddr_t n
"oldsn=%" PRIu32 ", cursn=%" PRIu32
", daddr=%" PRId64 ", su_nbytes=%u, "
"ndupino=%d)\n",
dtosn(fs, daddr),
lfs_dtosn(fs, daddr),
(int)sizeof (struct ulfs1_dinode) *
(1 - sp->ndupino) - sup->su_nbytes,
oldsn, sp->seg_number, daddr,
@ -1023,7 +1023,7 @@ lfs_update_iaddr(struct lfs *fs, struct segment *sp, struct inode *ip, daddr_t n
}
#endif
DLOG((DLOG_SU, "seg %d -= %d for ino %d inode\n",
dtosn(fs, daddr), sizeof (struct ulfs1_dinode), ino));
lfs_dtosn(fs, daddr), sizeof (struct ulfs1_dinode), ino));
sup->su_nbytes -= sizeof (struct ulfs1_dinode);
redo_ifile |=
(ino == LFS_IFILE_INUM && !(bp->b_flags & B_GATHERED));
@ -1111,24 +1111,24 @@ lfs_writeinode(struct lfs *fs, struct segment *sp, struct inode *ip)
/* Get next inode block. */
daddr = fs->lfs_offset;
fs->lfs_offset += btofsb(fs, fs->lfs_ibsize);
fs->lfs_offset += lfs_btofsb(fs, fs->lfs_ibsize);
sp->ibp = *sp->cbpp++ =
getblk(VTOI(fs->lfs_ivnode)->i_devvp,
fsbtodb(fs, daddr), fs->lfs_ibsize, 0, 0);
LFS_FSBTODB(fs, daddr), fs->lfs_ibsize, 0, 0);
gotblk++;
/* Zero out inode numbers */
for (i = 0; i < INOPB(fs); ++i)
for (i = 0; i < LFS_INOPB(fs); ++i)
((struct ulfs1_dinode *)sp->ibp->b_data)[i].di_inumber =
0;
++sp->start_bpp;
fs->lfs_avail -= btofsb(fs, fs->lfs_ibsize);
fs->lfs_avail -= lfs_btofsb(fs, fs->lfs_ibsize);
/* Set remaining space counters. */
sp->seg_bytes_left -= fs->lfs_ibsize;
sp->sum_bytes_left -= sizeof(int32_t);
ndx = fs->lfs_sumsize / sizeof(int32_t) -
sp->ninodes / INOPB(fs) - 1;
sp->ninodes / LFS_INOPB(fs) - 1;
((int32_t *)(sp->segsum))[ndx] = daddr;
}
@ -1156,7 +1156,7 @@ lfs_writeinode(struct lfs *fs, struct segment *sp, struct inode *ip)
}
bp = sp->ibp;
cdp = ((struct ulfs1_dinode *)bp->b_data) + (sp->ninodes % INOPB(fs));
cdp = ((struct ulfs1_dinode *)bp->b_data) + (sp->ninodes % LFS_INOPB(fs));
*cdp = *ip->i_din.ffs1_din;
/*
@ -1267,7 +1267,7 @@ lfs_writeinode(struct lfs *fs, struct segment *sp, struct inode *ip)
if (ip->i_number == LFS_IFILE_INUM) {
/* We know sp->idp == NULL */
sp->idp = ((struct ulfs1_dinode *)bp->b_data) +
(sp->ninodes % INOPB(fs));
(sp->ninodes % LFS_INOPB(fs));
/* Not dirty any more */
mutex_enter(&lfs_lock);
@ -1286,7 +1286,7 @@ lfs_writeinode(struct lfs *fs, struct segment *sp, struct inode *ip)
++((SEGSUM *)(sp->segsum))->ss_ninos;
/* If this page is full, set flag to allocate a new page. */
if (++sp->ninodes % INOPB(fs) == 0)
if (++sp->ninodes % LFS_INOPB(fs) == 0)
sp->ibp = NULL;
redo_ifile = lfs_update_iaddr(fs, sp, ip, bp->b_blkno);
@ -1415,7 +1415,7 @@ loop:
DLOG((DLOG_SEG, "lfs_gather: lbn %" PRId64
" blk %" PRId64 " not B_LOCKED\n",
bp->b_lblkno,
dbtofsb(fs, bp->b_blkno)));
LFS_DBTOFSB(fs, bp->b_blkno)));
VOP_PRINT(bp->b_vp);
panic("lfs_gather: bp not B_LOCKED");
}
@ -1476,9 +1476,9 @@ lfs_update_single(struct lfs *fs, struct segment *sp,
daddr = (daddr_t)((int32_t)daddr); /* XXX ondisk32 */
KASSERT(daddr <= LFS_MAX_DADDR);
if (daddr > 0)
daddr = dbtofsb(fs, daddr);
daddr = LFS_DBTOFSB(fs, daddr);
bb = numfrags(fs, size);
bb = lfs_numfrags(fs, size);
switch (num) {
case 0:
ooff = ip->i_ffs1_db[lbn];
@ -1487,7 +1487,7 @@ lfs_update_single(struct lfs *fs, struct segment *sp,
ip->i_ffs1_blocks += bb;
else {
/* possible fragment truncation or extension */
obb = btofsb(fs, ip->i_lfs_fragsize[lbn]);
obb = lfs_btofsb(fs, ip->i_lfs_fragsize[lbn]);
ip->i_ffs1_blocks += (bb - obb);
}
ip->i_ffs1_db[lbn] = ndaddr;
@ -1533,7 +1533,7 @@ lfs_update_single(struct lfs *fs, struct segment *sp,
* and location.
*/
if (daddr > 0) {
u_int32_t oldsn = dtosn(fs, daddr);
u_int32_t oldsn = lfs_dtosn(fs, daddr);
#ifdef DIAGNOSTIC
int ndupino;
@ -1554,7 +1554,7 @@ lfs_update_single(struct lfs *fs, struct segment *sp,
< osize) {
printf("lfs_updatemeta: negative bytes "
"(segment %" PRIu32 " short by %" PRId64
")\n", dtosn(fs, daddr),
")\n", lfs_dtosn(fs, daddr),
(int64_t)osize -
(sizeof (struct ulfs1_dinode) * ndupino +
sup->su_nbytes));
@ -1569,7 +1569,7 @@ lfs_update_single(struct lfs *fs, struct segment *sp,
#endif
DLOG((DLOG_SU, "seg %" PRIu32 " -= %d for ino %d lbn %" PRId64
" db 0x%" PRIx64 "\n",
dtosn(fs, daddr), osize,
lfs_dtosn(fs, daddr), osize,
ip->i_number, lbn, daddr));
sup->su_nbytes -= osize;
if (!(bp->b_flags & B_GATHERED)) {
@ -1664,7 +1664,7 @@ lfs_updatemeta(struct segment *sp)
lbn = *sp->start_lbp;
KASSERT(sbp->b_lblkno == lbn);
sbp->b_blkno = fsbtodb(fs, fs->lfs_offset);
sbp->b_blkno = LFS_FSBTODB(fs, fs->lfs_offset);
/*
* If we write a frag in the wrong place, the cleaner won't
@ -1685,7 +1685,7 @@ lfs_updatemeta(struct segment *sp)
for (bytesleft = sbp->b_bcount; bytesleft > 0;
bytesleft -= fs->lfs_bsize) {
size = MIN(bytesleft, fs->lfs_bsize);
bb = numfrags(fs, size);
bb = lfs_numfrags(fs, size);
lbn = *sp->start_lbp++;
lfs_update_single(fs, sp, sp->vp, lbn, fs->lfs_offset,
size);
@ -1710,7 +1710,7 @@ lfs_rewind(struct lfs *fs, int newsn)
ASSERT_SEGLOCK(fs);
osn = dtosn(fs, fs->lfs_offset);
osn = lfs_dtosn(fs, fs->lfs_offset);
if (osn < newsn)
return 0;
@ -1766,8 +1766,8 @@ lfs_initseg(struct lfs *fs)
repeat = 1;
fs->lfs_offset = fs->lfs_curseg;
sp->seg_number = dtosn(fs, fs->lfs_curseg);
sp->seg_bytes_left = fsbtob(fs, fs->lfs_fsbpseg);
sp->seg_number = lfs_dtosn(fs, fs->lfs_curseg);
sp->seg_bytes_left = lfs_fsbtob(fs, fs->lfs_fsbpseg);
/*
* If the segment contains a superblock, update the offset
@ -1775,21 +1775,21 @@ lfs_initseg(struct lfs *fs)
*/
LFS_SEGENTRY(sup, fs, sp->seg_number, bp);
if (sup->su_flags & SEGUSE_SUPERBLOCK) {
fs->lfs_offset += btofsb(fs, LFS_SBPAD);
fs->lfs_offset += lfs_btofsb(fs, LFS_SBPAD);
sp->seg_bytes_left -= LFS_SBPAD;
}
brelse(bp, 0);
/* Segment zero could also contain the labelpad */
if (fs->lfs_version > 1 && sp->seg_number == 0 &&
fs->lfs_start < btofsb(fs, LFS_LABELPAD)) {
fs->lfs_start < lfs_btofsb(fs, LFS_LABELPAD)) {
fs->lfs_offset +=
btofsb(fs, LFS_LABELPAD) - fs->lfs_start;
lfs_btofsb(fs, LFS_LABELPAD) - fs->lfs_start;
sp->seg_bytes_left -=
LFS_LABELPAD - fsbtob(fs, fs->lfs_start);
LFS_LABELPAD - lfs_fsbtob(fs, fs->lfs_start);
}
} else {
sp->seg_number = dtosn(fs, fs->lfs_curseg);
sp->seg_bytes_left = fsbtob(fs, fs->lfs_fsbpseg -
sp->seg_number = lfs_dtosn(fs, fs->lfs_curseg);
sp->seg_bytes_left = lfs_fsbtob(fs, fs->lfs_fsbpseg -
(fs->lfs_offset - fs->lfs_curseg));
}
fs->lfs_lastpseg = fs->lfs_offset;
@ -1819,12 +1819,12 @@ lfs_initseg(struct lfs *fs)
/* Get a new buffer for SEGSUM */
sbp = lfs_newbuf(fs, VTOI(fs->lfs_ivnode)->i_devvp,
fsbtodb(fs, fs->lfs_offset), fs->lfs_sumsize, LFS_NB_SUMMARY);
LFS_FSBTODB(fs, fs->lfs_offset), fs->lfs_sumsize, LFS_NB_SUMMARY);
/* ... and enter it into the buffer list. */
*sp->cbpp = sbp;
sp->cbpp++;
fs->lfs_offset += btofsb(fs, fs->lfs_sumsize);
fs->lfs_offset += lfs_btofsb(fs, fs->lfs_sumsize);
sp->start_bpp = sp->cbpp;
@ -1898,14 +1898,14 @@ lfs_newseg(struct lfs *fs)
fs->lfs_wrapstatus = LFS_WRAP_GOING;
mutex_exit(&lfs_lock);
LFS_SEGENTRY(sup, fs, dtosn(fs, fs->lfs_nextseg), bp);
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, fs->lfs_nextseg), bp);
DLOG((DLOG_SU, "lfs_newseg: seg %d := 0 in newseg\n",
dtosn(fs, fs->lfs_nextseg)));
lfs_dtosn(fs, fs->lfs_nextseg)));
sup->su_flags |= SEGUSE_DIRTY | SEGUSE_ACTIVE;
sup->su_nbytes = 0;
sup->su_nsums = 0;
sup->su_ninos = 0;
LFS_WRITESEGENTRY(sup, fs, dtosn(fs, fs->lfs_nextseg), bp);
LFS_WRITESEGENTRY(sup, fs, lfs_dtosn(fs, fs->lfs_nextseg), bp);
LFS_CLEANERINFO(cip, fs, bp);
--cip->clean;
@ -1916,7 +1916,7 @@ lfs_newseg(struct lfs *fs)
fs->lfs_lastseg = fs->lfs_curseg;
fs->lfs_curseg = fs->lfs_nextseg;
skip_inval = 1;
for (sn = curseg = dtosn(fs, fs->lfs_curseg) + fs->lfs_interleave;;) {
for (sn = curseg = lfs_dtosn(fs, fs->lfs_curseg) + fs->lfs_interleave;;) {
sn = (sn + 1) % fs->lfs_nseg;
if (sn == curseg) {
@ -1941,7 +1941,7 @@ lfs_newseg(struct lfs *fs)
lfs_unset_inval_all(fs);
++fs->lfs_nactive;
fs->lfs_nextseg = sntod(fs, sn);
fs->lfs_nextseg = lfs_sntod(fs, sn);
if (lfs_dostats) {
++lfs_stats.segsused;
}
@ -2055,7 +2055,7 @@ lfs_writeseg(struct lfs *fs, struct segment *sp)
}
#endif /* DEBUG */
ninos = (ssp->ss_ninos + INOPB(fs) - 1) / INOPB(fs);
ninos = (ssp->ss_ninos + LFS_INOPB(fs) - 1) / LFS_INOPB(fs);
DLOG((DLOG_SU, "seg %d += %d for %d inodes\n",
sp->seg_number, ssp->ss_ninos * sizeof (struct ulfs1_dinode),
ssp->ss_ninos));
@ -2067,7 +2067,7 @@ lfs_writeseg(struct lfs *fs, struct segment *sp)
sup->su_lastmod = time_second;
sup->su_ninos += ninos;
++sup->su_nsums;
fs->lfs_avail -= btofsb(fs, fs->lfs_sumsize);
fs->lfs_avail -= lfs_btofsb(fs, fs->lfs_sumsize);
do_again = !(bp->b_flags & B_GATHERED);
LFS_WRITESEGENTRY(sup, fs, sp->seg_number, bp); /* Ifile */
@ -2155,7 +2155,7 @@ lfs_writeseg(struct lfs *fs, struct segment *sp)
* segment.
*/
fs->lfs_avail -=
btofsb(fs, bp->b_bcount);
lfs_btofsb(fs, bp->b_bcount);
}
} else {
lfs_freebuf(fs, newbp);
@ -2215,10 +2215,10 @@ lfs_writeseg(struct lfs *fs, struct segment *sp)
fs->lfs_sumsize - sizeof(ssp->ss_sumsum));
mutex_enter(&lfs_lock);
fs->lfs_bfree -= (btofsb(fs, ninos * fs->lfs_ibsize) +
btofsb(fs, fs->lfs_sumsize));
fs->lfs_dmeta += (btofsb(fs, ninos * fs->lfs_ibsize) +
btofsb(fs, fs->lfs_sumsize));
fs->lfs_bfree -= (lfs_btofsb(fs, ninos * fs->lfs_ibsize) +
lfs_btofsb(fs, fs->lfs_sumsize));
fs->lfs_dmeta += (lfs_btofsb(fs, ninos * fs->lfs_ibsize) +
lfs_btofsb(fs, fs->lfs_sumsize));
mutex_exit(&lfs_lock);
/*
@ -2248,7 +2248,7 @@ lfs_writeseg(struct lfs *fs, struct segment *sp)
/ sizeof(int32_t)) {
panic("lfs_writeseg: real bpp overwrite");
}
if (bpp - sp->bpp > segsize(fs) / fs->lfs_fsize) {
if (bpp - sp->bpp > lfs_segsize(fs) / fs->lfs_fsize) {
panic("lfs_writeseg: theoretical bpp overwrite");
}
#endif
@ -2281,7 +2281,7 @@ lfs_writeseg(struct lfs *fs, struct segment *sp)
cl->flags |= LFS_CL_MALLOC;
}
#ifdef DIAGNOSTIC
if (dtosn(fs, dbtofsb(fs, bp->b_blkno +
if (lfs_dtosn(fs, LFS_DBTOFSB(fs, bp->b_blkno +
btodb(bp->b_bcount - 1))) !=
sp->seg_number) {
printf("blk size %d daddr %" PRIx64
@ -2390,7 +2390,7 @@ lfs_writesuper(struct lfs *fs, daddr_t daddr)
/* Checksum the superblock and copy it into a buffer. */
fs->lfs_cksum = lfs_sb_cksum(&(fs->lfs_dlfs));
bp = lfs_newbuf(fs, devvp,
fsbtodb(fs, daddr), LFS_SBPAD, LFS_NB_SBLOCK);
LFS_FSBTODB(fs, daddr), LFS_SBPAD, LFS_NB_SBLOCK);
memset((char *)bp->b_data + sizeof(struct dlfs), 0,
LFS_SBPAD - sizeof(struct dlfs));
*(struct dlfs *)bp->b_data = fs->lfs_dlfs;
@ -2454,7 +2454,7 @@ lfs_match_indir(struct lfs *fs, struct buf *bp)
ASSERT_SEGLOCK(fs);
lbn = bp->b_lblkno;
return (lbn < 0 && (-lbn - ULFS_NDADDR) % NINDIR(fs) == 0);
return (lbn < 0 && (-lbn - ULFS_NDADDR) % LFS_NINDIR(fs) == 0);
}
int
@ -2464,7 +2464,7 @@ lfs_match_dindir(struct lfs *fs, struct buf *bp)
ASSERT_SEGLOCK(fs);
lbn = bp->b_lblkno;
return (lbn < 0 && (-lbn - ULFS_NDADDR) % NINDIR(fs) == 1);
return (lbn < 0 && (-lbn - ULFS_NDADDR) % LFS_NINDIR(fs) == 1);
}
int
@ -2474,7 +2474,7 @@ lfs_match_tindir(struct lfs *fs, struct buf *bp)
ASSERT_SEGLOCK(fs);
lbn = bp->b_lblkno;
return (lbn < 0 && (-lbn - ULFS_NDADDR) % NINDIR(fs) == 2);
return (lbn < 0 && (-lbn - ULFS_NDADDR) % LFS_NINDIR(fs) == 2);
}
static void

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_subr.c,v 1.78 2013/06/06 00:44:40 dholland Exp $ */
/* $NetBSD: lfs_subr.c,v 1.79 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.78 2013/06/06 00:44:40 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.79 2013/06/18 18:18:58 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -144,7 +144,7 @@ lfs_setup_resblks(struct lfs *fs)
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 = MIN(maxbpp, segsize(fs) / fs->lfs_fsize + 2);
maxbpp = MIN(maxbpp, lfs_segsize(fs) / fs->lfs_fsize + 2);
pool_init(&fs->lfs_bpppool, maxbpp * sizeof(struct buf *), 0, 0, 0,
"lfsbpppl", &pool_allocator_nointr, IPL_NONE);
}
@ -449,7 +449,7 @@ lfs_segunlock(struct lfs *fs)
KASSERT(sp->cbpp == sp->bpp + 1);
/* Free allocated segment summary */
fs->lfs_offset -= btofsb(fs, fs->lfs_sumsize);
fs->lfs_offset -= lfs_btofsb(fs, fs->lfs_sumsize);
bp = *sp->bpp;
lfs_freebuf(fs, bp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_syscalls.c,v 1.146 2013/06/06 00:48:04 dholland Exp $ */
/* $NetBSD: lfs_syscalls.c,v 1.147 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007, 2008
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.146 2013/06/06 00:48:04 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.147 2013/06/18 18:18:58 christos Exp $");
#ifndef LFS
# define LFS /* for prototypes in syscallargs.h */
@ -249,7 +249,7 @@ lfs_markv(struct proc *p, fsid_t *fsidp, BLOCK_INFO *blkiov,
if (fs->lfs_ronly)
return EROFS;
maxino = (fragstoblks(fs, VTOI(fs->lfs_ivnode)->i_ffs1_blocks) -
maxino = (lfs_fragstoblks(fs, VTOI(fs->lfs_ivnode)->i_ffs1_blocks) -
fs->lfs_cleansz - fs->lfs_segtabsz) * fs->lfs_ifpb;
cnt = blkcnt;
@ -325,7 +325,7 @@ lfs_markv(struct proc *p, fsid_t *fsidp, BLOCK_INFO *blkiov,
DLOG((DLOG_CLEAN, "lfs_markv: lfs_fastvget"
" failed with %d (ino %d, segment %d)\n",
error, blkp->bi_inode,
dtosn(fs, blkp->bi_daddr)));
lfs_dtosn(fs, blkp->bi_daddr)));
/*
* If we got EAGAIN, that means that the
* Inode was locked. This is
@ -391,13 +391,13 @@ lfs_markv(struct proc *p, fsid_t *fsidp, BLOCK_INFO *blkiov,
b_daddr = 0;
if (VOP_BMAP(vp, blkp->bi_lbn, NULL, &b_daddr, NULL) ||
dbtofsb(fs, b_daddr) != blkp->bi_daddr)
LFS_DBTOFSB(fs, b_daddr) != blkp->bi_daddr)
{
if (dtosn(fs, dbtofsb(fs, b_daddr)) ==
dtosn(fs, blkp->bi_daddr))
if (lfs_dtosn(fs, LFS_DBTOFSB(fs, b_daddr)) ==
lfs_dtosn(fs, blkp->bi_daddr))
{
DLOG((DLOG_CLEAN, "lfs_markv: wrong da same seg: %llx vs %llx\n",
(long long)blkp->bi_daddr, (long long)dbtofsb(fs, b_daddr)));
(long long)blkp->bi_daddr, (long long)LFS_DBTOFSB(fs, b_daddr)));
}
do_again++;
continue;
@ -409,7 +409,7 @@ lfs_markv(struct proc *p, fsid_t *fsidp, BLOCK_INFO *blkiov,
* counterparts.
*/
if (blkp->bi_lbn >= 0)
obsize = blksize(fs, ip, blkp->bi_lbn);
obsize = lfs_blksize(fs, ip, blkp->bi_lbn);
else
obsize = fs->lfs_bsize;
/* Check for fragment size change */
@ -438,7 +438,7 @@ lfs_markv(struct proc *p, fsid_t *fsidp, BLOCK_INFO *blkiov,
bp = lfs_fakebuf(fs, vp, blkp->bi_lbn,
blkp->bi_size, blkp->bi_bp);
/* Pretend we used bread() to get it */
bp->b_blkno = fsbtodb(fs, blkp->bi_daddr);
bp->b_blkno = LFS_FSBTODB(fs, blkp->bi_daddr);
} else {
/* Indirect block or ifile */
if (blkp->bi_size != fs->lfs_bsize &&
@ -471,7 +471,7 @@ lfs_markv(struct proc *p, fsid_t *fsidp, BLOCK_INFO *blkiov,
/*
* XXX should account indirect blocks and ifile pages as well
*/
if (nblkwritten + lblkno(fs, ninowritten * sizeof (struct ulfs1_dinode))
if (nblkwritten + lfs_lblkno(fs, ninowritten * sizeof (struct ulfs1_dinode))
> LFS_MARKV_MAX_BLOCKS) {
DLOG((DLOG_CLEAN, "lfs_markv: writing %d blks %d inos\n",
nblkwritten, ninowritten));
@ -806,10 +806,10 @@ lfs_bmapv(struct proc *p, fsid_t *fsidp, BLOCK_INFO *blkiov, int blkcnt)
blkp->bi_daddr = LFS_UNUSED_DADDR;
continue;
}
blkp->bi_daddr = dbtofsb(fs, bi_daddr);
blkp->bi_daddr = LFS_DBTOFSB(fs, bi_daddr);
/* Fill in the block size, too */
if (blkp->bi_lbn >= 0)
blkp->bi_size = blksize(fs, ip, blkp->bi_lbn);
blkp->bi_size = lfs_blksize(fs, ip, blkp->bi_lbn);
else
blkp->bi_size = fs->lfs_bsize;
}
@ -895,7 +895,7 @@ lfs_do_segclean(struct lfs *fs, unsigned long segnum)
CLEANERINFO *cip;
SEGUSE *sup;
if (dtosn(fs, fs->lfs_curseg) == segnum) {
if (lfs_dtosn(fs, fs->lfs_curseg) == segnum) {
return (EBUSY);
}
@ -919,17 +919,17 @@ lfs_do_segclean(struct lfs *fs, unsigned long segnum)
return (EALREADY);
}
fs->lfs_avail += segtod(fs, 1);
fs->lfs_avail += lfs_segtod(fs, 1);
if (sup->su_flags & SEGUSE_SUPERBLOCK)
fs->lfs_avail -= btofsb(fs, LFS_SBPAD);
fs->lfs_avail -= lfs_btofsb(fs, LFS_SBPAD);
if (fs->lfs_version > 1 && segnum == 0 &&
fs->lfs_start < btofsb(fs, LFS_LABELPAD))
fs->lfs_avail -= btofsb(fs, LFS_LABELPAD) - fs->lfs_start;
fs->lfs_start < lfs_btofsb(fs, LFS_LABELPAD))
fs->lfs_avail -= lfs_btofsb(fs, LFS_LABELPAD) - fs->lfs_start;
mutex_enter(&lfs_lock);
fs->lfs_bfree += sup->su_nsums * btofsb(fs, fs->lfs_sumsize) +
btofsb(fs, sup->su_ninos * fs->lfs_ibsize);
fs->lfs_dmeta -= sup->su_nsums * btofsb(fs, fs->lfs_sumsize) +
btofsb(fs, sup->su_ninos * fs->lfs_ibsize);
fs->lfs_bfree += sup->su_nsums * lfs_btofsb(fs, fs->lfs_sumsize) +
lfs_btofsb(fs, sup->su_ninos * fs->lfs_ibsize);
fs->lfs_dmeta -= sup->su_nsums * lfs_btofsb(fs, fs->lfs_sumsize) +
lfs_btofsb(fs, sup->su_ninos * fs->lfs_ibsize);
if (fs->lfs_dmeta < 0)
fs->lfs_dmeta = 0;
mutex_exit(&lfs_lock);
@ -1168,7 +1168,7 @@ lfs_fastvget(struct mount *mp, ino_t ino, daddr_t daddr, struct vnode **vpp,
} else {
retries = 0;
again:
error = bread(ump->um_devvp, fsbtodb(fs, daddr), fs->lfs_ibsize,
error = bread(ump->um_devvp, LFS_FSBTODB(fs, daddr), fs->lfs_ibsize,
NOCRED, 0, &bp);
if (error) {
DLOG((DLOG_CLEAN, "lfs_fastvget: bread failed (%d)\n",

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_vfsops.c,v 1.306 2013/06/17 15:46:04 christos Exp $ */
/* $NetBSD: lfs_vfsops.c,v 1.307 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.306 2013/06/17 15:46:04 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.307 2013/06/18 18:18:58 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_lfs.h"
@ -946,12 +946,12 @@ lfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l)
* If we aren't going to be able to write meaningfully to this
* filesystem, and were not mounted readonly, bomb out now.
*/
if (fsbtob(fs, LFS_NRESERVE(fs)) > LFS_MAX_BYTES && !ronly) {
if (lfs_fsbtob(fs, LFS_NRESERVE(fs)) > LFS_MAX_BYTES && !ronly) {
DLOG((DLOG_MOUNT, "lfs_mount: to mount this filesystem read/write,"
" we need BUFPAGES >= %lld\n",
(long long)((bufmem_hiwater / bufmem_lowater) *
LFS_INVERSE_MAX_BYTES(
fsbtob(fs, LFS_NRESERVE(fs))) >> PAGE_SHIFT)));
lfs_fsbtob(fs, LFS_NRESERVE(fs))) >> PAGE_SHIFT)));
kmem_free(fs, sizeof(struct lfs));
error = EFBIG; /* XXX needs translation */
goto out;
@ -1124,10 +1124,10 @@ lfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l)
* Mark the current segment as ACTIVE, since we're going to
* be writing to it.
*/
LFS_SEGENTRY(sup, fs, dtosn(fs, fs->lfs_offset), bp);
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, fs->lfs_offset), bp);
sup->su_flags |= SEGUSE_DIRTY | SEGUSE_ACTIVE;
fs->lfs_nactive++;
LFS_WRITESEGENTRY(sup, fs, dtosn(fs, fs->lfs_offset), bp); /* Ifile */
LFS_WRITESEGENTRY(sup, fs, lfs_dtosn(fs, fs->lfs_offset), bp); /* Ifile */
/* Now that roll-forward is done, unlock the Ifile */
vput(vp);
@ -1283,7 +1283,8 @@ lfs_statvfs(struct mount *mp, struct statvfs *sbp)
else
sbp->f_bavail = 0;
sbp->f_files = fs->lfs_bfree / btofsb(fs, fs->lfs_ibsize) * INOPB(fs);
sbp->f_files = fs->lfs_bfree / lfs_btofsb(fs, fs->lfs_ibsize)
* LFS_INOPB(fs);
sbp->f_ffree = sbp->f_files - fs->lfs_nfiles;
sbp->f_favail = sbp->f_ffree;
sbp->f_fresvd = 0;
@ -1432,7 +1433,7 @@ retry:
/* Read in the disk contents for the inode, copy into the inode. */
retries = 0;
again:
error = bread(ump->um_devvp, fsbtodb(fs, daddr),
error = bread(ump->um_devvp, LFS_FSBTODB(fs, daddr),
(fs->lfs_version == 1 ? fs->lfs_bsize : fs->lfs_ibsize),
NOCRED, 0, &bp);
if (error) {
@ -1470,7 +1471,7 @@ retry:
printf("lfs_vget: block 0x%" PRIx64 ": ",
(*bpp)->b_blkno);
dp = (struct ulfs1_dinode *)(*bpp)->b_data;
for (i = 0; i < INOPB(fs); i++)
for (i = 0; i < LFS_INOPB(fs); i++)
if (dp[i].di_inumber)
printf("%d ", dp[i].di_inumber);
printf("\n");
@ -1861,7 +1862,7 @@ lfs_gop_write(struct vnode *vp, struct vm_page **pgs, int npages,
mutex_exit(vp->v_interlock);
mutex_exit(&bufcache_lock);
bp->b_lblkno = lblkno(fs, offset);
bp->b_lblkno = lfs_lblkno(fs, offset);
bp->b_private = mbp;
if (devvp->v_type == VBLK) {
bp->b_dev = devvp->v_rdev;
@ -1989,7 +1990,7 @@ lfs_vinit(struct mount *mp, struct vnode **vpp)
#endif /* DEBUG */
for (i = 0; i < ULFS_NDADDR; i++)
if (ip->i_ffs1_db[i] != 0)
ip->i_lfs_fragsize[i] = blksize(fs, ip, i);
ip->i_lfs_fragsize[i] = lfs_blksize(fs, ip, i);
}
#ifdef DIAGNOSTIC
@ -2013,7 +2014,7 @@ lfs_vinit(struct mount *mp, struct vnode **vpp)
uvm_vnp_setsize(vp, ip->i_size);
/* Initialize hiblk from file size */
ip->i_lfs_hiblk = lblkno(ip->i_lfs, ip->i_size + ip->i_lfs->lfs_bsize - 1) - 1;
ip->i_lfs_hiblk = lfs_lblkno(ip->i_lfs, ip->i_size + ip->i_lfs->lfs_bsize - 1) - 1;
*vpp = vp;
}
@ -2043,7 +2044,7 @@ lfs_resize_fs(struct lfs *fs, int newnsegs)
return 0;
/* We always have to have two superblocks */
if (newnsegs <= dtosn(fs, fs->lfs_sboffs[1]))
if (newnsegs <= lfs_dtosn(fs, fs->lfs_sboffs[1]))
return EFBIG;
ivp = fs->lfs_ivnode;
@ -2153,45 +2154,43 @@ lfs_resize_fs(struct lfs *fs, int newnsegs)
/* Zero out unused superblock offsets */
for (i = 2; i < LFS_MAXNUMSB; i++)
if (dtosn(fs, fs->lfs_sboffs[i]) >= newnsegs)
if (lfs_dtosn(fs, fs->lfs_sboffs[i]) >= newnsegs)
fs->lfs_sboffs[i] = 0x0;
/*
* Correct superblock entries that depend on fs size.
* The computations of these are as follows:
*
* size = segtod(fs, nseg)
* dsize = segtod(fs, nseg - minfreeseg) - btofsb(#super * LFS_SBPAD)
* bfree = dsize - btofsb(fs, bsize * nseg / 2) - blocks_actually_used
* avail = segtod(fs, nclean) - btofsb(#clean_super * LFS_SBPAD)
* + (segtod(fs, 1) - (offset - curseg))
* - segtod(fs, minfreeseg - (minfreeseg / 2))
* size = lfs_segtod(fs, nseg)
* dsize = lfs_segtod(fs, nseg - minfreeseg) - lfs_btofsb(#super * LFS_SBPAD)
* bfree = dsize - lfs_btofsb(fs, bsize * nseg / 2) - blocks_actually_used
* avail = lfs_segtod(fs, nclean) - lfs_btofsb(#clean_super * LFS_SBPAD)
* + (lfs_segtod(fs, 1) - (offset - curseg))
* - lfs_segtod(fs, minfreeseg - (minfreeseg / 2))
*
* XXX - we should probably adjust minfreeseg as well.
*/
gain = (newnsegs - oldnsegs);
fs->lfs_nseg = newnsegs;
fs->lfs_segtabsz = nlast - fs->lfs_cleansz;
fs->lfs_size += gain * btofsb(fs, fs->lfs_ssize);
fs->lfs_dsize += gain * btofsb(fs, fs->lfs_ssize) - btofsb(fs, sbbytes);
fs->lfs_bfree += gain * btofsb(fs, fs->lfs_ssize) - btofsb(fs, sbbytes)
- gain * btofsb(fs, fs->lfs_bsize / 2);
fs->lfs_size += gain * lfs_btofsb(fs, fs->lfs_ssize);
fs->lfs_dsize += gain * lfs_btofsb(fs, fs->lfs_ssize) - lfs_btofsb(fs, sbbytes);
fs->lfs_bfree += gain * lfs_btofsb(fs, fs->lfs_ssize) - lfs_btofsb(fs, sbbytes)
- gain * lfs_btofsb(fs, fs->lfs_bsize / 2);
if (gain > 0) {
fs->lfs_nclean += gain;
fs->lfs_avail += gain * btofsb(fs, fs->lfs_ssize);
fs->lfs_avail += gain * lfs_btofsb(fs, fs->lfs_ssize);
} else {
fs->lfs_nclean -= cgain;
fs->lfs_avail -= cgain * btofsb(fs, fs->lfs_ssize) -
btofsb(fs, csbbytes);
fs->lfs_avail -= cgain * lfs_btofsb(fs, fs->lfs_ssize) -
lfs_btofsb(fs, csbbytes);
}
/* Resize segment flag cache */
fs->lfs_suflags[0] = (u_int32_t *)realloc(fs->lfs_suflags[0],
fs->lfs_nseg * sizeof(u_int32_t),
M_SEGMENT, M_WAITOK);
fs->lfs_suflags[1] = (u_int32_t *)realloc(fs->lfs_suflags[1],
fs->lfs_nseg * sizeof(u_int32_t),
M_SEGMENT, M_WAITOK);
fs->lfs_suflags[0] = realloc(fs->lfs_suflags[0],
fs->lfs_nseg * 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);
for (i = oldnsegs; i < newnsegs; i++)
fs->lfs_suflags[0][i] = fs->lfs_suflags[1][i] = 0x0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_vnops.c,v 1.247 2013/06/08 22:23:52 dholland Exp $ */
/* $NetBSD: lfs_vnops.c,v 1.248 2013/06/18 18:18:58 christos Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.247 2013/06/08 22:23:52 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.248 2013/06/18 18:18:58 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@ -973,7 +973,7 @@ lfs_getattr(void *v)
vap->va_blocksize = MAXBSIZE;
else
vap->va_blocksize = vp->v_mount->mnt_stat.f_iosize;
vap->va_bytes = fsbtob(fs, (u_quad_t)ip->i_lfs_effnblks);
vap->va_bytes = lfs_fsbtob(fs, (u_quad_t)ip->i_lfs_effnblks);
vap->va_type = vp->v_type;
vap->va_filerev = ip->i_modrev;
return (0);
@ -1235,18 +1235,18 @@ lfs_strategy(void *v)
* Since the cleaner is synchronous, we can trust
* the list of intervals to be current.
*/
tbn = dbtofsb(fs, bp->b_blkno);
sn = dtosn(fs, tbn);
tbn = LFS_DBTOFSB(fs, bp->b_blkno);
sn = lfs_dtosn(fs, tbn);
slept = 0;
for (i = 0; i < fs->lfs_cleanind; i++) {
if (sn == dtosn(fs, fs->lfs_cleanint[i]) &&
if (sn == lfs_dtosn(fs, fs->lfs_cleanint[i]) &&
tbn >= fs->lfs_cleanint[i]) {
DLOG((DLOG_CLEAN,
"lfs_strategy: ino %d lbn %" PRId64
" ind %d sn %d fsb %" PRIx32
" given sn %d fsb %" PRIx64 "\n",
ip->i_number, bp->b_lblkno, i,
dtosn(fs, fs->lfs_cleanint[i]),
lfs_dtosn(fs, fs->lfs_cleanint[i]),
fs->lfs_cleanint[i], sn, tbn));
DLOG((DLOG_CLEAN,
"lfs_strategy: sleeping on ino %d lbn %"
@ -2182,7 +2182,7 @@ lfs_putpages(void *v)
return 0;
}
blkeof = blkroundup(fs, ip->i_size);
blkeof = lfs_blkroundup(fs, ip->i_size);
/*
* Ignore requests to free pages past EOF but in the same block
@ -2231,7 +2231,7 @@ lfs_putpages(void *v)
origendoffset = endoffset;
} else {
origendoffset = round_page(ap->a_offhi);
endoffset = round_page(blkroundup(fs, origendoffset));
endoffset = round_page(lfs_blkroundup(fs, origendoffset));
}
KASSERT(startoffset > 0 || endoffset >= startoffset);
@ -2457,7 +2457,7 @@ lfs_putpages(void *v)
DLOG((DLOG_PAGE, "lfs_putpages: genfs_putpages returned"
" %d ino %d off %x (seg %d)\n", error,
ip->i_number, fs->lfs_offset,
dtosn(fs, fs->lfs_offset)));
lfs_dtosn(fs, fs->lfs_offset)));
if (oreclaim) {
mutex_enter(vp->v_interlock);
@ -2472,7 +2472,7 @@ lfs_putpages(void *v)
DLOG((DLOG_PAGE, "lfs_putpages: genfs_putpages returned"
" %d ino %d off %x (seg %d)\n", error,
(int)ip->i_number, fs->lfs_offset,
dtosn(fs, fs->lfs_offset)));
lfs_dtosn(fs, fs->lfs_offset)));
}
/* genfs_do_putpages loses the interlock */
#ifdef DEBUG
@ -2576,12 +2576,12 @@ lfs_gop_size(struct vnode *vp, off_t size, off_t *eobp, int flags)
struct lfs *fs = ip->i_lfs;
daddr_t olbn, nlbn;
olbn = lblkno(fs, ip->i_size);
nlbn = lblkno(fs, size);
olbn = lfs_lblkno(fs, ip->i_size);
nlbn = lfs_lblkno(fs, size);
if (!(flags & GOP_SIZE_MEM) && nlbn < ULFS_NDADDR && olbn <= nlbn) {
*eobp = fragroundup(fs, size);
*eobp = lfs_fragroundup(fs, size);
} else {
*eobp = blkroundup(fs, size);
*eobp = lfs_blkroundup(fs, size);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_inode.h,v 1.8 2013/06/18 08:01:00 dholland Exp $ */
/* $NetBSD: ulfs_inode.h,v 1.9 2013/06/18 18:18:58 christos Exp $ */
/* from NetBSD: inode.h,v 1.64 2012/11/19 00:36:21 jakllsch Exp */
/*
@ -145,8 +145,8 @@ struct lfid {
/* Address calculations for metadata located in the inode */
#define S_INDIR(fs) -ULFS_NDADDR
#define D_INDIR(fs) (S_INDIR(fs) - NINDIR(fs) - 1)
#define T_INDIR(fs) (D_INDIR(fs) - NINDIR(fs) * NINDIR(fs) - 1)
#define D_INDIR(fs) (S_INDIR(fs) - LFS_NINDIR(fs) - 1)
#define T_INDIR(fs) (D_INDIR(fs) - LFS_NINDIR(fs) * LFS_NINDIR(fs) - 1)
/*
* "struct vnode" associated definitions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_lookup.c,v 1.11 2013/06/08 22:23:52 dholland Exp $ */
/* $NetBSD: ulfs_lookup.c,v 1.12 2013/06/18 18:18:58 christos Exp $ */
/* from NetBSD: ufs_lookup.c,v 1.122 2013/01/22 09:39:18 dholland Exp */
/*
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.11 2013/06/08 22:23:52 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.12 2013/06/18 18:18:58 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_lfs.h"
@ -817,7 +817,7 @@ ulfs_direnter(struct vnode *dvp, const struct ulfs_lookup_results *ulr,
struct buf *bp;
u_int dsize;
struct lfs_direct *ep, *nep;
int error, ret, blkoff, loc, spacefree;
int error, ret, lfs_blkoff, loc, spacefree;
char *dirbuf;
struct timespec ts;
struct ulfsmount *ump = VFSTOULFS(dvp->v_mount);
@ -861,13 +861,13 @@ ulfs_direnter(struct vnode *dvp, const struct ulfs_lookup_results *ulr,
dirp->d_type = tmp;
}
}
blkoff = ulr->ulr_offset & (ump->um_mountp->mnt_stat.f_iosize - 1);
memcpy((char *)bp->b_data + blkoff, dirp, newentrysize);
lfs_blkoff = ulr->ulr_offset & (ump->um_mountp->mnt_stat.f_iosize - 1);
memcpy((char *)bp->b_data + lfs_blkoff, dirp, newentrysize);
#ifdef LFS_DIRHASH
if (dp->i_dirhash != NULL) {
ulfsdirhash_newblk(dp, ulr->ulr_offset);
ulfsdirhash_add(dp, dirp, ulr->ulr_offset);
ulfsdirhash_checkblock(dp, (char *)bp->b_data + blkoff,
ulfsdirhash_checkblock(dp, (char *)bp->b_data + lfs_blkoff,
ulr->ulr_offset);
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_readwrite.c,v 1.3 2013/06/08 22:05:15 dholland Exp $ */
/* $NetBSD: ulfs_readwrite.c,v 1.4 2013/06/18 18:18:58 christos Exp $ */
/* from NetBSD: ufs_readwrite.c,v 1.105 2013/01/22 09:39:18 dholland Exp */
/*-
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.3 2013/06/08 22:05:15 dholland Exp $");
__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.4 2013/06/18 18:18:58 christos Exp $");
#ifdef LFS_READWRITE
#define FS struct lfs
@ -141,17 +141,17 @@ READ(void *v)
bytesinfile = ip->i_size - uio->uio_offset;
if (bytesinfile <= 0)
break;
lbn = lblkno(fs, uio->uio_offset);
lbn = lfs_lblkno(fs, uio->uio_offset);
nextlbn = lbn + 1;
size = blksize(fs, ip, lbn);
blkoffset = blkoff(fs, uio->uio_offset);
size = lfs_blksize(fs, ip, lbn);
blkoffset = lfs_blkoff(fs, uio->uio_offset);
xfersize = MIN(MIN(fs->fs_bsize - blkoffset, uio->uio_resid),
bytesinfile);
if (lblktosize(fs, nextlbn) >= ip->i_size)
if (lfs_lblktosize(fs, nextlbn) >= ip->i_size)
error = bread(vp, lbn, size, NOCRED, 0, &bp);
else {
int nextsize = blksize(fs, ip, nextlbn);
int nextsize = lfs_blksize(fs, ip, nextlbn);
error = breadn(vp, lbn,
size, &nextlbn, &nextsize, 1, NOCRED, 0, &bp);
}
@ -278,28 +278,28 @@ WRITE(void *v)
#ifdef LFS_READWRITE
async = true;
lfs_availwait(fs, btofsb(fs, uio->uio_resid));
lfs_availwait(fs, lfs_btofsb(fs, uio->uio_resid));
lfs_check(vp, LFS_UNUSED_LBN, 0);
#endif /* !LFS_READWRITE */
if (!usepc)
goto bcache;
preallocoff = round_page(blkroundup(fs, MAX(osize, uio->uio_offset)));
preallocoff = round_page(lfs_blkroundup(fs, MAX(osize, uio->uio_offset)));
aflag = ioflag & IO_SYNC ? B_SYNC : 0;
nsize = MAX(osize, uio->uio_offset + uio->uio_resid);
endallocoff = nsize - blkoff(fs, nsize);
endallocoff = nsize - lfs_blkoff(fs, nsize);
/*
* if we're increasing the file size, deal with expanding
* the fragment if there is one.
*/
if (nsize > osize && lblkno(fs, osize) < ULFS_NDADDR &&
lblkno(fs, osize) != lblkno(fs, nsize) &&
blkroundup(fs, osize) != osize) {
if (nsize > osize && lfs_lblkno(fs, osize) < ULFS_NDADDR &&
lfs_lblkno(fs, osize) != lfs_lblkno(fs, nsize) &&
lfs_blkroundup(fs, osize) != osize) {
off_t eob;
eob = blkroundup(fs, osize);
eob = lfs_blkroundup(fs, osize);
uvm_vnp_setwritesize(vp, eob);
error = ulfs_balloc_range(vp, osize, eob - osize, cred, aflag);
if (error)
@ -322,7 +322,7 @@ WRITE(void *v)
}
oldoff = uio->uio_offset;
blkoffset = blkoff(fs, uio->uio_offset);
blkoffset = lfs_blkoff(fs, uio->uio_offset);
bytelen = MIN(fs->fs_bsize - blkoffset, uio->uio_resid);
if (bytelen == 0) {
break;
@ -338,12 +338,12 @@ WRITE(void *v)
overwrite = uio->uio_offset >= preallocoff &&
uio->uio_offset < endallocoff;
if (!overwrite && (vp->v_vflag & VV_MAPPED) == 0 &&
blkoff(fs, uio->uio_offset) == 0 &&
lfs_blkoff(fs, uio->uio_offset) == 0 &&
(uio->uio_offset & PAGE_MASK) == 0) {
vsize_t len;
len = trunc_page(bytelen);
len -= blkoff(fs, len);
len -= lfs_blkoff(fs, len);
if (len > 0) {
overwrite = true;
bytelen = len;
@ -411,7 +411,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),
round_page(blkroundup(fs, uio->uio_offset)),
round_page(lfs_blkroundup(fs, uio->uio_offset)),
PGO_CLEANIT | PGO_SYNCIO | PGO_JOURNALLOCKED);
}
goto out;
@ -421,8 +421,8 @@ WRITE(void *v)
VOP_PUTPAGES(vp, trunc_page(origoff), round_page(origoff + resid),
PGO_CLEANIT | PGO_FREE | PGO_SYNCIO | PGO_JOURNALLOCKED);
while (uio->uio_resid > 0) {
lbn = lblkno(fs, uio->uio_offset);
blkoffset = blkoff(fs, uio->uio_offset);
lbn = lfs_lblkno(fs, uio->uio_offset);
blkoffset = lfs_blkoff(fs, uio->uio_offset);
xfersize = MIN(fs->fs_bsize - blkoffset, uio->uio_resid);
if (fs->fs_bsize > xfersize)
flags |= B_CLRBUF;
@ -431,7 +431,7 @@ WRITE(void *v)
#ifdef LFS_READWRITE
error = lfs_reserve(fs, vp, NULL,
btofsb(fs, (ULFS_NIADDR + 1) << fs->lfs_bshift));
lfs_btofsb(fs, (ULFS_NIADDR + 1) << fs->lfs_bshift));
if (error)
break;
need_unreserve = true;
@ -447,7 +447,7 @@ WRITE(void *v)
uvm_vnp_setsize(vp, ip->i_size);
extended = 1;
}
size = blksize(fs, ip, lbn) - bp->b_resid;
size = lfs_blksize(fs, ip, lbn) - bp->b_resid;
if (xfersize > size)
xfersize = size;
@ -465,7 +465,7 @@ WRITE(void *v)
#ifdef LFS_READWRITE
(void)VOP_BWRITE(bp->b_vp, bp);
lfs_reserve(fs, vp, NULL,
-btofsb(fs, (ULFS_NIADDR + 1) << fs->lfs_bshift));
-lfs_btofsb(fs, (ULFS_NIADDR + 1) << fs->lfs_bshift));
need_unreserve = false;
#else
if (ioflag & IO_SYNC)
@ -481,7 +481,7 @@ WRITE(void *v)
#ifdef LFS_READWRITE
if (need_unreserve) {
lfs_reserve(fs, vp, NULL,
-btofsb(fs, (ULFS_NIADDR + 1) << fs->lfs_bshift));
-lfs_btofsb(fs, (ULFS_NIADDR + 1) << fs->lfs_bshift));
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: dumplfs.c,v 1.40 2013/06/08 23:27:34 dholland Exp $ */
/* $NetBSD: dumplfs.c,v 1.41 2013/06/18 18:18:58 christos 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.40 2013/06/08 23:27:34 dholland Exp $");
__RCSID("$NetBSD: dumplfs.c,v 1.41 2013/06/18 18:18:58 christos Exp $");
#endif
#endif /* not lint */
@ -125,7 +125,7 @@ print_ientry(int i, IFILE *ip)
(ip->if_nextfree == LFS_ORPHAN_NEXTFREE ? "FFFFFFFF" : "-"));
}
#define fsbtobyte(fs, b) fsbtob((fs), (off_t)((b)))
#define fsbtobyte(fs, b) lfs_fsbtob((fs), (off_t)((b)))
int datasum_check = 0;
@ -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] > btofsb(&lfs_sb1, LFS_LABELPAD))
get(fd, fsbtob(&lfs_sb1, lfs_sb1.lfs_sboffs[0]),
lfs_sb1.lfs_sboffs[0] > lfs_btofsb(&lfs_sb1, LFS_LABELPAD))
get(fd, lfs_fsbtob(&lfs_sb1, lfs_sb1.lfs_sboffs[0]),
&(lfs_sb1.lfs_dlfs), sizeof(struct dlfs));
/*
@ -241,14 +241,14 @@ main(int argc, char **argv)
if (seglist != NULL)
for (; seglist != NULL; seglist = seglist->next) {
seg_addr = sntod(lfs_master, seglist->num);
seg_addr = lfs_sntod(lfs_master, seglist->num);
dump_segment(fd, seglist->num, seg_addr, lfs_master,
do_allsb);
}
else
for (segnum = 0, seg_addr = sntod(lfs_master, 0);
for (segnum = 0, seg_addr = lfs_sntod(lfs_master, 0);
segnum < lfs_master->lfs_nseg;
segnum++, seg_addr = sntod(lfs_master, segnum))
segnum++, seg_addr = lfs_sntod(lfs_master, segnum))
dump_segment(fd, segnum, seg_addr, lfs_master,
do_allsb);
@ -278,7 +278,7 @@ dump_ifile(int fd, struct lfs *lfsp, int do_ientries, int do_segentries, daddr_t
err(1, "malloc");
get(fd, fsbtobyte(lfsp, addr), dpage, psize);
for (dip = dpage + INOPB(lfsp) - 1; dip >= dpage; --dip)
for (dip = dpage + LFS_INOPB(lfsp) - 1; dip >= dpage; --dip)
if (dip->di_inumber == LFS_IFILE_INUM)
break;
@ -500,8 +500,8 @@ dump_sum(int fd, struct lfs *lfsp, SEGSUM *sp, int segnum, daddr_t addr)
sp->ss_sumsum != (ck = cksum(&sp->ss_datasum,
lfsp->lfs_sumsize - sizeof(sp->ss_sumsum)))) {
/* Don't print "corrupt" if we're just too close to the edge */
if (dtosn(lfsp, addr + fsbtodb(lfsp, 1)) ==
dtosn(lfsp, addr))
if (lfs_dtosn(lfsp, addr + LFS_FSBTODB(lfsp, 1)) ==
lfs_dtosn(lfsp, addr))
(void)printf("dumplfs: %s %d address 0x%llx\n",
"corrupt summary block; segment", segnum,
(long long)addr);
@ -547,13 +547,13 @@ dump_sum(int fd, struct lfs *lfsp, SEGSUM *sp, int segnum, daddr_t addr)
numbytes += lfsp->lfs_ibsize; /* add bytes for inode block */
printf("\t0x%x {", *dp);
get(fd, fsbtobyte(lfsp, *dp), inop, lfsp->lfs_ibsize);
for (j = 0; i < sp->ss_ninos && j < INOPB(lfsp); j++, i++) {
for (j = 0; i < sp->ss_ninos && j < LFS_INOPB(lfsp); j++, i++) {
if (j > 0)
(void)printf(", ");
(void)printf("%dv%d", inop[j].di_inumber, inop[j].di_gen);
}
(void)printf("}");
if (((i/INOPB(lfsp)) % 4) == 3)
if (((i/LFS_INOPB(lfsp)) % 4) == 3)
(void)printf("\n");
}
free(inop);
@ -605,13 +605,13 @@ dump_sum(int fd, struct lfs *lfsp, SEGSUM *sp, int segnum, daddr_t addr)
datap = (char *)malloc(el_size * numblocks);
memset(datap, 0, el_size * numblocks);
acc = 0;
addr += btofsb(lfsp, lfsp->lfs_sumsize);
addr += lfs_btofsb(lfsp, lfsp->lfs_sumsize);
buf = malloc(lfsp->lfs_bsize);
for (i = 0; i < sp->ss_nfinfo; i++) {
while (addr == *idp) {
get(fd, fsbtobyte(lfsp, addr), buf, lfsp->lfs_ibsize);
memcpy(datap + acc * el_size, buf, el_size);
addr += btofsb(lfsp, lfsp->lfs_ibsize);
addr += lfs_btofsb(lfsp, lfsp->lfs_ibsize);
--idp;
++acc;
}
@ -619,9 +619,9 @@ dump_sum(int fd, struct lfs *lfsp, SEGSUM *sp, int segnum, daddr_t addr)
get(fd, fsbtobyte(lfsp, addr), buf, lfsp->lfs_fsize);
memcpy(datap + acc * el_size, buf, el_size);
if (j == fp->fi_nblocks - 1)
addr += btofsb(lfsp, fp->fi_lastlength);
addr += lfs_btofsb(lfsp, fp->fi_lastlength);
else
addr += btofsb(lfsp, lfsp->lfs_bsize);
addr += lfs_btofsb(lfsp, lfsp->lfs_bsize);
++acc;
}
fp = (FINFO *)&(fp->fi_blocks[fp->fi_nblocks]);
@ -629,7 +629,7 @@ dump_sum(int fd, struct lfs *lfsp, SEGSUM *sp, int segnum, daddr_t addr)
while (addr == *idp) {
get(fd, fsbtobyte(lfsp, addr), buf, lfsp->lfs_ibsize);
memcpy(datap + acc * el_size, buf, el_size);
addr += btofsb(lfsp, lfsp->lfs_ibsize);
addr += lfs_btofsb(lfsp, lfsp->lfs_ibsize);
--idp;
++acc;
}
@ -656,16 +656,16 @@ dump_segment(int fd, int segnum, daddr_t addr, struct lfs *lfsp, int dump_sb)
daddr_t new_addr;
(void)printf("\nSEGMENT %lld (Disk Address 0x%llx)\n",
(long long)dtosn(lfsp, addr), (long long)addr);
(long long)lfs_dtosn(lfsp, addr), (long long)addr);
sum_offset = fsbtobyte(lfsp, addr);
sumblock = malloc(lfsp->lfs_sumsize);
if (lfsp->lfs_version > 1 && segnum == 0) {
if (fsbtob(lfsp, lfsp->lfs_start) < LFS_LABELPAD) {
if (lfs_fsbtob(lfsp, lfsp->lfs_start) < LFS_LABELPAD) {
/* First segment eats the disklabel */
sum_offset += fragroundup(lfsp, LFS_LABELPAD) -
fsbtob(lfsp, lfsp->lfs_start);
addr += btofsb(lfsp, fragroundup(lfsp, LFS_LABELPAD)) -
sum_offset += lfs_fragroundup(lfsp, LFS_LABELPAD) -
lfs_fsbtob(lfsp, lfsp->lfs_start);
addr += lfs_btofsb(lfsp, lfs_fragroundup(lfsp, LFS_LABELPAD)) -
lfsp->lfs_start;
printf("Disklabel at 0x0\n");
}
@ -683,14 +683,14 @@ dump_segment(int fd, int segnum, daddr_t addr, struct lfs *lfsp, int dump_sb)
sbp = (struct lfs *)sump;
if ((sb = (sbp->lfs_magic == LFS_MAGIC))) {
printf("Superblock at 0x%x\n",
(unsigned)btofsb(lfsp, sum_offset));
(unsigned)lfs_btofsb(lfsp, sum_offset));
if (dump_sb) {
get(fd, sum_offset, &(lfs_sb.lfs_dlfs),
sizeof(struct dlfs));
dump_super(&lfs_sb);
}
if (lfsp->lfs_version > 1)
sum_offset += fragroundup(lfsp, LFS_SBPAD);
sum_offset += lfs_fragroundup(lfsp, LFS_SBPAD);
else
sum_offset += LFS_SBPAD;
} else if (did_one)
@ -702,7 +702,7 @@ dump_segment(int fd, int segnum, daddr_t addr, struct lfs *lfsp, int dump_sb)
}
} else {
nbytes = dump_sum(fd, lfsp, sump, segnum,
btofsb(lfsp, sum_offset));
lfs_btofsb(lfsp, sum_offset));
if (nbytes >= 0)
sum_offset += lfsp->lfs_sumsize + nbytes;
else
@ -710,9 +710,9 @@ dump_segment(int fd, int segnum, daddr_t addr, struct lfs *lfsp, int dump_sb)
did_one = 1;
}
/* If the segment ends right on a boundary, it still ends */
new_addr = btofsb(lfsp, sum_offset);
new_addr = lfs_btofsb(lfsp, sum_offset);
/* printf("end daddr = 0x%lx\n", (long)new_addr); */
if (dtosn(lfsp, new_addr) != dtosn(lfsp, addr))
if (lfs_dtosn(lfsp, new_addr) != lfs_dtosn(lfsp, addr))
break;
} while (sum_offset);