Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Part two of dinodes; use the same union everywhere.
details: https://anonhg.NetBSD.org/src/rev/1348fa12a589
branches: trunk
changeset: 810134:1348fa12a589
user: dholland <dholland%NetBSD.org@localhost>
date: Wed Aug 19 20:33:29 2015 +0000
description:
Part two of dinodes; use the same union everywhere.
(previously the ufs-derived code had things set up slightly different)
Remove a bunch of associated mess.
diffstat:
sbin/fsck_lfs/inode.c | 8 +--
sbin/fsck_lfs/lfs.c | 13 +----
sbin/fsck_lfs/lfs_user.h | 5 +-
sbin/fsck_lfs/pass6.c | 9 +---
sbin/fsck_lfs/segwrite.c | 17 +------
sbin/fsck_lfs/vnode.c | 4 +-
sbin/newfs_lfs/make_lfs.c | 20 ++++-----
sys/ufs/lfs/lfs_accessors.h | 19 ++++++++-
sys/ufs/lfs/lfs_inode.c | 9 +--
sys/ufs/lfs/lfs_inode.h | 93 +++++++++++++++++++++-----------------------
sys/ufs/lfs/lfs_rfw.c | 86 ++++++++++++++++++++++++++++-------------
sys/ufs/lfs/lfs_segment.c | 18 ++------
sys/ufs/lfs/lfs_vfsops.c | 33 ++++-----------
sys/ufs/lfs/lfs_vnops.c | 9 +--
14 files changed, 170 insertions(+), 173 deletions(-)
diffs (truncated from 702 to 300 lines):
diff -r 374604646fb0 -r 1348fa12a589 sbin/fsck_lfs/inode.c
--- a/sbin/fsck_lfs/inode.c Wed Aug 19 20:15:20 2015 +0000
+++ b/sbin/fsck_lfs/inode.c Wed Aug 19 20:33:29 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inode.c,v 1.59 2015/08/12 18:28:00 dholland Exp $ */
+/* $NetBSD: inode.c,v 1.60 2015/08/19 20:33:29 dholland Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -119,8 +119,7 @@
seg_table[segno].su_nbytes += DINOSIZE(fs);
brelse(bp, 0);
}
- // XXX bogus cast
- return (union lfs_dinode *)(VTOI(vp)->i_din.ffs1_din);
+ return VTOI(vp)->i_din;
}
/*
@@ -621,8 +620,7 @@
vp = lfs_valloc(fs, ino);
if (vp == NULL)
return (0);
- // XXX bogus cast
- dp = (union lfs_dinode *)(VTOI(vp)->i_din.ffs1_din);
+ dp = VTOI(vp)->i_din;
bp = getblk(vp, 0, lfs_sb_getfsize(fs));
VOP_BWRITE(bp);
lfs_dino_setmode(fs, dp, type);
diff -r 374604646fb0 -r 1348fa12a589 sbin/fsck_lfs/lfs.c
--- a/sbin/fsck_lfs/lfs.c Wed Aug 19 20:15:20 2015 +0000
+++ b/sbin/fsck_lfs/lfs.c Wed Aug 19 20:33:29 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs.c,v 1.56 2015/08/12 18:28:00 dholland Exp $ */
+/* $NetBSD: lfs.c,v 1.57 2015/08/19 20:33:29 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -356,9 +356,7 @@
ip = ecalloc(1, sizeof(*ip));
- dip = ecalloc(1, sizeof(*dip));
- // XXX bogus cast
- ip->i_din.ffs1_din = (struct lfs32_dinode *)dip;
+ ip->i_din = dip = ecalloc(1, sizeof(*dip));
/* Initialize the inode -- from lfs_vcreate. */
ip->inode_ext.lfs = ecalloc(1, sizeof(*ip->inode_ext.lfs));
@@ -381,12 +379,7 @@
free(vp);
return NULL;
}
- // XXX this should go away
- if (fs->lfs_is64) {
- memcpy(ip->i_din.ffs2_din, &dip->u_64, sizeof(dip->u_64));
- } else {
- memcpy(ip->i_din.ffs1_din, &dip->u_32, sizeof(dip->u_32));
- }
+ lfs_copy_dinode(fs, ip->i_din, dip);
brelse(bp, 0);
}
ip->i_number = ino;
diff -r 374604646fb0 -r 1348fa12a589 sbin/fsck_lfs/lfs_user.h
--- a/sbin/fsck_lfs/lfs_user.h Wed Aug 19 20:15:20 2015 +0000
+++ b/sbin/fsck_lfs/lfs_user.h Wed Aug 19 20:33:29 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_user.h,v 1.10 2015/08/12 18:28:00 dholland Exp $ */
+/* $NetBSD: lfs_user.h,v 1.11 2015/08/19 20:33:29 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -72,8 +72,7 @@
/* Convert between inode pointers and vnode pointers. */
#define VTOI(vp) ((struct inode *)(vp)->v_data)
-// XXX bogus cast
-#define VTOD(vp) ((union lfs_dinode *)(VTOI(vp)->i_din.ffs1_din))
+#define VTOD(vp) (VTOI(vp)->i_din)
#define sbdirty() ++fsdirty
diff -r 374604646fb0 -r 1348fa12a589 sbin/fsck_lfs/pass6.c
--- a/sbin/fsck_lfs/pass6.c Wed Aug 19 20:15:20 2015 +0000
+++ b/sbin/fsck_lfs/pass6.c Wed Aug 19 20:33:29 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass6.c,v 1.42 2015/08/12 18:28:00 dholland Exp $ */
+/* $NetBSD: pass6.c,v 1.43 2015/08/19 20:33:29 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -448,12 +448,7 @@
/* Copy over preexisting in-core inode, if any */
vp = vget(fs, thisino);
- /* XXX this is lame */
- if (fs->lfs_is64) {
- memcpy(VTOI(vp)->i_din.ffs2_din, &dp->u_64, sizeof(dp->u_64));
- } else {
- memcpy(VTOI(vp)->i_din.ffs1_din, &dp->u_32, sizeof(dp->u_32));
- }
+ lfs_copy_dinode(fs, VTOI(vp)->i_din, dp);
/* Finally account the inode itself */
sn = lfs_dtosn(fs, odaddr);
diff -r 374604646fb0 -r 1348fa12a589 sbin/fsck_lfs/segwrite.c
--- a/sbin/fsck_lfs/segwrite.c Wed Aug 19 20:15:20 2015 +0000
+++ b/sbin/fsck_lfs/segwrite.c Wed Aug 19 20:33:29 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: segwrite.c,v 1.41 2015/08/12 18:28:00 dholland Exp $ */
+/* $NetBSD: segwrite.c,v 1.42 2015/08/19 20:33:29 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -291,6 +291,7 @@
sp->sum_bytes_left -= sizeof(ulfs_daddr_t);
ndx = lfs_sb_getsumsize(fs) / sizeof(ulfs_daddr_t) -
sp->ninodes / LFS_INOPB(fs) - 1;
+ /* XXX ondisk32 */
((ulfs_daddr_t *) (sp->segsum))[ndx] = daddr;
}
/* Update the inode times and copy the inode onto the inode page. */
@@ -309,23 +310,13 @@
* already been gathered.
*/
if (ip->i_number == LFS_IFILE_INUM && sp->idp) {
- // XXX weak
- if (fs->lfs_is64) {
- sp->idp->u_64 = *ip->i_din.ffs2_din;
- } else {
- sp->idp->u_32 = *ip->i_din.ffs1_din;
- }
+ lfs_copy_dinode(fs, sp->idp, ip->i_din);
ip->i_lfs_osize = ip->i_ffs1_size;
return 0;
}
bp = sp->ibp;
cdp = DINO_IN_BLOCK(fs, bp->b_data, sp->ninodes % LFS_INOPB(fs));
- // XXX weak
- if (fs->lfs_is64) {
- cdp->u_64 = *ip->i_din.ffs2_din;
- } else {
- cdp->u_32 = *ip->i_din.ffs1_din;
- }
+ 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;
diff -r 374604646fb0 -r 1348fa12a589 sbin/fsck_lfs/vnode.c
--- a/sbin/fsck_lfs/vnode.c Wed Aug 19 20:15:20 2015 +0000
+++ b/sbin/fsck_lfs/vnode.c Wed Aug 19 20:33:29 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnode.c,v 1.14 2013/06/08 02:16:03 dholland Exp $ */
+/* $NetBSD: vnode.c,v 1.15 2015/08/19 20:33:29 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -141,7 +141,7 @@
buf_destroy(bp);
}
free(VTOI(tossvp)->inode_ext.lfs);
- free(VTOI(tossvp)->i_din.ffs1_din);
+ free(VTOI(tossvp)->i_din);
memset(VTOI(tossvp), 0, sizeof(struct inode));
free(tossvp->v_data);
memset(tossvp, 0, sizeof(*tossvp));
diff -r 374604646fb0 -r 1348fa12a589 sbin/newfs_lfs/make_lfs.c
--- a/sbin/newfs_lfs/make_lfs.c Wed Aug 19 20:15:20 2015 +0000
+++ b/sbin/newfs_lfs/make_lfs.c Wed Aug 19 20:33:29 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: make_lfs.c,v 1.43 2015/08/12 18:28:01 dholland Exp $ */
+/* $NetBSD: make_lfs.c,v 1.44 2015/08/19 20:33:29 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
#if 0
static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95";
#else
-__RCSID("$NetBSD: make_lfs.c,v 1.43 2015/08/12 18:28:01 dholland Exp $");
+__RCSID("$NetBSD: make_lfs.c,v 1.44 2015/08/19 20:33:29 dholland Exp $");
#endif
#endif /* not lint */
@@ -700,18 +700,17 @@
/*
* Initialize the Ifile inode. Do this before we do anything
* with the Ifile or segment tables.
+ *
+ * XXX: is there some reason this allocates a new dinode? we
+ * already have an empty one generated by vget.
*/
dip = malloc(sizeof(*dip));
if (dip == NULL)
err(1, NULL);
- // XXX lame
- if (fs->lfs_is64) {
- VTOI(fs->lfs_ivnode)->i_din.ffs2_din = &dip->u_64;
- } else {
- VTOI(fs->lfs_ivnode)->i_din.ffs1_din = &dip->u_32;
- }
+ memset(dip, 0, sizeof(*dip));
+
+ VTOI(fs->lfs_ivnode)->i_din = dip;
- memset(dip, 0, sizeof(*dip));
lfs_dino_setmode(fs, dip, LFS_IFREG | 0600);
lfs_dino_setflags(fs, dip, SF_IMMUTABLE);
make_dinode(LFS_IFILE_INUM, dip,
@@ -775,8 +774,7 @@
/* Initialize root directory */
vp = lfs_raw_vget(fs, ULFS_ROOTINO, devfd, 0x0);
- // XXX bogus cast
- dip = (union lfs_dinode *)VTOI(vp)->i_din.ffs1_din;
+ dip = VTOI(vp)->i_din;
make_dinode(ULFS_ROOTINO, dip, howmany(LFS_DIRBLKSIZ, lfs_sb_getfsize(fs)), fs);
lfs_dino_setmode(fs, dip, LFS_IFDIR | UMASK);
VTOI(vp)->i_lfs_osize = LFS_DIRBLKSIZ;
diff -r 374604646fb0 -r 1348fa12a589 sys/ufs/lfs/lfs_accessors.h
--- a/sys/ufs/lfs/lfs_accessors.h Wed Aug 19 20:15:20 2015 +0000
+++ b/sys/ufs/lfs/lfs_accessors.h Wed Aug 19 20:33:29 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_accessors.h,v 1.13 2015/08/12 18:28:01 dholland Exp $ */
+/* $NetBSD: lfs_accessors.h,v 1.14 2015/08/19 20:33:29 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 */
@@ -179,6 +179,23 @@
#define DINO_IN_BLOCK(fs, base, ix) \
((union lfs_dinode *)((char *)(base) + DINOSIZE(fs) * (ix)))
+static __unused inline void
+lfs_copy_dinode(STRUCT_LFS *fs,
+ union lfs_dinode *dst, const union lfs_dinode *src)
+{
+ /*
+ * We can do structure assignment of the structs, but not of
+ * the whole union, as the union is the size of the (larger)
+ * 64-bit struct and on a 32-bit fs the upper half of it might
+ * be off the end of a buffer or otherwise invalid.
+ */
+ if (fs->lfs_is64) {
+ dst->u_64 = src->u_64;
+ } else {
+ dst->u_32 = src->u_32;
+ }
+}
+
#define LFS_DEF_DINO_ACCESSOR(type, type32, field) \
static __unused inline type \
lfs_dino_get##field(STRUCT_LFS *fs, union lfs_dinode *dip) \
diff -r 374604646fb0 -r 1348fa12a589 sys/ufs/lfs/lfs_inode.c
--- a/sys/ufs/lfs/lfs_inode.c Wed Aug 19 20:15:20 2015 +0000
+++ b/sys/ufs/lfs/lfs_inode.c Wed Aug 19 20:33:29 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_inode.c,v 1.144 2015/08/12 18:28:01 dholland Exp $ */
+/* $NetBSD: lfs_inode.c,v 1.145 2015/08/19 20:33:29 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.144 2015/08/12 18:28:01 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.145 2015/08/19 20:33:29 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@@ -100,7 +100,6 @@
union lfs_dinode *
lfs_ifind(struct lfs *fs, ino_t ino, struct buf *bp)
{
- char *base = bp->b_data;
union lfs_dinode *ldip;
unsigned num, i;
@@ -112,12 +111,12 @@
*/
num = LFS_INOPB(fs);
for (i = num; i-- > 0; ) {
- ldip = (union lfs_dinode *)(base + i * DINOSIZE(fs));
+ ldip = DINO_IN_BLOCK(fs, bp->b_data, i);
if (lfs_dino_getinumber(fs, ldip) == ino)
return (ldip);
}
- printf("searched %u entries\n", num);
+ printf("searched %u entries for %ju\n", num, (uintmax_t)ino);
printf("offset is 0x%jx (seg %d)\n", (uintmax_t)lfs_sb_getoffset(fs),
lfs_dtosn(fs, lfs_sb_getoffset(fs)));
printf("block is 0x%jx (seg %d)\n",
diff -r 374604646fb0 -r 1348fa12a589 sys/ufs/lfs/lfs_inode.h
--- a/sys/ufs/lfs/lfs_inode.h Wed Aug 19 20:15:20 2015 +0000
+++ b/sys/ufs/lfs/lfs_inode.h Wed Aug 19 20:33:29 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_inode.h,v 1.9 2015/08/12 18:28:01 dholland Exp $ */
+/* $NetBSD: lfs_inode.h,v 1.10 2015/08/19 20:33:29 dholland Exp $ */
/* from NetBSD: ulfs_inode.h,v 1.5 2013/06/06 00:51:50 dholland Exp */
Home |
Main Index |
Thread Index |
Old Index