Use the lfs dinode accessors in place of the ufs-derived ones.

(Mostly.)

The ufs-derived ones are fake structure member macros, which are gross
and not very safe. Also, it seems that a lot of places in the lfs code
were using the ffsv1 branch of them unconditionally, and this way it's
guaranteed all those places have been updated.

Found while doing this: for non-devices, have getattr produce NODEV
in the rdev field instead of leaking the address of the first direct
block.
This commit is contained in:
dholland 2015-09-01 06:08:37 +00:00
parent 068f46fe61
commit da32f22c2a
20 changed files with 319 additions and 269 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.36 2015/08/12 18:28:00 dholland Exp $ */
/* $NetBSD: dir.c,v 1.37 2015/09/01 06:08:37 dholland Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -316,7 +316,7 @@ fileerror(ino_t cwd, ino_t ino, const char *errmesg)
else {
if (ftypeok(VTOD(vp)))
pfatal("%s=%s\n",
(VTOI(vp)->i_ffs1_mode & LFS_IFMT) == LFS_IFDIR ?
(lfs_dino_getmode(fs, VTOI(vp)->i_din) & LFS_IFMT) == LFS_IFDIR ?
"DIR" : "FILE", pathbuf);
else
pfatal("NAME=%s\n", pathbuf);
@ -492,7 +492,8 @@ linkup(ino_t orphan, ino_t parentdir)
parentdir != (ino_t) - 1)
(void) makeentry(orphan, lfdir, "..");
vp = vget(fs, lfdir);
VTOI(vp)->i_ffs1_nlink++;
lfs_dino_setnlink(fs, VTOI(vp)->i_din,
lfs_dino_getnlink(fs, VTOI(vp)->i_din) + 1);
inodirty(VTOI(vp));
lncntp[lfdir]++;
pwarn("DIR I=%llu CONNECTED. ", (unsigned long long)orphan);
@ -688,7 +689,8 @@ freedir(ino_t ino, ino_t parent)
if (ino != parent) {
vp = vget(fs, parent);
VTOI(vp)->i_ffs1_nlink--;
lfs_dino_setnlink(fs, VTOI(vp)->i_din,
lfs_dino_getnlink(fs, VTOI(vp)->i_din) - 1);
inodirty(VTOI(vp));
}
freeino(ino);

View File

@ -1,4 +1,4 @@
/* $NetBSD: inode.c,v 1.60 2015/08/19 20:33:29 dholland Exp $ */
/* $NetBSD: inode.c,v 1.61 2015/09/01 06:08:37 dholland Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -305,7 +305,10 @@ iblock(struct inodesc *idesc, long ilevel, u_int64_t isize)
pathbuf, (long long)idesc->id_number);
if (reply("ADJUST LENGTH") == 1) {
vp = vget(fs, idesc->id_number);
VTOI(vp)->i_ffs1_size -= isize;
lfs_dino_setsize(fs, VTOI(vp)->i_din,
lfs_dino_getsize(fs,
VTOI(vp)->i_din)
- isize);
isize = 0;
printf(
"YOU MUST RERUN FSCK AFTERWARDS\n");
@ -444,7 +447,7 @@ clri(struct inodesc * idesc, const char *type, int flag)
vp = vget(fs, idesc->id_number);
if (flag & 0x1) {
pwarn("%s %s", type,
(VTOI(vp)->i_ffs1_mode & LFS_IFMT) == LFS_IFDIR ? "DIR" : "FILE");
(lfs_dino_getmode(fs, VTOI(vp)->i_din) & LFS_IFMT) == LFS_IFDIR ? "DIR" : "FILE");
pinode(idesc->id_number);
}
if ((flag & 0x2) || preen || reply("CLEAR") == 1) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs.c,v 1.57 2015/08/19 20:33:29 dholland Exp $ */
/* $NetBSD: lfs.c,v 1.58 2015/09/01 06:08:37 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@ -173,7 +173,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 = LFS_FSBTODB(fs, ip->i_ffs1_db[bn]);
*bnp = LFS_FSBTODB(fs, lfs_dino_getdb(fs, ip->i_din, bn));
if (*bnp == 0)
*bnp = -1;
return (0);
@ -187,7 +187,7 @@ ulfs_bmaparray(struct lfs * fs, struct uvnode * vp, daddr_t bn, daddr_t * bnp, s
num = *nump;
/* Get disk address out of indirect block array */
daddr = ip->i_ffs1_ib[xap->in_off];
daddr = lfs_dino_getib(fs, ip->i_din, xap->in_off);
for (bp = NULL, ++xap; --num; ++xap) {
/* Exit the loop if there is no disk address assigned yet and
@ -228,7 +228,7 @@ ulfs_bmaparray(struct lfs * fs, struct uvnode * vp, daddr_t bn, daddr_t * bnp, s
* contains the logical block number of the appropriate single, double or
* triple indirect block and the offset into the inode indirect block array.
* Note, the logical block number of the inode single/double/triple indirect
* block appears twice in the array, once with the offset into the i_ffs1_ib and
* block appears twice in the array, once with the offset into di_ib and
* once with the offset into the page itself.
*/
int
@ -386,18 +386,18 @@ lfs_raw_vget(struct lfs * fs, ino_t ino, int fd, ulfs_daddr_t daddr)
/* ip->i_devvp = fs->lfs_devvp; */
ip->i_lfs = fs;
ip->i_lfs_effnblks = ip->i_ffs1_blocks;
ip->i_lfs_osize = ip->i_ffs1_size;
ip->i_lfs_effnblks = lfs_dino_getblocks(fs, ip->i_din);
ip->i_lfs_osize = lfs_dino_getsize(fs, ip->i_din);
#if 0
if (fs->lfs_version > 1) {
ip->i_ffs1_atime = ts.tv_sec;
ip->i_ffs1_atimensec = ts.tv_nsec;
if (lfs_sb_getversion(fs) > 1) {
lfs_dino_setatime(fs, ip->i_din, ts.tv_sec);
lfs_dino_setatimensec(fs, ip->i_din, ts.tv_nsec);
}
#endif
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)
if (lfs_dino_getdb(fs, ip->i_din, i) != 0)
ip->i_lfs_fragsize[i] = lfs_blksize(fs, ip, i);
++nvnodes;
@ -925,10 +925,11 @@ extend_ifile(struct lfs *fs)
vp = fs->lfs_ivnode;
ip = VTOI(vp);
blkno = lfs_lblkno(fs, ip->i_ffs1_size);
blkno = lfs_lblkno(fs, lfs_dino_getsize(fs, ip->i_din));
lfs_balloc(vp, ip->i_ffs1_size, lfs_sb_getbsize(fs), &bp);
ip->i_ffs1_size += lfs_sb_getbsize(fs);
lfs_balloc(vp, lfs_dino_getsize(fs, ip->i_din), lfs_sb_getbsize(fs), &bp);
lfs_dino_setsize(fs, ip->i_din,
lfs_dino_getsize(fs, ip->i_din) + lfs_sb_getbsize(fs));
ip->i_flag |= IN_MODIFIED;
i = (blkno - lfs_sb_getsegtabsz(fs) - lfs_sb_getcleansz(fs)) *
@ -968,7 +969,7 @@ extend_ifile(struct lfs *fs)
LFS_BWRITE_LOG(bp);
#ifdef IN_FSCK_LFS
reset_maxino(((ip->i_ffs1_size >> lfs_sb_getbshift(fs))
reset_maxino(((lfs_dino_getsize(fs, ip->i_din) >> lfs_sb_getbshift(fs))
- lfs_sb_getsegtabsz(fs)
- lfs_sb_getcleansz(fs)) * lfs_sb_getifpb(fs));
#endif
@ -1026,7 +1027,7 @@ 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 = lfs_lblkno(fs, ip->i_ffs1_size);
lastblock = lfs_lblkno(fs, lfs_dino_getsize(fs, ip->i_din));
if (lastblock < ULFS_NDADDR && lastblock < lbn) {
osize = lfs_blksize(fs, ip, lastblock);
if (osize < lfs_sb_getbsize(fs) && osize > 0) {
@ -1034,7 +1035,7 @@ lfs_balloc(struct uvnode *vp, off_t startoffset, int iosize, struct ubuf **bpp)
lastblock,
(bpp ? &bp : NULL))))
return (error);
ip->i_ffs1_size = (lastblock + 1) * lfs_sb_getbsize(fs);
lfs_dino_setsize(fs, ip->i_din, (lastblock + 1) * lfs_sb_getbsize(fs));
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (bpp)
(void) VOP_BWRITE(bp);
@ -1049,10 +1050,10 @@ 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 && lfs_lblkno(fs, ip->i_ffs1_size) <= lbn) {
if (lbn < ULFS_NDADDR && lfs_lblkno(fs, lfs_dino_getsize(fs, ip->i_din)) <= lbn) {
osize = lfs_blksize(fs, ip, lbn);
nsize = lfs_fragroundup(fs, offset + iosize);
if (lfs_lblktosize(fs, lbn) >= ip->i_ffs1_size) {
if (lfs_lblktosize(fs, lbn) >= lfs_dino_getsize(fs, ip->i_din)) {
/* Brand new block or fragment */
frags = lfs_numfrags(fs, nsize);
if (bpp) {
@ -1061,7 +1062,7 @@ lfs_balloc(struct uvnode *vp, off_t startoffset, int iosize, struct ubuf **bpp)
}
ip->i_lfs_effnblks += frags;
lfs_sb_subbfree(fs, frags);
ip->i_ffs1_db[lbn] = UNWRITTEN;
lfs_dino_setdb(fs, ip->i_din, lbn, UNWRITTEN);
} else {
if (nsize <= osize) {
/* No need to extend */
@ -1105,15 +1106,16 @@ lfs_balloc(struct uvnode *vp, off_t startoffset, int iosize, struct ubuf **bpp)
ip->i_lfs_effnblks += bcount;
if (daddr == UNASSIGNED) {
if (num > 0 && ip->i_ffs1_ib[indirs[0].in_off] == 0) {
ip->i_ffs1_ib[indirs[0].in_off] = UNWRITTEN;
if (num > 0 && lfs_dino_getib(fs, ip->i_din, indirs[0].in_off) == 0) {
lfs_dino_setib(fs, ip->i_din, indirs[0].in_off,
UNWRITTEN);
}
/*
* Create new indirect blocks if necessary
*/
if (num > 1) {
idaddr = ip->i_ffs1_ib[indirs[0].in_off];
idaddr = lfs_dino_getib(fs, ip->i_din, indirs[0].in_off);
for (i = 1; i < num; ++i) {
ibp = getblk(vp, indirs[i].in_lbn,
lfs_sb_getbsize(fs));
@ -1165,10 +1167,11 @@ lfs_balloc(struct uvnode *vp, off_t startoffset, int iosize, struct ubuf **bpp)
switch (num) {
case 0:
ip->i_ffs1_db[lbn] = UNWRITTEN;
lfs_dino_setdb(fs, ip->i_din, lbn, UNWRITTEN);
break;
case 1:
ip->i_ffs1_ib[indirs[0].in_off] = UNWRITTEN;
lfs_dino_setib(fs, ip->i_din, indirs[0].in_off,
UNWRITTEN);
break;
default:
idp = &indirs[num - 1];
@ -1176,7 +1179,8 @@ lfs_balloc(struct uvnode *vp, off_t startoffset, int iosize, struct ubuf **bpp)
panic("lfs_balloc: bread bno %lld",
(long long)idp->in_lbn);
/* XXX ondisk32 */
((int32_t *)ibp->b_data)[idp->in_off] = UNWRITTEN;
lfs_iblock_set(fs, ibp->b_data, idp->in_off,
UNWRITTEN);
VOP_BWRITE(ibp);
}
} else if (bpp && !(bp->b_flags & (B_DONE|B_DELWRI))) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: pass6.c,v 1.43 2015/08/19 20:33:29 dholland Exp $ */
/* $NetBSD: pass6.c,v 1.44 2015/09/01 06:08:37 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -103,21 +103,24 @@ rfw_update_single(struct uvnode *vp, daddr_t lbn, ulfs_daddr_t ndaddr, size_t si
frags = lfs_numfrags(fs, size);
switch (num) {
case 0:
ooff = ip->i_ffs1_db[lbn];
ooff = lfs_dino_getdb(fs, ip->i_din, lbn);
if (ooff <= 0)
ip->i_ffs1_blocks += frags;
lfs_dino_setblocks(fs, ip->i_din,
lfs_dino_getblocks(fs, ip->i_din) + frags);
else {
/* possible fragment truncation or extension */
ofrags = lfs_numfrags(fs, ip->i_lfs_fragsize[lbn]);
ip->i_ffs1_blocks += (frags - ofrags);
lfs_dino_setblocks(fs, ip->i_din,
lfs_dino_getblocks(fs, ip->i_din) + (frags - ofrags));
}
ip->i_ffs1_db[lbn] = ndaddr;
lfs_dino_setdb(fs, ip->i_din, lbn, ndaddr);
break;
case 1:
ooff = ip->i_ffs1_ib[a[0].in_off];
ooff = lfs_dino_getib(fs, ip->i_din, a[0].in_off);
if (ooff <= 0)
ip->i_ffs1_blocks += frags;
ip->i_ffs1_ib[a[0].in_off] = ndaddr;
lfs_dino_setblocks(fs, ip->i_din,
lfs_dino_getblocks(fs, ip->i_din) + frags);
lfs_dino_setib(fs, ip->i_din, a[0].in_off, ndaddr);
break;
default:
ap = &a[num - 1];
@ -125,10 +128,11 @@ rfw_update_single(struct uvnode *vp, daddr_t lbn, ulfs_daddr_t ndaddr, size_t si
errx(1, "lfs_updatemeta: bread bno %" PRId64,
ap->in_lbn);
ooff = ((ulfs_daddr_t *) bp->b_data)[ap->in_off];
ooff = lfs_iblock_get(fs, bp->b_data, ap->in_off);
if (ooff <= 0)
ip->i_ffs1_blocks += frags;
((ulfs_daddr_t *) bp->b_data)[ap->in_off] = ndaddr;
lfs_dino_setblocks(fs, ip->i_din,
lfs_dino_getblocks(fs, ip->i_din) + frags);
lfs_iblock_set(fs, bp->b_data, ap->in_off, ndaddr);
(void) VOP_BWRITE(bp);
}
@ -153,8 +157,8 @@ rfw_update_single(struct uvnode *vp, daddr_t lbn, ulfs_daddr_t ndaddr, size_t si
}
/* If block is beyond EOF, update size */
if (lbn >= 0 && ip->i_ffs1_size <= (lbn << lfs_sb_getbshift(fs))) {
ip->i_ffs1_size = (lbn << lfs_sb_getbshift(fs)) + 1;
if (lbn >= 0 && lfs_dino_getsize(fs, ip->i_din) <= (lbn << lfs_sb_getbshift(fs))) {
lfs_dino_setsize(fs, ip->i_din, (lbn << lfs_sb_getbshift(fs)) + 1);
}
/* If block frag size is too large for old EOF, update size */
@ -163,8 +167,8 @@ rfw_update_single(struct uvnode *vp, daddr_t lbn, ulfs_daddr_t ndaddr, size_t si
minsize = (lbn << lfs_sb_getbshift(fs));
minsize += (size - lfs_sb_getfsize(fs)) + 1;
if (ip->i_ffs1_size < minsize)
ip->i_ffs1_size = minsize;
if (lfs_dino_getsize(fs, ip->i_din) < minsize)
lfs_dino_setsize(fs, ip->i_din, minsize);
}
/* Count for the user */
@ -264,7 +268,7 @@ pass6harvest(ulfs_daddr_t daddr, FINFO *fip)
vp = vget(fs, lfs_fi_getino(fs, fip));
if (vp && vp != fs->lfs_ivnode &&
VTOI(vp)->i_ffs1_gen == lfs_fi_getversion(fs, fip)) {
lfs_dino_getgen(fs, VTOI(vp)->i_din) == lfs_fi_getversion(fs, fip)) {
for (i = 0; i < lfs_fi_getnblocks(fs, fip); i++) {
size = (i == lfs_fi_getnblocks(fs, fip) - 1 ?
lfs_fi_getlastlength(fs, fip) : lfs_sb_getbsize(fs));
@ -388,7 +392,7 @@ account_block_changes(union lfs_dinode *dp)
/* Check direct block holdings between existing and new */
for (i = 0; i < ULFS_NDADDR; i++) {
odaddr = (ip ? ip->i_ffs1_db[i] : 0x0);
odaddr = (ip ? lfs_dino_getdb(fs, ip->i_din, i) : 0x0);
if (lfs_dino_getdb(fs, dp, i) > 0 && lfs_dino_getdb(fs, dp, i) != odaddr)
rfw_update_single(vp, i, lfs_dino_getdb(fs, dp, i),
lfs_dblksize(fs, dp, i));
@ -397,7 +401,7 @@ account_block_changes(union lfs_dinode *dp)
/* Check indirect block holdings between existing and new */
off = 0;
for (i = 0; i < ULFS_NIADDR; i++) {
odaddr = (ip ? ip->i_ffs1_ib[i] : 0x0);
odaddr = (ip ? lfs_dino_getib(fs, ip->i_din, i) : 0x0);
if (lfs_dino_getib(fs, dp, i) > 0 && lfs_dino_getib(fs, dp, i) != odaddr) {
lbn = -(ULFS_NDADDR + off + i);
rfw_update_single(vp, i, lfs_dino_getib(fs, dp, i), lfs_sb_getbsize(fs));
@ -711,11 +715,9 @@ pass6(void)
* allocated inode. Delete old file
* and proceed as in (2).
*/
if (vp && (
fs->lfs_is64 ?
VTOI(vp)->i_ffs2_gen :
VTOI(vp)->i_ffs1_gen
) < lfs_dino_getgen(fs, dp)) {
if (vp &&
lfs_dino_getgen(fs, VTOI(vp)->i_din)
< lfs_dino_getgen(fs, dp)) {
remove_ino(vp, lfs_dino_getinumber(fs, dp));
if (!(lfs_ss_getflags(fs, sp) & SS_DIROP))
pfatal("NEW FILE VERSION IN NON-DIROP PARTIAL SEGMENT");
@ -733,11 +735,9 @@ pass6(void)
* only. We'll pick up any new
* blocks when we do the block pass.
*/
if (vp && (
fs->lfs_is64 ?
VTOI(vp)->i_ffs2_gen :
VTOI(vp)->i_ffs1_gen
) == lfs_dino_getgen(fs, dp)) {
if (vp &&
lfs_dino_getgen(fs, VTOI(vp)->i_din)
== lfs_dino_getgen(fs, dp)) {
nmvfiles++;
readdress_inode(dp, ibdaddr);

View File

@ -1,4 +1,4 @@
/* $NetBSD: segwrite.c,v 1.42 2015/08/19 20:33:29 dholland Exp $ */
/* $NetBSD: segwrite.c,v 1.43 2015/09/01 06:08:37 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@ -311,7 +311,7 @@ lfs_writeinode(struct lfs * fs, struct segment * sp, struct inode * ip)
*/
if (ip->i_number == LFS_IFILE_INUM && sp->idp) {
lfs_copy_dinode(fs, sp->idp, ip->i_din);
ip->i_lfs_osize = ip->i_ffs1_size;
ip->i_lfs_osize = lfs_dino_getsize(fs, ip->i_din);
return 0;
}
bp = sp->ibp;
@ -319,7 +319,7 @@ lfs_writeinode(struct lfs * fs, struct segment * sp, struct inode * ip)
lfs_copy_dinode(fs, cdp, ip->i_din);
/* If all blocks are goig to disk, update the "size on disk" */
ip->i_lfs_osize = ip->i_ffs1_size;
ip->i_lfs_osize = lfs_dino_getsize(fs, ip->i_din);
if (ip->i_number == LFS_IFILE_INUM) /* We know sp->idp == NULL */
sp->idp = DINO_IN_BLOCK(fs, bp->b_data, sp->ninodes % LFS_INOPB(fs));
@ -478,21 +478,24 @@ lfs_update_single(struct lfs * fs, struct segment * sp, daddr_t lbn,
frags = lfs_numfrags(fs, size);
switch (num) {
case 0:
ooff = ip->i_ffs1_db[lbn];
ooff = lfs_dino_getdb(fs, ip->i_din, lbn);
if (ooff == UNWRITTEN)
ip->i_ffs1_blocks += frags;
lfs_dino_setblocks(fs, ip->i_din,
lfs_dino_getblocks(fs, ip->i_din) + frags);
else {
/* possible fragment truncation or extension */
ofrags = lfs_btofsb(fs, ip->i_lfs_fragsize[lbn]);
ip->i_ffs1_blocks += (frags - ofrags);
lfs_dino_setblocks(fs, ip->i_din,
lfs_dino_getblocks(fs, ip->i_din) + (frags - ofrags));
}
ip->i_ffs1_db[lbn] = ndaddr;
lfs_dino_setdb(fs, ip->i_din, lbn, ndaddr);
break;
case 1:
ooff = ip->i_ffs1_ib[a[0].in_off];
ooff = lfs_dino_getib(fs, ip->i_din, a[0].in_off);
if (ooff == UNWRITTEN)
ip->i_ffs1_blocks += frags;
ip->i_ffs1_ib[a[0].in_off] = ndaddr;
lfs_dino_setblocks(fs, ip->i_din,
lfs_dino_getblocks(fs, ip->i_din) + frags);
lfs_dino_setib(fs, ip->i_din, a[0].in_off, ndaddr);
break;
default:
ap = &a[num - 1];
@ -500,10 +503,11 @@ lfs_update_single(struct lfs * fs, struct segment * sp, daddr_t lbn,
errx(EXIT_FAILURE, "%s: bread bno %" PRId64, __func__,
ap->in_lbn);
ooff = ((ulfs_daddr_t *) bp->b_data)[ap->in_off];
ooff = lfs_iblock_get(fs, bp->b_data, ap->in_off);
if (ooff == UNWRITTEN)
ip->i_ffs1_blocks += frags;
((ulfs_daddr_t *) bp->b_data)[ap->in_off] = ndaddr;
lfs_dino_setblocks(fs, ip->i_din,
lfs_dino_getblocks(fs, ip->i_din) + frags);
lfs_iblock_set(fs, bp->b_data, ap->in_off, ndaddr);
(void) VOP_BWRITE(bp);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: setup.c,v 1.55 2015/08/12 18:28:00 dholland Exp $ */
/* $NetBSD: setup.c,v 1.56 2015/09/01 06:08:37 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -413,11 +413,11 @@ setup(const char *dev)
* XXX dirty while we do the rest.
*/
ivp = fs->lfs_ivnode;
maxino = ((VTOI(ivp)->i_ffs1_size - (lfs_sb_getcleansz(fs) + lfs_sb_getsegtabsz(fs))
maxino = ((lfs_dino_getsize(fs, VTOI(ivp)->i_din) - (lfs_sb_getcleansz(fs) + lfs_sb_getsegtabsz(fs))
* lfs_sb_getbsize(fs)) / lfs_sb_getbsize(fs)) * lfs_sb_getifpb(fs);
if (debug)
pwarn("maxino = %llu\n", (unsigned long long)maxino);
for (i = 0; i < VTOI(ivp)->i_ffs1_size; i += lfs_sb_getbsize(fs)) {
for (i = 0; i < lfs_dino_getsize(fs, VTOI(ivp)->i_din); i += lfs_sb_getbsize(fs)) {
bread(ivp, i >> lfs_sb_getbshift(fs), lfs_sb_getbsize(fs), 0, &bp);
/* XXX check B_ERROR */
brelse(bp, 0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_accessors.h,v 1.15 2015/08/29 21:04:22 mlelstv Exp $ */
/* $NetBSD: lfs_accessors.h,v 1.16 2015/09/01 06:08:37 dholland Exp $ */
/* from NetBSD: lfs.h,v 1.165 2015/07/24 06:59:32 dholland Exp */
/* from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp */
@ -236,6 +236,9 @@ LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, gen);
LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, uid);
LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, gid);
/* XXX this should be done differently (it's a fake field) */
LFS_DEF_DINO_ACCESSOR(uint64_t, int32_t, rdev);
static __unused inline daddr_t
lfs_dino_getdb(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix)
{
@ -280,6 +283,49 @@ lfs_dino_setib(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix, daddr_t val)
}
}
/* birthtime is present only in the 64-bit inode */
static __unused inline void
lfs_dino_setbirthtime(STRUCT_LFS *fs, union lfs_dinode *dip,
const struct timespec *ts)
{
if (fs->lfs_is64) {
dip->u_64.di_birthtime = ts->tv_sec;
dip->u_64.di_birthnsec = ts->tv_nsec;
} else {
/* drop it on the floor */
}
}
/*
* indirect blocks
*/
static __unused inline daddr_t
lfs_iblock_get(STRUCT_LFS *fs, void *block, unsigned ix)
{
if (fs->lfs_is64) {
// XXX re-enable these asserts after reorging this file
//KASSERT(ix < lfs_sb_getbsize(fs) / sizeof(int64_t));
return (daddr_t)(((int64_t *)block)[ix]);
} else {
//KASSERT(ix < lfs_sb_getbsize(fs) / sizeof(int32_t));
/* must sign-extend or UNWRITTEN gets trashed */
return (daddr_t)(int64_t)(((int32_t *)block)[ix]);
}
}
static __unused inline void
lfs_iblock_set(STRUCT_LFS *fs, void *block, unsigned ix, daddr_t val)
{
if (fs->lfs_is64) {
//KASSERT(ix < lfs_sb_getbsize(fs) / sizeof(int64_t));
((int64_t *)block)[ix] = val;
} else {
//KASSERT(ix < lfs_sb_getbsize(fs) / sizeof(int32_t));
((int32_t *)block)[ix] = val;
}
}
/*
* "struct buf" associated definitions
*/
@ -1032,10 +1078,10 @@ lfs_btofsb(STRUCT_LFS *fs, uint64_t b)
static __unused inline uint32_t
lfs_blksize(STRUCT_LFS *fs, struct inode *ip, uint64_t lbn)
{
if (lbn >= ULFS_NDADDR || ip->i_ffs1_size >= (lbn + 1) << lfs_sb_getbshift(fs)) {
if (lbn >= ULFS_NDADDR || lfs_dino_getsize(fs, ip->i_din) >= (lbn + 1) << lfs_sb_getbshift(fs)) {
return lfs_sb_getbsize(fs);
} else {
return lfs_fragroundup(fs, lfs_blkoff(fs, ip->i_ffs1_size));
return lfs_fragroundup(fs, lfs_blkoff(fs, lfs_dino_getsize(fs, ip->i_din)));
}
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_alloc.c,v 1.128 2015/08/29 21:04:22 mlelstv Exp $ */
/* $NetBSD: lfs_alloc.c,v 1.129 2015/09/01 06:08:37 dholland 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.128 2015/08/29 21:04:22 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.129 2015/09/01 06:08:37 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@ -135,7 +135,7 @@ lfs_extend_ifile(struct lfs *fs, kauth_cred_t cred)
return (error);
}
ip->i_size += lfs_sb_getbsize(fs);
ip->i_ffs1_size = ip->i_size;
lfs_dino_setsize(fs, ip->i_din, ip->i_size);
uvm_vnp_setsize(vp, ip->i_size);
maxino = ((ip->i_size >> lfs_sb_getbshift(fs)) - lfs_sb_getcleansz(fs) -

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_balloc.c,v 1.86 2015/08/02 18:18:46 dholland Exp $ */
/* $NetBSD: lfs_balloc.c,v 1.87 2015/09/01 06:08:37 dholland Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.86 2015/08/02 18:18:46 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.87 2015/09/01 06:08:37 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@ -160,8 +160,8 @@ lfs_balloc(struct vnode *vp, off_t startoffset, int iosize, kauth_cred_t cred,
lastblock,
(bpp ? &bp : NULL), cred)))
return (error);
ip->i_ffs1_size = ip->i_size =
(lastblock + 1) * lfs_sb_getbsize(fs);
ip->i_size = (lastblock + 1) * lfs_sb_getbsize(fs);
lfs_dino_setsize(fs, ip->i_din, ip->i_size);
uvm_vnp_setsize(vp, ip->i_size);
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (bpp)
@ -195,7 +195,7 @@ lfs_balloc(struct vnode *vp, off_t startoffset, int iosize, kauth_cred_t cred,
mutex_enter(&lfs_lock);
lfs_sb_subbfree(fs, frags);
mutex_exit(&lfs_lock);
ip->i_ffs1_db[lbn] = UNWRITTEN;
lfs_dino_setdb(fs, ip->i_din, lbn, UNWRITTEN);
} else {
if (nsize <= osize) {
/* No need to extend */
@ -245,15 +245,15 @@ lfs_balloc(struct vnode *vp, off_t startoffset, int iosize, kauth_cred_t cred,
}
if (daddr == UNASSIGNED) {
if (num > 0 && ip->i_ffs1_ib[indirs[0].in_off] == 0) {
ip->i_ffs1_ib[indirs[0].in_off] = UNWRITTEN;
if (num > 0 && lfs_dino_getib(fs, ip->i_din, indirs[0].in_off) == 0) {
lfs_dino_setib(fs, ip->i_din, indirs[0].in_off, UNWRITTEN);
}
/*
* Create new indirect blocks if necessary
*/
if (num > 1) {
idaddr = ip->i_ffs1_ib[indirs[0].in_off];
idaddr = lfs_dino_getib(fs, ip->i_din, indirs[0].in_off);
for (i = 1; i < num; ++i) {
ibp = getblk(vp, indirs[i].in_lbn,
lfs_sb_getbsize(fs), 0,0);
@ -322,10 +322,10 @@ lfs_balloc(struct vnode *vp, off_t startoffset, int iosize, kauth_cred_t cred,
switch (num) {
case 0:
ip->i_ffs1_db[lbn] = UNWRITTEN;
lfs_dino_setdb(fs, ip->i_din, lbn, UNWRITTEN);
break;
case 1:
ip->i_ffs1_ib[indirs[0].in_off] = UNWRITTEN;
lfs_dino_setib(fs, ip->i_din, indirs[0].in_off, UNWRITTEN);
break;
default:
idp = &indirs[num - 1];

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_inode.c,v 1.145 2015/08/19 20:33:29 dholland Exp $ */
/* $NetBSD: lfs_inode.c,v 1.146 2015/09/01 06:08:37 dholland Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.145 2015/08/19 20:33:29 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.146 2015/09/01 06:08:37 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@ -204,8 +204,8 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
daddr_t lastblock;
struct inode *oip = VTOI(ovp);
daddr_t bn, lbn, lastiblock[ULFS_NIADDR], indir_lbn[ULFS_NIADDR];
/* XXX ondisk32 */
int32_t newblks[ULFS_NDADDR + ULFS_NIADDR];
/* note: newblks is set but only actually used if DIAGNOSTIC */
daddr_t newblks[ULFS_NDADDR + ULFS_NIADDR] __diagused;
struct lfs *fs;
struct buf *bp;
int offset, size, level;
@ -242,13 +242,14 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
if (ovp->v_type == VLNK &&
(oip->i_size < fs->um_maxsymlinklen ||
(fs->um_maxsymlinklen == 0 &&
oip->i_ffs1_blocks == 0))) {
lfs_dino_getblocks(fs, oip->i_din) == 0))) {
#ifdef DIAGNOSTIC
if (length != 0)
panic("lfs_truncate: partial truncate of symlink");
#endif
memset((char *)SHORTLINK(oip), 0, (u_int)oip->i_size);
oip->i_size = oip->i_ffs1_size = 0;
oip->i_size = 0;
lfs_dino_setsize(fs, oip->i_din, 0);
oip->i_flag |= IN_CHANGE | IN_UPDATE;
return (lfs_update(ovp, NULL, NULL, 0));
}
@ -319,7 +320,8 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
-lfs_btofsb(fs, (ULFS_NIADDR + 2) << lfs_sb_getbshift(fs)));
if (error)
return (error);
oip->i_ffs1_size = oip->i_size = length;
oip->i_size = length;
lfs_dino_setsize(fs, oip->i_din, oip->i_size);
uvm_vnp_setsize(ovp, length);
(void) VOP_BWRITE(bp->b_vp, bp);
oip->i_flag |= IN_CHANGE | IN_UPDATE;
@ -347,7 +349,8 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
if (ovp != fs->lfs_ivnode)
lfs_seglock(fs, SEGM_PROT);
if (offset == 0) {
oip->i_size = oip->i_ffs1_size = length;
oip->i_size = length;
lfs_dino_setsize(fs, oip->i_din, oip->i_size);
} else if (!usepc) {
lbn = lfs_lblkno(fs, length);
aflags = B_CLRBUF;
@ -361,7 +364,8 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
}
obufsize = bp->b_bufsize;
odb = lfs_btofsb(fs, bp->b_bcount);
oip->i_size = oip->i_ffs1_size = length;
oip->i_size = length;
lfs_dino_setsize(fs, oip->i_din, oip->i_size);
size = lfs_blksize(fs, oip, lbn);
if (ovp->v_type != VDIR)
memset((char *)bp->b_data + offset, 0,
@ -420,7 +424,8 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
genfs_node_wrlock(ovp);
oip->i_size = oip->i_ffs1_size = length;
oip->i_size = length;
lfs_dino_setsize(fs, oip->i_din, oip->i_size);
uvm_vnp_setsize(ovp, length);
/*
@ -443,7 +448,12 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
* freeing blocks. lastiblock values are also normalized to -1
* for calls to lfs_indirtrunc below.
*/
memcpy((void *)newblks, (void *)&oip->i_ffs1_db[0], sizeof newblks);
for (i=0; i<ULFS_NDADDR; i++) {
newblks[i] = lfs_dino_getdb(fs, oip->i_din, i);
}
for (i=0; i<ULFS_NIADDR; i++) {
newblks[ULFS_NDADDR + i] = lfs_dino_getib(fs, oip->i_din, i);
}
for (level = TRIPLE; level >= SINGLE; level--)
if (lastiblock[level] < 0) {
newblks[ULFS_NDADDR+level] = 0;
@ -452,7 +462,8 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
for (i = ULFS_NDADDR - 1; i > lastblock; i--)
newblks[i] = 0;
oip->i_size = oip->i_ffs1_size = osize;
oip->i_size = osize;
lfs_dino_setsize(fs, oip->i_din, oip->i_size);
error = lfs_vtruncbuf(ovp, lastblock + 1, false, 0);
if (error && !allerror)
allerror = error;
@ -464,7 +475,7 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
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];
bn = lfs_dino_getib(fs, oip->i_din, level);
if (bn != 0) {
error = lfs_indirtrunc(oip, indir_lbn[level],
bn, lastiblock[level],
@ -475,10 +486,10 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
real_released += rcount;
blocksreleased += count;
if (lastiblock[level] < 0) {
if (oip->i_ffs1_ib[level] > 0)
if (lfs_dino_getib(fs, oip->i_din, level) > 0)
real_released += nblocks;
blocksreleased += nblocks;
oip->i_ffs1_ib[level] = 0;
lfs_dino_setib(fs, oip->i_din, level, 0);
lfs_blkfree(fs, oip, bn, lfs_sb_getbsize(fs),
&lastseg, &bc);
lfs_deregister_block(ovp, bn);
@ -494,11 +505,11 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
for (i = ULFS_NDADDR - 1; i > lastblock; i--) {
long bsize, obsize;
bn = oip->i_ffs1_db[i];
bn = lfs_dino_getdb(fs, oip->i_din, i);
if (bn == 0)
continue;
bsize = lfs_blksize(fs, oip, i);
if (oip->i_ffs1_db[i] > 0) {
if (lfs_dino_getdb(fs, oip->i_din, i) > 0) {
/* Check for fragment size changes */
obsize = oip->i_lfs_fragsize[i];
real_released += lfs_btofsb(fs, obsize);
@ -506,7 +517,7 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
} else
obsize = 0;
blocksreleased += lfs_btofsb(fs, bsize);
oip->i_ffs1_db[i] = 0;
lfs_dino_setdb(fs, oip->i_din, i, 0);
lfs_blkfree(fs, oip, bn, obsize, &lastseg, &bc);
lfs_deregister_block(ovp, bn);
}
@ -517,7 +528,7 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
* Finally, look for a change in size of the
* last direct block; release any frags.
*/
bn = oip->i_ffs1_db[lastblock];
bn = lfs_dino_getdb(fs, oip->i_din, lastblock);
if (bn != 0) {
long oldspace, newspace;
#if 0
@ -533,7 +544,8 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
olddspace = oip->i_lfs_fragsize[lastblock];
#endif
oip->i_size = oip->i_ffs1_size = length;
oip->i_size = length;
lfs_dino_setsize(fs, oip->i_din, oip->i_size);
newspace = lfs_blksize(fs, oip, lastblock);
if (newspace == 0)
panic("itrunc: newspace");
@ -554,11 +566,12 @@ done:
#ifdef DIAGNOSTIC
for (level = SINGLE; level <= TRIPLE; level++)
if ((newblks[ULFS_NDADDR + level] == 0) !=
((oip->i_ffs1_ib[level]) == 0)) {
(lfs_dino_getib(fs, oip->i_din, level) == 0)) {
panic("lfs itrunc1");
}
for (i = 0; i < ULFS_NDADDR; i++)
if ((newblks[i] == 0) != (oip->i_ffs1_db[i] == 0)) {
if ((newblks[i] == 0) !=
(lfs_dino_getdb(fs, oip->i_din, i) == 0)) {
panic("lfs itrunc2");
}
if (length == 0 &&
@ -568,17 +581,20 @@ done:
/*
* Put back the real size.
*/
oip->i_size = oip->i_ffs1_size = length;
oip->i_size = length;
lfs_dino_setsize(fs, oip->i_din, oip->i_size);
oip->i_lfs_effnblks -= blocksreleased;
oip->i_ffs1_blocks -= real_released;
lfs_dino_setblocks(fs, oip->i_din,
lfs_dino_getblocks(fs, oip->i_din) - real_released);
mutex_enter(&lfs_lock);
lfs_sb_addbfree(fs, blocksreleased);
mutex_exit(&lfs_lock);
#ifdef DIAGNOSTIC
if (oip->i_size == 0 &&
(oip->i_ffs1_blocks != 0 || oip->i_lfs_effnblks != 0)) {
printf("lfs_truncate: truncate to 0 but %d blks/%jd effblks\n",
oip->i_ffs1_blocks, (intmax_t)oip->i_lfs_effnblks);
(lfs_dino_getblocks(fs, oip->i_din) != 0 || oip->i_lfs_effnblks != 0)) {
printf("lfs_truncate: truncate to 0 but %jd blks/%jd effblks\n",
(intmax_t)lfs_dino_getblocks(fs, oip->i_din),
(intmax_t)oip->i_lfs_effnblks);
panic("lfs_truncate: persistent blocks");
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_inode.h,v 1.10 2015/08/19 20:33:29 dholland Exp $ */
/* $NetBSD: lfs_inode.h,v 1.11 2015/09/01 06:08:37 dholland Exp $ */
/* from NetBSD: ulfs_inode.h,v 1.5 2013/06/06 00:51:50 dholland Exp */
/* from NetBSD: inode.h,v 1.64 2012/11/19 00:36:21 jakllsch Exp */
@ -155,51 +155,6 @@ struct inode {
union lfs_dinode *i_din;
};
#define i_ffs1_atime i_din->u_32.di_atime
#define i_ffs1_atimensec i_din->u_32.di_atimensec
#define i_ffs1_blocks i_din->u_32.di_blocks
#define i_ffs1_ctime i_din->u_32.di_ctime
#define i_ffs1_ctimensec i_din->u_32.di_ctimensec
#define i_ffs1_db i_din->u_32.di_db
#define i_ffs1_flags i_din->u_32.di_flags
#define i_ffs1_gen i_din->u_32.di_gen
#define i_ffs1_gid i_din->u_32.di_gid
#define i_ffs1_ib i_din->u_32.di_ib
#define i_ffs1_mode i_din->u_32.di_mode
#define i_ffs1_mtime i_din->u_32.di_mtime
#define i_ffs1_mtimensec i_din->u_32.di_mtimensec
#define i_ffs1_nlink i_din->u_32.di_nlink
#define i_ffs1_rdev i_din->u_32.di_rdev
#define i_ffs1_size i_din->u_32.di_size
#define i_ffs1_uid i_din->u_32.di_uid
#define i_ffs1_modrev i_din->u_32.di_modrev
#define i_ffs2_atime i_din->u_64.di_atime
#define i_ffs2_atimensec i_din->u_64.di_atimensec
#define i_ffs2_birthtime i_din->u_64.di_birthtime
#define i_ffs2_birthnsec i_din->u_64.di_birthnsec
#define i_ffs2_blocks i_din->u_64.di_blocks
#define i_ffs2_blksize i_din->u_64.di_blksize
#define i_ffs2_ctime i_din->u_64.di_ctime
#define i_ffs2_ctimensec i_din->u_64.di_ctimensec
#define i_ffs2_db i_din->u_64.di_db
#define i_ffs2_flags i_din->u_64.di_flags
#define i_ffs2_gen i_din->u_64.di_gen
#define i_ffs2_gid i_din->u_64.di_gid
#define i_ffs2_ib i_din->u_64.di_ib
#define i_ffs2_mode i_din->u_64.di_mode
#define i_ffs2_mtime i_din->u_64.di_mtime
#define i_ffs2_mtimensec i_din->u_64.di_mtimensec
#define i_ffs2_nlink i_din->u_64.di_nlink
#define i_ffs2_rdev i_din->u_64.di_rdev
#define i_ffs2_size i_din->u_64.di_size
#define i_ffs2_uid i_din->u_64.di_uid
#define i_ffs2_kernflags i_din->u_64.di_kernflags
#define i_ffs2_extsize i_din->u_64.di_extsize
#define i_ffs2_extb i_din->u_64.di_extb
#define i_ffs2_inumber i_din->u_64.di_inumber
#define i_ffs2_modrev i_din->u_64.di_modrev
/* These flags are kept in i_flag. */
#define IN_ACCESS 0x0001 /* Access time update request. */
#define IN_CHANGE 0x0002 /* Inode change time update request. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_itimes.c,v 1.18 2015/08/12 18:25:52 dholland Exp $ */
/* $NetBSD: lfs_itimes.c,v 1.19 2015/09/01 06:08:37 dholland Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_itimes.c,v 1.18 2015/08/12 18:25:52 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_itimes.c,v 1.19 2015/09/01 06:08:37 dholland Exp $");
#include <sys/param.h>
#include <sys/time.h>
@ -57,6 +57,7 @@ void
lfs_itimes(struct inode *ip, const struct timespec *acc,
const struct timespec *mod, const struct timespec *cre)
{
struct lfs *fs = ip->i_lfs;
#ifdef _KERNEL
struct timespec now;
@ -70,14 +71,13 @@ lfs_itimes(struct inode *ip, const struct timespec *acc,
if (acc == NULL)
acc = &now;
#endif
ip->i_ffs1_atime = acc->tv_sec;
ip->i_ffs1_atimensec = acc->tv_nsec;
if (ip->i_lfs->lfs_is64 || lfs_sb_getversion(ip->i_lfs) > 1) {
struct lfs *fs = ip->i_lfs;
lfs_dino_setatime(fs, ip->i_din, acc->tv_sec);
lfs_dino_setatimensec(fs, ip->i_din, acc->tv_nsec);
if (fs->lfs_is64 || lfs_sb_getversion(fs) > 1) {
struct buf *ibp;
IFILE *ifp;
LFS_IENTRY(ifp, ip->i_lfs, ip->i_number, ibp);
LFS_IENTRY(ifp, fs, ip->i_number, ibp);
lfs_if_setatime_sec(fs, ifp, acc->tv_sec);
lfs_if_setatime_nsec(fs, ifp, acc->tv_nsec);
LFS_BWRITE_LOG(ibp);
@ -96,8 +96,8 @@ lfs_itimes(struct inode *ip, const struct timespec *acc,
if (mod == NULL)
mod = &now;
#endif
ip->i_ffs1_mtime = mod->tv_sec;
ip->i_ffs1_mtimensec = mod->tv_nsec;
lfs_dino_setmtime(fs, ip->i_din, mod->tv_sec);
lfs_dino_setmtimensec(fs, ip->i_din, mod->tv_nsec);
ip->i_modrev++;
}
if (ip->i_flag & (IN_CHANGE | IN_MODIFY)) {
@ -105,8 +105,8 @@ lfs_itimes(struct inode *ip, const struct timespec *acc,
if (cre == NULL)
cre = &now;
#endif
ip->i_ffs1_ctime = cre->tv_sec;
ip->i_ffs1_ctimensec = cre->tv_nsec;
lfs_dino_setctime(fs, ip->i_din, cre->tv_sec);
lfs_dino_setctimensec(fs, ip->i_din, cre->tv_nsec);
}
mutex_enter(&lfs_lock);
if (ip->i_flag & (IN_CHANGE | IN_UPDATE))

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_rfw.c,v 1.30 2015/08/19 20:33:29 dholland Exp $ */
/* $NetBSD: lfs_rfw.c,v 1.31 2015/09/01 06:08:37 dholland 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.30 2015/08/19 20:33:29 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_rfw.c,v 1.31 2015/09/01 06:08:37 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@ -124,12 +124,13 @@ lfs_rf_valloc(struct lfs *fs, ino_t ino, int vers, struct lwp *l,
return 0;
else if (ip->i_gen < vers) {
lfs_truncate(vp, (off_t)0, 0, NOCRED);
ip->i_gen = ip->i_ffs1_gen = vers;
ip->i_gen = vers;
lfs_dino_setgen(fs, ip->i_din, vers);
LFS_SET_UINO(ip, IN_CHANGE | IN_UPDATE);
return 0;
} else {
DLOG((DLOG_RF, "ino %d: sought version %d, got %d\n",
ino, vers, ip->i_ffs1_gen));
ino, vers, lfs_dino_getgen(fs, ip->i_din)));
vput(vp);
*vpp = NULLVP;
return EEXIST;
@ -152,7 +153,8 @@ lfs_rf_valloc(struct lfs *fs, ino_t ino, int vers, struct lwp *l,
return error;
}
ip = VTOI(vp);
ip->i_nlink = ip->i_ffs1_nlink = 1;
ip->i_nlink = 1;
lfs_dino_setnlink(fs, ip->i_din, 1);
*vpp = vp;
return 0;
}
@ -208,11 +210,13 @@ update_meta(struct lfs *fs, ino_t ino, int vers, daddr_t lbn,
if (ip->i_size <= (lbn << lfs_sb_getbshift(fs))) {
u_int64_t newsize;
if (lbn < ULFS_NDADDR)
newsize = ip->i_ffs1_size = (lbn << lfs_sb_getbshift(fs)) +
if (lbn < ULFS_NDADDR) {
newsize = (lbn << lfs_sb_getbshift(fs)) +
(size - lfs_sb_getfsize(fs)) + 1;
else
newsize = ip->i_ffs1_size = (lbn << lfs_sb_getbshift(fs)) + 1;
} else {
newsize = (lbn << lfs_sb_getbshift(fs)) + 1;
}
lfs_dino_setsize(fs, ip->i_din, newsize);
if (ip->i_size < newsize) {
ip->i_size = newsize;
@ -232,8 +236,8 @@ update_meta(struct lfs *fs, ino_t ino, int vers, daddr_t lbn,
/* differences here should be due to UNWRITTEN indirect blocks. */
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);
ip->i_lfs_effnblks == lfs_dino_getblocks(fs, ip->i_din)) ||
ip->i_lfs_effnblks >= lfs_dino_getblocks(fs, ip->i_din));
#ifdef DEBUG
/* Now look again to make sure it worked */

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_segment.c,v 1.258 2015/08/21 07:35:56 hannken Exp $ */
/* $NetBSD: lfs_segment.c,v 1.259 2015/09/01 06:08:37 dholland Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.258 2015/08/21 07:35:56 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.259 2015/09/01 06:08:37 dholland Exp $");
#ifdef DEBUG
# define vndebug(vp, str) do { \
@ -175,8 +175,8 @@ lfs_imtime(struct lfs *fs)
ASSERT_MAYBE_SEGLOCK(fs);
vfs_timestamp(&ts);
ip = VTOI(fs->lfs_ivnode);
ip->i_ffs1_mtime = ts.tv_sec;
ip->i_ffs1_mtimensec = ts.tv_nsec;
lfs_dino_setmtime(fs, ip->i_din, ts.tv_sec);
lfs_dino_setmtimensec(fs, ip->i_din, ts.tv_nsec);
}
/*
@ -1200,17 +1200,17 @@ lfs_writeinode(struct lfs *fs, struct segment *sp, struct inode *ip)
*/
/* Check file size based on highest allocated block */
if (((ip->i_ffs1_mode & LFS_IFMT) == LFS_IFREG ||
(ip->i_ffs1_mode & LFS_IFMT) == LFS_IFDIR) &&
if (((lfs_dino_getmode(fs, ip->i_din) & LFS_IFMT) == LFS_IFREG ||
(lfs_dino_getmode(fs, ip->i_din) & LFS_IFMT) == LFS_IFDIR) &&
ip->i_size > ((ip->i_lfs_hiblk + 1) << lfs_sb_getbshift(fs))) {
lfs_dino_setsize(fs, cdp, (ip->i_lfs_hiblk + 1) << lfs_sb_getbshift(fs));
DLOG((DLOG_SEG, "lfs_writeinode: ino %d size %" PRId64 " -> %"
PRId64 "\n", (int)ip->i_number, ip->i_size, lfs_dino_getsize(fs, cdp)));
}
if (ip->i_lfs_effnblks != ip->i_ffs1_blocks) {
if (ip->i_lfs_effnblks != lfs_dino_getblocks(fs, ip->i_din)) {
DLOG((DLOG_SEG, "lfs_writeinode: cleansing ino %d eff %jd != nblk %d)"
" at %jx\n", ip->i_number, (intmax_t)ip->i_lfs_effnblks,
ip->i_ffs1_blocks, (uintmax_t)lfs_sb_getoffset(fs)));
lfs_dino_getblocks(fs, ip->i_din), (uintmax_t)lfs_sb_getoffset(fs)));
for (i=0; i<ULFS_NDADDR; i++) {
if (lfs_dino_getdb(fs, cdp, i) == UNWRITTEN) {
DLOG((DLOG_SEG, "lfs_writeinode: wiping UNWRITTEN\n"));
@ -1253,12 +1253,12 @@ lfs_writeinode(struct lfs *fs, struct segment *sp, struct inode *ip)
/* XXX IN_ALLMOD */
LFS_CLR_UINO(ip, IN_ACCESSED | IN_ACCESS | IN_CHANGE |
IN_UPDATE | IN_MODIFY);
if (ip->i_lfs_effnblks == ip->i_ffs1_blocks)
if (ip->i_lfs_effnblks == lfs_dino_getblocks(fs, ip->i_din))
LFS_CLR_UINO(ip, IN_MODIFIED);
else {
DLOG((DLOG_VNODE, "lfs_writeinode: ino %d: real "
"blks=%d, eff=%jd\n", ip->i_number,
ip->i_ffs1_blocks, (intmax_t)ip->i_lfs_effnblks));
lfs_dino_getblocks(fs, ip->i_din), (intmax_t)ip->i_lfs_effnblks));
}
}
@ -1483,23 +1483,26 @@ lfs_update_single(struct lfs *fs, struct segment *sp,
bb = lfs_numfrags(fs, size);
switch (num) {
case 0:
ooff = ip->i_ffs1_db[lbn];
ooff = lfs_dino_getdb(fs, ip->i_din, lbn);
DEBUG_OOFF(0);
if (ooff == UNWRITTEN)
ip->i_ffs1_blocks += bb;
lfs_dino_setblocks(fs, ip->i_din,
lfs_dino_getblocks(fs, ip->i_din) + bb);
else {
/* possible fragment truncation or extension */
obb = lfs_btofsb(fs, ip->i_lfs_fragsize[lbn]);
ip->i_ffs1_blocks += (bb - obb);
lfs_dino_setblocks(fs, ip->i_din,
lfs_dino_getblocks(fs, ip->i_din) + (bb-obb));
}
ip->i_ffs1_db[lbn] = ndaddr;
lfs_dino_setdb(fs, ip->i_din, lbn, ndaddr);
break;
case 1:
ooff = ip->i_ffs1_ib[a[0].in_off];
ooff = lfs_dino_getib(fs, ip->i_din, a[0].in_off);
DEBUG_OOFF(1);
if (ooff == UNWRITTEN)
ip->i_ffs1_blocks += bb;
ip->i_ffs1_ib[a[0].in_off] = ndaddr;
lfs_dino_setblocks(fs, ip->i_din,
lfs_dino_getblocks(fs, ip->i_din) + bb);
lfs_dino_setib(fs, ip->i_din, a[0].in_off, ndaddr);
break;
default:
ap = &a[num - 1];
@ -1508,13 +1511,12 @@ lfs_update_single(struct lfs *fs, struct segment *sp,
panic("lfs_updatemeta: bread bno %" PRId64,
ap->in_lbn);
/* XXX ondisk32 */
ooff = ((int32_t *)bp->b_data)[ap->in_off];
ooff = lfs_iblock_get(fs, bp->b_data, ap->in_off);
DEBUG_OOFF(num);
if (ooff == UNWRITTEN)
ip->i_ffs1_blocks += bb;
/* XXX ondisk32 */
((int32_t *)bp->b_data)[ap->in_off] = ndaddr;
lfs_dino_setblocks(fs, ip->i_din,
lfs_dino_getblocks(fs, ip->i_din) + bb);
lfs_iblock_set(fs, bp->b_data, ap->in_off, ndaddr);
(void) VOP_BWRITE(bp->b_vp, bp);
}
@ -2145,12 +2147,12 @@ lfs_writeseg(struct lfs *fs, struct segment *sp)
* XXX See comment in lfs_writefile.
*/
if (bp->b_lblkno < 0 && bp->b_vp != devvp && bp->b_vp &&
VTOI(bp->b_vp)->i_ffs1_blocks !=
lfs_dino_getblocks(fs, VTOI(bp->b_vp)->i_din) !=
VTOI(bp->b_vp)->i_lfs_effnblks) {
DLOG((DLOG_VNODE, "lfs_writeseg: cleansing ino %d (%jd != %d)\n",
VTOI(bp->b_vp)->i_number,
(intmax_t)VTOI(bp->b_vp)->i_lfs_effnblks,
VTOI(bp->b_vp)->i_ffs1_blocks));
lfs_dino_getblocks(fs, VTOI(bp->b_vp)->i_din)));
/* Make a copy we'll make changes to */
newbp = lfs_newbuf(fs, bp->b_vp, bp->b_lblkno,
bp->b_bcount, LFS_NB_IBLOCK);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_syscalls.c,v 1.169 2015/08/12 18:28:01 dholland Exp $ */
/* $NetBSD: lfs_syscalls.c,v 1.170 2015/09/01 06:08:37 dholland 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.169 2015/08/12 18:28:01 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.170 2015/09/01 06:08:37 dholland Exp $");
#ifndef LFS
# define LFS /* for prototypes in syscallargs.h */
@ -248,7 +248,7 @@ lfs_markv(struct lwp *l, fsid_t *fsidp, BLOCK_INFO *blkiov,
if (fs->lfs_ronly)
return EROFS;
maxino = (lfs_fragstoblks(fs, VTOI(fs->lfs_ivnode)->i_ffs1_blocks) -
maxino = (lfs_fragstoblks(fs, lfs_dino_getblocks(fs, VTOI(fs->lfs_ivnode)->i_din)) -
lfs_sb_getcleansz(fs) - lfs_sb_getsegtabsz(fs)) * lfs_sb_getifpb(fs);
cnt = blkcnt;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_vfsops.c,v 1.341 2015/08/19 20:33:29 dholland Exp $ */
/* $NetBSD: lfs_vfsops.c,v 1.342 2015/09/01 06:08:37 dholland 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.341 2015/08/19 20:33:29 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.342 2015/09/01 06:08:37 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_lfs.h"
@ -1661,8 +1661,8 @@ again:
out:
if (lfs_sb_getversion(fs) > 1) {
ip->i_ffs1_atime = ts.tv_sec;
ip->i_ffs1_atimensec = ts.tv_nsec;
lfs_dino_setatime(fs, ip->i_din, ts.tv_sec);
lfs_dino_setatimensec(fs, ip->i_din, ts.tv_nsec);
}
lfs_vinit(mp, &vp);
@ -1721,7 +1721,7 @@ lfs_newvnode(struct mount *mp, struct vnode *dvp, struct vnode *vp,
/* Set a new generation number for this inode. */
ip->i_gen = gen;
ip->i_ffs1_gen = gen;
lfs_dino_setgen(fs, ip->i_din, gen);
memset(ip->i_lfs_fragsize, 0,
ULFS_NDADDR * sizeof(*ip->i_lfs_fragsize));
@ -1757,11 +1757,12 @@ lfs_newvnode(struct mount *mp, struct vnode *dvp, struct vnode *vp,
* Want to be able to use this to make badblock
* inodes, so don't truncate the dev number.
*/
// XXX clean this up
if (ump->um_fstype == ULFS1)
ip->i_ffs1_rdev = ulfs_rw32(vap->va_rdev,
ip->i_din->u_32.di_rdev = ulfs_rw32(vap->va_rdev,
ULFS_MPNEEDSWAP(fs));
else
ip->i_ffs2_rdev = ulfs_rw64(vap->va_rdev,
ip->i_din->u_64.di_rdev = ulfs_rw64(vap->va_rdev,
ULFS_MPNEEDSWAP(fs));
}
lfs_vinit(mp, &vp);
@ -1791,7 +1792,7 @@ lfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
return ESTALE;
if (lfh.lfid_ino >
((VTOI(fs->lfs_ivnode)->i_ffs1_size >> lfs_sb_getbshift(fs)) -
((lfs_dino_getsize(fs, VTOI(fs->lfs_ivnode)->i_din) >> lfs_sb_getbshift(fs)) -
lfs_sb_getcleansz(fs) - lfs_sb_getsegtabsz(fs)) * lfs_sb_getifpb(fs))
return ESTALE;
@ -2203,16 +2204,16 @@ lfs_vinit(struct mount *mp, struct vnode **vpp)
struct lfs *fs = ump->um_lfs;
int i;
ip->i_mode = ip->i_ffs1_mode;
ip->i_nlink = ip->i_ffs1_nlink;
ip->i_lfs_osize = ip->i_size = ip->i_ffs1_size;
ip->i_flags = ip->i_ffs1_flags;
ip->i_gen = ip->i_ffs1_gen;
ip->i_uid = ip->i_ffs1_uid;
ip->i_gid = ip->i_ffs1_gid;
ip->i_mode = lfs_dino_getmode(fs, ip->i_din);
ip->i_nlink = lfs_dino_getnlink(fs, ip->i_din);
ip->i_lfs_osize = ip->i_size = lfs_dino_getsize(fs, ip->i_din);
ip->i_flags = lfs_dino_getflags(fs, ip->i_din);
ip->i_gen = lfs_dino_getgen(fs, ip->i_din);
ip->i_uid = lfs_dino_getuid(fs, ip->i_din);
ip->i_gid = lfs_dino_getgid(fs, ip->i_din);
ip->i_lfs_effnblks = ip->i_ffs1_blocks;
ip->i_lfs_odnlink = ip->i_ffs1_nlink;
ip->i_lfs_effnblks = lfs_dino_getblocks(fs, ip->i_din);
ip->i_lfs_odnlink = lfs_dino_getnlink(fs, ip->i_din);
/*
* Initialize the vnode from the inode, check for aliases. In all
@ -2229,20 +2230,20 @@ lfs_vinit(struct mount *mp, struct vnode **vpp)
if ((vp->v_type == VBLK || vp->v_type == VCHR) &&
i == 0)
continue;
if (ip->i_ffs1_db[i] != 0) {
if (lfs_dino_getdb(fs, ip->i_din, i) != 0) {
lfs_dump_dinode(fs, ip->i_din);
panic("inconsistent inode (direct)");
}
}
for ( ; i < ULFS_NDADDR + ULFS_NIADDR; i++) {
if (ip->i_ffs1_ib[i - ULFS_NDADDR] != 0) {
if (lfs_dino_getib(fs, ip->i_din, i - ULFS_NDADDR) != 0) {
lfs_dump_dinode(fs, ip->i_din);
panic("inconsistent inode (indirect)");
}
}
#endif /* DEBUG */
for (i = 0; i < ULFS_NDADDR; i++)
if (ip->i_ffs1_db[i] != 0)
if (lfs_dino_getdb(fs, ip->i_din, i) != 0)
ip->i_lfs_fragsize[i] = lfs_blksize(fs, ip, i);
}
@ -2367,7 +2368,7 @@ lfs_resize_fs(struct lfs *fs, int newnsegs)
/* Register new ifile size */
ip->i_size += noff * lfs_sb_getbsize(fs);
ip->i_ffs1_size = ip->i_size;
lfs_dino_setsize(fs, ip->i_din, ip->i_size);
uvm_vnp_setsize(ivp, ip->i_size);
/* Copy the inode table to its new position */

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_vnops.c,v 1.287 2015/08/19 20:33:29 dholland Exp $ */
/* $NetBSD: lfs_vnops.c,v 1.288 2015/09/01 06:08:37 dholland Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -125,7 +125,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.287 2015/08/19 20:33:29 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.288 2015/09/01 06:08:37 dholland Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@ -1150,14 +1150,22 @@ lfs_getattr(void *v)
vap->va_nlink = ip->i_nlink;
vap->va_uid = ip->i_uid;
vap->va_gid = ip->i_gid;
vap->va_rdev = (dev_t)ip->i_ffs1_rdev;
switch (vp->v_type) {
case VBLK:
case VCHR:
vap->va_rdev = (dev_t)lfs_dino_getrdev(fs, ip->i_din);
break;
default:
vap->va_rdev = NODEV;
break;
}
vap->va_size = vp->v_size;
vap->va_atime.tv_sec = ip->i_ffs1_atime;
vap->va_atime.tv_nsec = ip->i_ffs1_atimensec;
vap->va_mtime.tv_sec = ip->i_ffs1_mtime;
vap->va_mtime.tv_nsec = ip->i_ffs1_mtimensec;
vap->va_ctime.tv_sec = ip->i_ffs1_ctime;
vap->va_ctime.tv_nsec = ip->i_ffs1_ctimensec;
vap->va_atime.tv_sec = lfs_dino_getatime(fs, ip->i_din);
vap->va_atime.tv_nsec = lfs_dino_getatimensec(fs, ip->i_din);
vap->va_mtime.tv_sec = lfs_dino_getmtime(fs, ip->i_din);
vap->va_mtime.tv_nsec = lfs_dino_getmtimensec(fs, ip->i_din);
vap->va_ctime.tv_sec = lfs_dino_getctime(fs, ip->i_din);
vap->va_ctime.tv_nsec = lfs_dino_getctimensec(fs, ip->i_din);
vap->va_flags = ip->i_flags;
vap->va_gen = ip->i_gen;
/* this doesn't belong here */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_bmap.c,v 1.6 2015/08/02 18:18:46 dholland Exp $ */
/* $NetBSD: ulfs_bmap.c,v 1.7 2015/09/01 06:08:37 dholland Exp $ */
/* from NetBSD: ufs_bmap.c,v 1.50 2013/01/22 09:39:18 dholland Exp */
/*
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ulfs_bmap.c,v 1.6 2015/08/02 18:18:46 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: ulfs_bmap.c,v 1.7 2015/09/01 06:08:37 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -172,10 +172,10 @@ ulfs_bmaparray(struct vnode *vp, daddr_t bn, daddr_t *bnp, struct indir *ap,
if (nump != NULL)
*nump = 0;
if (ump->um_fstype == ULFS1)
daddr = ulfs_fix_unwritten(ulfs_rw32(ip->i_ffs1_db[bn],
daddr = ulfs_fix_unwritten(ulfs_rw32(ip->i_din->u_32.di_db[bn],
ULFS_MPNEEDSWAP(fs)));
else
daddr = ulfs_rw64(ip->i_ffs2_db[bn],
daddr = ulfs_rw64(ip->i_din->u_64.di_db[bn],
ULFS_MPNEEDSWAP(fs));
*bnp = blkptrtodb(fs, daddr);
/*
@ -201,17 +201,17 @@ ulfs_bmaparray(struct vnode *vp, daddr_t bn, daddr_t *bnp, struct indir *ap,
if (ump->um_fstype == ULFS1) {
for (++bn; bn < ULFS_NDADDR && *runp < maxrun &&
is_sequential(fs,
ulfs_fix_unwritten(ulfs_rw32(ip->i_ffs1_db[bn - 1],
ulfs_fix_unwritten(ulfs_rw32(ip->i_din->u_32.di_db[bn - 1],
ULFS_MPNEEDSWAP(fs))),
ulfs_fix_unwritten(ulfs_rw32(ip->i_ffs1_db[bn],
ulfs_fix_unwritten(ulfs_rw32(ip->i_din->u_32.di_db[bn],
ULFS_MPNEEDSWAP(fs))));
++bn, ++*runp);
} else {
for (++bn; bn < ULFS_NDADDR && *runp < maxrun &&
is_sequential(fs,
ulfs_rw64(ip->i_ffs2_db[bn - 1],
ulfs_rw64(ip->i_din->u_64.di_db[bn - 1],
ULFS_MPNEEDSWAP(fs)),
ulfs_rw64(ip->i_ffs2_db[bn],
ulfs_rw64(ip->i_din->u_64.di_db[bn],
ULFS_MPNEEDSWAP(fs)));
++bn, ++*runp);
}
@ -228,11 +228,12 @@ ulfs_bmaparray(struct vnode *vp, daddr_t bn, daddr_t *bnp, struct indir *ap,
num = *nump;
/* Get disk address out of indirect block array */
// XXX clean this up
if (ump->um_fstype == ULFS1)
daddr = ulfs_fix_unwritten(ulfs_rw32(ip->i_ffs1_ib[xap->in_off],
daddr = ulfs_fix_unwritten(ulfs_rw32(ip->i_din->u_32.di_ib[xap->in_off],
ULFS_MPNEEDSWAP(fs)));
else
daddr = ulfs_rw64(ip->i_ffs2_ib[xap->in_off],
daddr = ulfs_rw64(ip->i_din->u_64.di_ib[xap->in_off],
ULFS_MPNEEDSWAP(fs));
for (bp = NULL, ++xap; --num; ++xap) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_inode.h,v 1.15 2015/08/12 18:28:01 dholland Exp $ */
/* $NetBSD: ulfs_inode.h,v 1.16 2015/09/01 06:08:37 dholland Exp $ */
/* from NetBSD: inode.h,v 1.64 2012/11/19 00:36:21 jakllsch Exp */
/*
@ -189,27 +189,28 @@ struct lfid {
*/
#define DIP(ip, field) \
(((ip)->i_ump->um_fstype == ULFS1) ? \
(ip)->i_ffs1_##field : (ip)->i_ffs2_##field)
(ip)->i_din->u_32.di_##field : (ip)->i_din->u_64.di_##field)
#define DIP_ASSIGN(ip, field, value) \
do { \
if ((ip)->i_ump->um_fstype == ULFS1) \
(ip)->i_ffs1_##field = (value); \
(ip)->i_din->u_32.di_##field = (value); \
else \
(ip)->i_ffs2_##field = (value); \
(ip)->i_din->u_64.di_##field = (value); \
} while(0)
#define DIP_ADD(ip, field, value) \
do { \
if ((ip)->i_ump->um_fstype == ULFS1) \
(ip)->i_ffs1_##field += (value); \
(ip)->i_din->u_32.di_##field += (value); \
else \
(ip)->i_ffs2_##field += (value); \
(ip)->i_din->u_64.di_##field += (value); \
} while(0)
/* XXX rework this better */
#define SHORTLINK(ip) \
(((ip)->i_ump->um_fstype == ULFS1) ? \
(void *)(ip)->i_ffs1_db : (void *)(ip)->i_ffs2_db)
(void *)(ip)->i_din->u_32.di_db : (void *)(ip)->i_din->u_64.di_db)
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_vnops.c,v 1.26 2015/05/31 15:48:03 hannken Exp $ */
/* $NetBSD: ulfs_vnops.c,v 1.27 2015/09/01 06:08:37 dholland Exp $ */
/* from NetBSD: ufs_vnops.c,v 1.213 2013/06/08 05:47:02 kardel Exp */
/*-
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.26 2015/05/31 15:48:03 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.27 2015/09/01 06:08:37 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_lfs.h"
@ -106,6 +106,7 @@ __KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.26 2015/05/31 15:48:03 hannken Exp
#endif
#include <ufs/lfs/lfs_extern.h>
#include <ufs/lfs/lfs.h>
#include <ufs/lfs/lfs_accessors.h>
#include <uvm/uvm.h>
@ -236,6 +237,7 @@ ulfs_setattr(void *v)
struct vattr *vap;
struct vnode *vp;
struct inode *ip;
struct lfs *fs;
kauth_cred_t cred;
struct lwp *l;
int error;
@ -245,6 +247,7 @@ ulfs_setattr(void *v)
vap = ap->a_vap;
vp = ap->a_vp;
ip = VTOI(vp);
fs = ip->i_lfs;
cred = ap->a_cred;
l = curlwp;
action = KAUTH_VNODE_WRITE_FLAGS;
@ -375,10 +378,9 @@ ulfs_setattr(void *v)
if (vp->v_mount->mnt_flag & MNT_RELATIME)
ip->i_flag |= IN_ACCESS;
}
if (vap->va_birthtime.tv_sec != VNOVAL &&
ip->i_ump->um_fstype == ULFS2) {
ip->i_ffs2_birthtime = vap->va_birthtime.tv_sec;
ip->i_ffs2_birthnsec = vap->va_birthtime.tv_nsec;
if (vap->va_birthtime.tv_sec != VNOVAL) {
lfs_dino_setbirthtime(fs, ip->i_din,
&vap->va_birthtime);
}
error = lfs_update(vp, &vap->va_atime, &vap->va_mtime, 0);
if (error)
@ -1140,11 +1142,12 @@ ulfs_vinit(struct mount *mntp, int (**specops)(void *), int (**fifoops)(void *),
case VBLK:
vp->v_op = specops;
ump = ip->i_ump;
// XXX clean this up
if (ump->um_fstype == ULFS1)
rdev = (dev_t)ulfs_rw32(ip->i_ffs1_rdev,
rdev = (dev_t)ulfs_rw32(ip->i_din->u_32.di_rdev,
ULFS_MPNEEDSWAP(ump->um_lfs));
else
rdev = (dev_t)ulfs_rw64(ip->i_ffs2_rdev,
rdev = (dev_t)ulfs_rw64(ip->i_din->u_64.di_rdev,
ULFS_MPNEEDSWAP(ump->um_lfs));
spec_node_init(vp, rdev);
break;