Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Use lfs_accessors.h in conjunction with the cleaner's struct...
details: https://anonhg.NetBSD.org/src/rev/d9f72eada66b
branches: trunk
changeset: 339546:d9f72eada66b
user: dholland <dholland%NetBSD.org@localhost>
date: Tue Jul 28 05:14:23 2015 +0000
description:
Use lfs_accessors.h in conjunction with the cleaner's struct clfs.
Remove previous hacks.
diffstat:
libexec/lfs_cleanerd/cleaner.h | 89 ++----------------------------------
libexec/lfs_cleanerd/coalesce.c | 9 +--
libexec/lfs_cleanerd/lfs_cleanerd.c | 70 ++++++++++++++--------------
sys/ufs/lfs/lfs_accessors.h | 8 +-
4 files changed, 48 insertions(+), 128 deletions(-)
diffs (truncated from 409 to 300 lines):
diff -r fa65924ed1f0 -r d9f72eada66b libexec/lfs_cleanerd/cleaner.h
--- a/libexec/lfs_cleanerd/cleaner.h Tue Jul 28 05:13:14 2015 +0000
+++ b/libexec/lfs_cleanerd/cleaner.h Tue Jul 28 05:14:23 2015 +0000
@@ -37,92 +37,13 @@
int clfs_onhold; /* If cleaning this fs is on hold */
};
-// XXX temporary
+/*
+ * Get lfs accessors that use struct clfs. This must come after the
+ * definition of struct clfs. (blah)
+ */
+#define STRUCT_LFS struct clfs
#include <ufs/lfs/lfs_accessors.h>
-/* ugh... */
-#define CLFS_DEF_SB_ACCESSOR(type, field) \
- static __unused inline type \
- clfs_sb_get##field(struct clfs *fs) \
- { \
- return fs->lfs_dlfs.dlfs_##field; \
- } \
- static __unused inline void \
- clfs_sb_set##field(struct clfs *fs, type val) \
- { \
- fs->lfs_dlfs.dlfs_##field = val; \
- } \
- static __unused inline void \
- clfs_sb_add##field(struct clfs *fs, type val) \
- { \
- type *p = &fs->lfs_dlfs.dlfs_##field; \
- *p += val; \
- }
-
-/* more ugh... */
-CLFS_DEF_SB_ACCESSOR(u_int32_t, ssize);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, bsize);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, fsize);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, frag);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, ifile);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, inopb);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, ifpb);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, sepb);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, nseg);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, cleansz);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, segtabsz);
-CLFS_DEF_SB_ACCESSOR(u_int64_t, bmask);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, bshift);
-CLFS_DEF_SB_ACCESSOR(u_int64_t, ffmask);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, ffshift);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, fbshift);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, blktodb);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, minfreeseg);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, sumsize);
-CLFS_DEF_SB_ACCESSOR(u_int32_t, ibsize);
-CLFS_DEF_SB_ACCESSOR(int32_t, s0addr);
-static __unused inline int32_t
-clfs_sb_getsboff(struct clfs *fs, unsigned n)
-{
- assert(n < LFS_MAXNUMSB);
- return fs->lfs_dlfs.dlfs_sboffs[n];
-}
-static __unused inline const char *
-clfs_sb_getfsmnt(struct clfs *fs)
-{
- return (const char *)fs->lfs_dlfs.dlfs_fsmnt;
-}
-
-/* still more ugh... */
-#define lfs_sb_getssize(fs) clfs_sb_getssize(fs)
-#define lfs_sb_getbsize(fs) clfs_sb_getbsize(fs)
-#define lfs_sb_getfsize(fs) clfs_sb_getfsize(fs)
-#define lfs_sb_getfrag(fs) clfs_sb_getfrag(fs)
-#define lfs_sb_getinopb(fs) clfs_sb_getinopb(fs)
-#define lfs_sb_getifpb(fs) clfs_sb_getifpb(fs)
-#define lfs_sb_getsepb(fs) clfs_sb_getsepb(fs)
-#define lfs_sb_getnseg(fs) clfs_sb_getnseg(fs)
-#define lfs_sb_getcleansz(fs) clfs_sb_getcleansz(fs)
-#define lfs_sb_getsegtabsz(fs) clfs_sb_getsegtabsz(fs)
-#define lfs_sb_getbmask(fs) clfs_sb_getbmask(fs)
-#define lfs_sb_getbshift(fs) clfs_sb_getbshift(fs)
-#define lfs_sb_getffmask(fs) clfs_sb_getffmask(fs)
-#define lfs_sb_getffshift(fs) clfs_sb_getffshift(fs)
-#define lfs_sb_getfbshift(fs) clfs_sb_getfbshift(fs)
-#define lfs_sb_getblktodb(fs) clfs_sb_getblktodb(fs)
-#define lfs_sb_getminfreeseg(fs) clfs_sb_getminfreeseg(fs)
-#define lfs_sb_getsumsize(fs) clfs_sb_getsumsize(fs)
-#define lfs_sb_getibsize(fs) clfs_sb_getibsize(fs)
-#define lfs_sb_gets0addr(fs) clfs_sb_gets0addr(fs)
-#define lfs_sb_getsboff(fs, n) clfs_sb_getsboff(fs, n)
-#define lfs_sb_getfsmnt(fs) clfs_sb_getfsmnt(fs)
-
-/*
- * This needs to come after the definition of struct clfs. (XXX blah)
- */
-//#define STRUCT_LFS struct clfs
-//#include <ufs/lfs/lfs_accessors.h>
-
/*
* Fraction of the could-be-clean segments required to be clean.
*/
diff -r fa65924ed1f0 -r d9f72eada66b libexec/lfs_cleanerd/coalesce.c
--- a/libexec/lfs_cleanerd/coalesce.c Tue Jul 28 05:13:14 2015 +0000
+++ b/libexec/lfs_cleanerd/coalesce.c Tue Jul 28 05:14:23 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: coalesce.c,v 1.27 2015/07/28 05:09:34 dholland Exp $ */
+/* $NetBSD: coalesce.c,v 1.28 2015/07/28 05:14:23 dholland Exp $ */
/*-
* Copyright (c) 2002, 2005 The NetBSD Foundation, Inc.
@@ -38,7 +38,6 @@
#include <sys/mman.h>
#include <ufs/lfs/lfs.h>
-#include <ufs/lfs/lfs_accessors.h>
#include <fcntl.h>
#include <signal.h>
@@ -217,10 +216,10 @@
#endif
noff = toff = 0;
for (i = 1; i < nb; i++) {
- if (bip[i].bi_daddr != bip[i - 1].bi_daddr + clfs_sb_getfrag(fs))
+ if (bip[i].bi_daddr != bip[i - 1].bi_daddr + lfs_sb_getfrag(fs))
++noff;
toff += abs(bip[i].bi_daddr - bip[i - 1].bi_daddr
- - clfs_sb_getfrag(fs)) >> lfs_sb_getfbshift(fs);
+ - lfs_sb_getfrag(fs)) >> lfs_sb_getfbshift(fs);
}
/*
@@ -299,7 +298,7 @@
bps = lfs_segtod(fs, 1);
for (tbip = bip; tbip < bip + nb; tbip += bps) {
do {
- bread(fs->lfs_ivnode, 0, clfs_sb_getbsize(fs), 0, &bp);
+ bread(fs->lfs_ivnode, 0, lfs_sb_getbsize(fs), 0, &bp);
cip = *(CLEANERINFO *)bp->b_data;
brelse(bp, B_INVAL);
diff -r fa65924ed1f0 -r d9f72eada66b libexec/lfs_cleanerd/lfs_cleanerd.c
--- a/libexec/lfs_cleanerd/lfs_cleanerd.c Tue Jul 28 05:13:14 2015 +0000
+++ b/libexec/lfs_cleanerd/lfs_cleanerd.c Tue Jul 28 05:14:23 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_cleanerd.c,v 1.40 2015/07/24 06:59:31 dholland Exp $ */
+/* $NetBSD: lfs_cleanerd.c,v 1.41 2015/07/28 05:14:23 dholland Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -269,8 +269,8 @@
memcpy(fs->lfs_dlfs.dlfs_fsmnt, mnttmp, sizeof(mnttmp));
/* Set up vnodes for Ifile and raw device */
- fs->lfs_ivnode = fd_vget(fs->clfs_ifilefd, clfs_sb_getbsize(fs), 0, 0);
- fs->clfs_devvp = fd_vget(fs->clfs_devfd, clfs_sb_getfsize(fs), clfs_sb_getssize(fs),
+ fs->lfs_ivnode = fd_vget(fs->clfs_ifilefd, lfs_sb_getbsize(fs), 0, 0);
+ fs->clfs_devvp = fd_vget(fs->clfs_devfd, lfs_sb_getfsize(fs), lfs_sb_getssize(fs),
atatime);
/* Allocate and clear segtab */
@@ -317,9 +317,9 @@
/* If Ifile is larger than buffer cache, rehash */
fstat(fs->clfs_ifilefd, &st);
- if (st.st_size / clfs_sb_getbsize(fs) > hashmax) {
+ if (st.st_size / lfs_sb_getbsize(fs) > hashmax) {
ohashmax = hashmax;
- bufrehash(st.st_size / clfs_sb_getbsize(fs));
+ bufrehash(st.st_size / lfs_sb_getbsize(fs));
dlog("%s: resized buffer hash from %d to %d",
lfs_sb_getfsmnt(fs), ohashmax, hashmax);
}
@@ -337,7 +337,7 @@
error = bread(fs->lfs_ivnode,
ino / lfs_sb_getifpb(fs) + lfs_sb_getcleansz(fs) +
- lfs_sb_getsegtabsz(fs), clfs_sb_getbsize(fs), 0, bpp);
+ lfs_sb_getsegtabsz(fs), lfs_sb_getbsize(fs), 0, bpp);
if (error)
syslog(LOG_ERR, "%s: ientry failed for ino %d",
lfs_sb_getfsmnt(fs), (int)ino);
@@ -519,7 +519,7 @@
syslog(LOG_WARNING, "fixing short FINFO at %x (seg %d)",
odaddr, lfs_dtosn(fs, odaddr));
- bread(fs->clfs_devvp, odaddr, clfs_sb_getfsize(fs),
+ bread(fs->clfs_devvp, odaddr, lfs_sb_getfsize(fs),
0, &nbp);
nssp = (SEGSUM *)nbp->b_data;
--nssp->ss_nfinfo;
@@ -548,7 +548,7 @@
/* Read all the blocks from the data summary */
for (i = 0; i < fip->fi_nblocks; i++) {
size = (i == fip->fi_nblocks - 1) ?
- fip->fi_lastlength : clfs_sb_getbsize(fs);
+ fip->fi_lastlength : lfs_sb_getbsize(fs);
cp = fd_ptrget(fs->clfs_devvp, daddr);
ck = lfs_cksum_part(cp, sizeof(u_int32_t), ck);
daddr += lfs_btofsb(fs, size);
@@ -574,7 +574,7 @@
bip[*bic + i].bi_segcreate = ssp->ss_create;
bip[*bic + i].bi_version = fip->fi_version;
bip[*bic + i].bi_size = (i == fip->fi_nblocks - 1) ?
- fip->fi_lastlength : clfs_sb_getbsize(fs);
+ fip->fi_lastlength : lfs_sb_getbsize(fs);
cp = fd_ptrget(fs->clfs_devvp, daddr);
ck = lfs_cksum_part(cp, sizeof(u_int32_t), ck);
bip[*bic + i].bi_bp = cp;
@@ -623,7 +623,7 @@
fp = fopen(copylog_filename, "ab");
if (fp != NULL) {
- if (fwrite(cp, (size_t)clfs_sb_getssize(fs), 1, fp) != 1) {
+ if (fwrite(cp, (size_t)lfs_sb_getssize(fs), 1, fp) != 1) {
perror("writing segment to copy log");
}
}
@@ -659,12 +659,12 @@
/* Note bytes read for stats */
cleaner_stats.segs_cleaned++;
- cleaner_stats.bytes_read += clfs_sb_getssize(fs);
+ cleaner_stats.bytes_read += lfs_sb_getssize(fs);
++fs->clfs_nactive;
npseg = 0;
while(lfs_dtosn(fs, daddr) == sn &&
- lfs_dtosn(fs, daddr + lfs_btofsb(fs, clfs_sb_getbsize(fs))) == sn) {
+ lfs_dtosn(fs, daddr + lfs_btofsb(fs, lfs_sb_getbsize(fs))) == sn) {
daddr = parse_pseg(fs, daddr, bipp, bic);
if (daddr == 0x0) {
++cleaner_stats.segs_error;
@@ -708,7 +708,7 @@
return;
}
- if (t->nbytes > clfs_sb_getssize(fs)) {
+ if (t->nbytes > lfs_sb_getssize(fs)) {
/* Another type of error */
syslog(LOG_WARNING, "segment %d: bad seguse count %d",
sn, t->nbytes);
@@ -725,16 +725,16 @@
* We count the summary headers as "dirty" to avoid cleaning very
* old and very full segments.
*/
- benefit = (int64_t)clfs_sb_getssize(fs) - t->nbytes -
- (t->nsums + 1) * clfs_sb_getfsize(fs);
- if (clfs_sb_getbsize(fs) > clfs_sb_getfsize(fs)) /* fragmentation */
- benefit -= (clfs_sb_getbsize(fs) / 2);
+ benefit = (int64_t)lfs_sb_getssize(fs) - t->nbytes -
+ (t->nsums + 1) * lfs_sb_getfsize(fs);
+ if (lfs_sb_getbsize(fs) > lfs_sb_getfsize(fs)) /* fragmentation */
+ benefit -= (lfs_sb_getbsize(fs) / 2);
if (benefit <= 0) {
t->priority = 0;
return;
}
- cost = clfs_sb_getssize(fs) + t->nbytes;
+ cost = lfs_sb_getssize(fs) + t->nbytes;
t->priority = (256 * benefit * age) / cost;
return;
@@ -873,7 +873,7 @@
/* Record statistics */
for (i = nb = 0; i < bic; i++)
nb += bip[i].bi_size;
- util = ((double)nb) / (fs->clfs_nactive * clfs_sb_getssize(fs));
+ util = ((double)nb) / (fs->clfs_nactive * lfs_sb_getssize(fs));
cleaner_stats.util_tot += util;
cleaner_stats.util_sos += util * util;
cleaner_stats.bytes_written += nb;
@@ -970,10 +970,10 @@
/*
* Look for IFILE blocks, unless this is the Ifile.
*/
- if (bip[i].bi_inode != clfs_sb_getifile(fs)) {
+ if (bip[i].bi_inode != lfs_sb_getifile(fs)) {
lbn = lfs_sb_getcleansz(fs) + bip[i].bi_inode /
lfs_sb_getifpb(fs);
- *ifc += check_or_add(clfs_sb_getifile(fs), lbn,
+ *ifc += check_or_add(lfs_sb_getifile(fs), lbn,
bip, bic, &ebip, &ebic);
}
}
@@ -1021,7 +1021,7 @@
for (i = 0; i < lfs_sb_getnseg(fs); i+= lfs_sb_getsepb(fs)) {
bread(fs->lfs_ivnode,
lfs_sb_getcleansz(fs) + i / lfs_sb_getsepb(fs),
- clfs_sb_getbsize(fs), 0, &bp);
+ lfs_sb_getbsize(fs), 0, &bp);
for (j = 0; j < lfs_sb_getsepb(fs) && i + j < lfs_sb_getnseg(fs); j++) {
sup = ((SEGUSE *)bp->b_data) + j;
fs->clfs_segtab[i + j].nbytes = sup->su_nbytes;
@@ -1055,10 +1055,10 @@
ngood = 0;
if (use_bytes) {
/* Set attainable goal */
- goal = clfs_sb_getssize(fs) * atatime;
- if (goal > (cip->clean - 1) * clfs_sb_getssize(fs) / 2)
Home |
Main Index |
Thread Index |
Old Index