Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Make 32-bit and 64-bit versions of CLEANERINFO.
details: https://anonhg.NetBSD.org/src/rev/a2d32ce2a6d6
branches: trunk
changeset: 339826:a2d32ce2a6d6
user: dholland <dholland%NetBSD.org@localhost>
date: Wed Aug 12 18:25:03 2015 +0000
description:
Make 32-bit and 64-bit versions of CLEANERINFO.
XXX: while this is written to disk, it seems like much of it would
XXX: be better set up as a commpage shared with the cleaner.
diffstat:
libexec/lfs_cleanerd/cleaner.h | 2 -
libexec/lfs_cleanerd/coalesce.c | 6 +-
libexec/lfs_cleanerd/lfs_cleanerd.c | 44 +++++++++++++++--
sbin/fsck_lfs/pass0.c | 14 ++--
sbin/fsck_lfs/segwrite.c | 7 +-
sbin/newfs_lfs/make_lfs.c | 16 +++---
sys/ufs/lfs/lfs.h | 39 ++++++++++++----
sys/ufs/lfs/lfs_accessors.h | 87 +++++++++++++++++++++++++++++-------
sys/ufs/lfs/lfs_segment.c | 9 +--
sys/ufs/lfs/lfs_subr.c | 10 ++-
sys/ufs/lfs/lfs_syscalls.c | 14 ++--
sys/ufs/lfs/lfs_vfsops.c | 18 ++++---
sys/ufs/lfs/lfs_vnops.c | 9 ++-
usr.sbin/dumplfs/dumplfs.c | 19 ++++---
14 files changed, 199 insertions(+), 95 deletions(-)
diffs (truncated from 676 to 300 lines):
diff -r 69dd115e6d66 -r a2d32ce2a6d6 libexec/lfs_cleanerd/cleaner.h
--- a/libexec/lfs_cleanerd/cleaner.h Wed Aug 12 18:24:14 2015 +0000
+++ b/libexec/lfs_cleanerd/cleaner.h Wed Aug 12 18:25:03 2015 +0000
@@ -59,14 +59,12 @@
/* lfs_cleanerd.c */
void pwarn(const char *, ...);
void calc_cb(struct clfs *, int, struct clfs_seguse *);
-int clean_fs(struct clfs *, CLEANERINFO *);
void dlog(const char *, ...);
void handle_error(struct clfs **, int);
int init_fs(struct clfs *, char *);
int invalidate_segment(struct clfs *, int);
void lfs_ientry(IFILE **, struct clfs *, ino_t, struct ubuf **);
int load_segment(struct clfs *, int, BLOCK_INFO **, int *);
-int needs_cleaning(struct clfs *, CLEANERINFO *);
int reinit_fs(struct clfs *);
void reload_ifile(struct clfs *);
void toss_old_blocks(struct clfs *, BLOCK_INFO **, blkcnt_t *, int *);
diff -r 69dd115e6d66 -r a2d32ce2a6d6 libexec/lfs_cleanerd/coalesce.c
--- a/libexec/lfs_cleanerd/coalesce.c Wed Aug 12 18:24:14 2015 +0000
+++ b/libexec/lfs_cleanerd/coalesce.c Wed Aug 12 18:25:03 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: coalesce.c,v 1.29 2015/08/12 18:23:16 dholland Exp $ */
+/* $NetBSD: coalesce.c,v 1.30 2015/08/12 18:25:03 dholland Exp $ */
/*-
* Copyright (c) 2002, 2005 The NetBSD Foundation, Inc.
@@ -344,10 +344,10 @@
cip = *(CLEANERINFO *)bp->b_data;
brelse(bp, B_INVAL);
- if (cip.clean < 4) /* XXX magic number 4 */
+ if (lfs_ci_getclean(fs, &cip) < 4) /* XXX magic number 4 */
kops.ko_fcntl(fs->clfs_ifilefd,
LFCNSEGWAIT, NULL);
- } while(cip.clean < 4);
+ } while (lfs_ci_getclean(fs, &cip) < 4);
/*
* Note that although lim.blkcnt is 32 bits wide, bps
diff -r 69dd115e6d66 -r a2d32ce2a6d6 libexec/lfs_cleanerd/lfs_cleanerd.c
--- a/libexec/lfs_cleanerd/lfs_cleanerd.c Wed Aug 12 18:24:14 2015 +0000
+++ b/libexec/lfs_cleanerd/lfs_cleanerd.c Wed Aug 12 18:25:03 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_cleanerd.c,v 1.45 2015/08/12 18:23:16 dholland Exp $ */
+/* $NetBSD: lfs_cleanerd.c,v 1.46 2015/08/12 18:25:03 dholland Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -1024,8 +1024,8 @@
* list, and send this list through lfs_markv() to move them to new
* locations on disk.
*/
-int
-clean_fs(struct clfs *fs, CLEANERINFO *cip)
+static int
+clean_fs(struct clfs *fs, const CLEANERINFO64 *cip)
{
int i, j, ngood, sn, bic, r, npos;
blkcnt_t widebic;
@@ -1236,9 +1236,10 @@
* the given filesystem needs to be cleaned. Returns 1 if it does, 0 if it
* does not, or -1 on error.
*/
-int
-needs_cleaning(struct clfs *fs, CLEANERINFO *cip)
+static int
+needs_cleaning(struct clfs *fs, CLEANERINFO64 *cip)
{
+ CLEANERINFO *cipu;
struct ubuf *bp;
struct stat st;
daddr_t fsb_per_seg, max_free_segs;
@@ -1258,7 +1259,20 @@
syslog(LOG_ERR, "%s: can't read inode", lfs_sb_getfsmnt(fs));
return -1;
}
- *cip = *(CLEANERINFO *)bp->b_data; /* Structure copy */
+ cipu = (CLEANERINFO *)bp->b_data;
+ if (fs->lfs_is64) {
+ /* Structure copy */
+ *cip = cipu->u_64;
+ } else {
+ /* Copy the fields and promote to 64 bit */
+ cip->clean = cipu->u_32.clean;
+ cip->dirty = cipu->u_32.dirty;
+ cip->bfree = cipu->u_32.bfree;
+ cip->avail = cipu->u_32.avail;
+ cip->free_head = cipu->u_32.free_head;
+ cip->free_tail = cipu->u_32.free_tail;
+ cip->flags = cipu->u_32.flags;
+ }
brelse(bp, B_INVAL);
cleaner_stats.bytes_read += lfs_sb_getbsize(fs);
@@ -1397,11 +1411,27 @@
#ifdef LFS_CLEANER_AS_LIB
sem_t *semaddr = NULL;
#endif
- CLEANERINFO ci;
+ CLEANERINFO64 ci;
#ifndef USE_CLIENT_SERVER
char *cp, *pidname;
#endif
+#ifdef RESCUEDIR
+ /*
+ * XXX: Work around apparent bug with gcc 4.8 and -Os: it
+ * claims that ci.clean is uninitialized in clean_fs (at one
+ * of the several uses of it, which is neither the first nor
+ * last use) -- this is conditionalized on RESCUEDIR because
+ * it comes up for building the cleaner for /rescue. It
+ * doesn't happen with plain -O2, and the value is clearly
+ * always initialized.
+ *
+ * Hopefully in the future further rearrangements will allow
+ * removing this hack.
+ */
+ ci.clean = 0;
+#endif
+
/*
* Set up defaults
*/
diff -r 69dd115e6d66 -r a2d32ce2a6d6 sbin/fsck_lfs/pass0.c
--- a/sbin/fsck_lfs/pass0.c Wed Aug 12 18:24:14 2015 +0000
+++ b/sbin/fsck_lfs/pass0.c Wed Aug 12 18:25:03 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass0.c,v 1.37 2015/07/28 05:09:34 dholland Exp $ */
+/* $NetBSD: pass0.c,v 1.38 2015/08/12 18:25:03 dholland Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -116,7 +116,7 @@
plastino = 0;
lowfreeino = maxino;
LFS_CLEANERINFO(cip, fs, cbp);
- freehd = ino = cip->free_head;
+ freehd = ino = lfs_ci_getfree_head(fs, cip);
brelse(cbp, 0);
while (ino) {
@@ -194,9 +194,9 @@
}
LFS_CLEANERINFO(cip, fs, cbp);
- if (cip->free_head != freehd) {
+ if (lfs_ci_getfree_head(fs, cip) != freehd) {
/* They've already given us permission for this change */
- cip->free_head = freehd;
+ lfs_ci_setfree_head(fs, cip, freehd);
writeit = 1;
}
if (freehd != lfs_sb_getfreehd(fs)) {
@@ -207,12 +207,12 @@
sbdirty();
}
}
- if (cip->free_tail != plastino) {
+ if (lfs_ci_getfree_tail(fs, cip) != plastino) {
pwarn("FREE LIST TAIL SHOULD BE %llu (WAS %llu)\n",
(unsigned long long)plastino,
- (unsigned long long)cip->free_tail);
+ (unsigned long long)lfs_ci_getfree_tail(fs, cip));
if (preen || reply("FIX")) {
- cip->free_tail = plastino;
+ lfs_ci_setfree_tail(fs, cip, plastino);
writeit = 1;
}
}
diff -r 69dd115e6d66 -r a2d32ce2a6d6 sbin/fsck_lfs/segwrite.c
--- a/sbin/fsck_lfs/segwrite.c Wed Aug 12 18:24:14 2015 +0000
+++ b/sbin/fsck_lfs/segwrite.c Wed Aug 12 18:25:03 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: segwrite.c,v 1.36 2015/08/02 18:18:09 dholland Exp $ */
+/* $NetBSD: segwrite.c,v 1.37 2015/08/12 18:25:03 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -701,9 +701,8 @@
LFS_WRITESEGENTRY(sup, fs, lfs_dtosn(fs, lfs_sb_getnextseg(fs)), bp);
LFS_CLEANERINFO(cip, fs, bp);
- --cip->clean;
- ++cip->dirty;
- lfs_sb_setnclean(fs, cip->clean);
+ lfs_ci_shiftcleantodirty(fs, cip, 1);
+ lfs_sb_setnclean(fs, lfs_ci_getclean(fs, cip));
LFS_SYNC_CLEANERINFO(cip, fs, bp, 1);
lfs_sb_setlastseg(fs, lfs_sb_getcurseg(fs));
diff -r 69dd115e6d66 -r a2d32ce2a6d6 sbin/newfs_lfs/make_lfs.c
--- a/sbin/newfs_lfs/make_lfs.c Wed Aug 12 18:24:14 2015 +0000
+++ b/sbin/newfs_lfs/make_lfs.c Wed Aug 12 18:25:03 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: make_lfs.c,v 1.40 2015/08/02 18:18:09 dholland Exp $ */
+/* $NetBSD: make_lfs.c,v 1.41 2015/08/12 18:25:03 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.40 2015/08/02 18:18:09 dholland Exp $");
+__RCSID("$NetBSD: make_lfs.c,v 1.41 2015/08/12 18:25:03 dholland Exp $");
#endif
#endif /* not lint */
@@ -722,11 +722,11 @@
* Initialize the cleanerinfo block
*/
LFS_CLEANERINFO(cip, fs, bp);
- cip->clean = lfs_sb_getnseg(fs);
- cip->dirty = 0;
+ lfs_ci_setclean(fs, cip, lfs_sb_getnseg(fs));
+ lfs_ci_setdirty(fs, cip, 0);
if (version > 1) {
- cip->free_head = HIGHEST_USED_INO + 1;
- cip->free_tail = lfs_sb_getifpb(fs) - 1;
+ lfs_ci_setfree_head(fs, cip, HIGHEST_USED_INO + 1);
+ lfs_ci_setfree_tail(fs, cip, lfs_sb_getifpb(fs) - 1);
}
LFS_SYNC_CLEANERINFO(cip, fs, bp, 1);
@@ -888,8 +888,8 @@
/* Put that in the Ifile version too, and write it */
LFS_CLEANERINFO(cip, fs, bp);
- cip->bfree = lfs_sb_getbfree(fs);
- cip->avail = lfs_sb_getavail(fs);
+ lfs_ci_setbfree(fs, cip, lfs_sb_getbfree(fs));
+ lfs_ci_setavail(fs, cip, lfs_sb_getavail(fs));
LFS_SYNC_CLEANERINFO(cip, fs, bp, 1);
if (!Nflag)
lfs_segwrite(fs, SEGM_CKP);
diff -r 69dd115e6d66 -r a2d32ce2a6d6 sys/ufs/lfs/lfs.h
--- a/sys/ufs/lfs/lfs.h Wed Aug 12 18:24:14 2015 +0000
+++ b/sys/ufs/lfs/lfs.h Wed Aug 12 18:25:03 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs.h,v 1.174 2015/08/12 18:24:14 dholland Exp $ */
+/* $NetBSD: lfs.h,v 1.175 2015/08/12 18:25:04 dholland Exp $ */
/* from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp */
/* from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp */
@@ -511,16 +511,35 @@
* Cleaner information structure. This resides in the ifile and is used
* to pass information from the kernel to the cleaner.
*/
-typedef struct _cleanerinfo {
- u_int32_t clean; /* number of clean segments */
- u_int32_t dirty; /* number of dirty segments */
- /* XXX64 bfree and avail must -> 64 */
- int32_t bfree; /* disk blocks free */
- int32_t avail; /* disk blocks available */
- u_int32_t free_head; /* head of the inode free list */
- u_int32_t free_tail; /* tail of the inode free list */
+
+/* flags for ->flags */
#define LFS_CLEANER_MUST_CLEAN 0x01
- u_int32_t flags; /* status word from the kernel */
+
+typedef struct _cleanerinfo32 {
+ u_int32_t clean; /* 0: number of clean segments */
+ u_int32_t dirty; /* 4: number of dirty segments */
+ int32_t bfree; /* 8: disk blocks free */
+ int32_t avail; /* 12: disk blocks available */
+ u_int32_t free_head; /* 16: head of the inode free list */
+ u_int32_t free_tail; /* 20: tail of the inode free list */
+ u_int32_t flags; /* 24: status word from the kernel */
+} CLEANERINFO32;
+
+typedef struct _cleanerinfo64 {
+ u_int32_t clean; /* 0: number of clean segments */
+ u_int32_t dirty; /* 4: number of dirty segments */
+ int64_t bfree; /* 8: disk blocks free */
+ int64_t avail; /* 16: disk blocks available */
+ u_int64_t free_head; /* 24: head of the inode free list */
+ u_int64_t free_tail; /* 32: tail of the inode free list */
+ u_int32_t flags; /* 40: status word from the kernel */
+ u_int32_t pad; /* 44: must be 64-bit aligned */
+} CLEANERINFO64;
+
+/* this must not go to disk directly of course */
+typedef union _cleanerinfo {
+ CLEANERINFO32 u_32;
+ CLEANERINFO64 u_64;
} CLEANERINFO;
/*
diff -r 69dd115e6d66 -r a2d32ce2a6d6 sys/ufs/lfs/lfs_accessors.h
--- a/sys/ufs/lfs/lfs_accessors.h Wed Aug 12 18:24:14 2015 +0000
+++ b/sys/ufs/lfs/lfs_accessors.h Wed Aug 12 18:25:03 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_accessors.h,v 1.8 2015/08/02 18:18:46 dholland Exp $ */
+/* $NetBSD: lfs_accessors.h,v 1.9 2015/08/12 18:25:04 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 */
@@ -146,6 +146,17 @@
Home |
Main Index |
Thread Index |
Old Index