cleaner.h revision 1.8 1 1.1 perseant #ifndef CLEANER_H_
2 1.1 perseant #define CLEANER_H_
3 1.1 perseant
4 1.1 perseant /*
5 1.1 perseant * An abbreviated version of the SEGUSE data structure.
6 1.1 perseant */
7 1.1 perseant struct clfs_seguse {
8 1.1 perseant u_int32_t nbytes;
9 1.1 perseant u_int32_t nsums;
10 1.1 perseant u_int32_t flags;
11 1.1 perseant u_int64_t lastmod;
12 1.1 perseant u_int64_t priority;
13 1.1 perseant };
14 1.1 perseant
15 1.1 perseant /*
16 1.1 perseant * The cleaner's view of the superblock data structure.
17 1.1 perseant */
18 1.1 perseant struct clfs {
19 1.6 dholland struct dlfs lfs_dlfs;
20 1.1 perseant
21 1.1 perseant /* Ifile */
22 1.1 perseant int clfs_ifilefd; /* Ifile file descriptor */
23 1.1 perseant struct uvnode *lfs_ivnode; /* Ifile vnode */
24 1.4 martin struct lfs_fhandle clfs_ifilefh; /* Ifile file handle */
25 1.1 perseant
26 1.1 perseant /* Device */
27 1.1 perseant int clfs_devfd; /* Device file descriptor */
28 1.1 perseant struct uvnode *clfs_devvp; /* Device vnode */
29 1.1 perseant char *clfs_dev; /* Name of device */
30 1.1 perseant
31 1.1 perseant /* Cache of segment status */
32 1.1 perseant struct clfs_seguse *clfs_segtab; /* Abbreviated seguse table */
33 1.1 perseant struct clfs_seguse **clfs_segtabp; /* pointers to same */
34 1.1 perseant
35 1.1 perseant /* Progress status */
36 1.1 perseant int clfs_nactive; /* How many segments' blocks we have */
37 1.1 perseant int clfs_onhold; /* If cleaning this fs is on hold */
38 1.1 perseant };
39 1.1 perseant
40 1.8 dholland // XXX temporary
41 1.8 dholland #include <ufs/lfs/lfs_accessors.h>
42 1.8 dholland
43 1.6 dholland /* ugh... */
44 1.6 dholland #define CLFS_DEF_SB_ACCESSOR(type, field) \
45 1.6 dholland static __unused inline type \
46 1.6 dholland clfs_sb_get##field(struct clfs *fs) \
47 1.6 dholland { \
48 1.6 dholland return fs->lfs_dlfs.dlfs_##field; \
49 1.6 dholland } \
50 1.6 dholland static __unused inline void \
51 1.6 dholland clfs_sb_set##field(struct clfs *fs, type val) \
52 1.6 dholland { \
53 1.6 dholland fs->lfs_dlfs.dlfs_##field = val; \
54 1.6 dholland } \
55 1.6 dholland static __unused inline void \
56 1.6 dholland clfs_sb_add##field(struct clfs *fs, type val) \
57 1.6 dholland { \
58 1.7 dholland type *p = &fs->lfs_dlfs.dlfs_##field; \
59 1.7 dholland *p += val; \
60 1.6 dholland }
61 1.6 dholland
62 1.6 dholland /* more ugh... */
63 1.6 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, ssize);
64 1.6 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, bsize);
65 1.6 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, fsize);
66 1.6 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, frag);
67 1.6 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, ifile);
68 1.7 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, inopb);
69 1.6 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, ifpb);
70 1.6 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, sepb);
71 1.6 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, nseg);
72 1.6 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, cleansz);
73 1.6 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, segtabsz);
74 1.7 dholland CLFS_DEF_SB_ACCESSOR(u_int64_t, bmask);
75 1.7 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, bshift);
76 1.7 dholland CLFS_DEF_SB_ACCESSOR(u_int64_t, ffmask);
77 1.7 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, ffshift);
78 1.7 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, fbshift);
79 1.7 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, blktodb);
80 1.7 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, minfreeseg);
81 1.7 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, sumsize);
82 1.7 dholland CLFS_DEF_SB_ACCESSOR(u_int32_t, ibsize);
83 1.7 dholland CLFS_DEF_SB_ACCESSOR(int32_t, s0addr);
84 1.7 dholland static __unused inline int32_t
85 1.7 dholland clfs_sb_getsboff(struct clfs *fs, unsigned n)
86 1.7 dholland {
87 1.7 dholland assert(n < LFS_MAXNUMSB);
88 1.7 dholland return fs->lfs_dlfs.dlfs_sboffs[n];
89 1.7 dholland }
90 1.7 dholland static __unused inline const char *
91 1.7 dholland clfs_sb_getfsmnt(struct clfs *fs)
92 1.7 dholland {
93 1.7 dholland return (const char *)fs->lfs_dlfs.dlfs_fsmnt;
94 1.7 dholland }
95 1.6 dholland
96 1.6 dholland /* still more ugh... */
97 1.6 dholland #define lfs_sb_getssize(fs) clfs_sb_getssize(fs)
98 1.6 dholland #define lfs_sb_getbsize(fs) clfs_sb_getbsize(fs)
99 1.6 dholland #define lfs_sb_getfsize(fs) clfs_sb_getfsize(fs)
100 1.6 dholland #define lfs_sb_getfrag(fs) clfs_sb_getfrag(fs)
101 1.7 dholland #define lfs_sb_getinopb(fs) clfs_sb_getinopb(fs)
102 1.6 dholland #define lfs_sb_getifpb(fs) clfs_sb_getifpb(fs)
103 1.6 dholland #define lfs_sb_getsepb(fs) clfs_sb_getsepb(fs)
104 1.6 dholland #define lfs_sb_getnseg(fs) clfs_sb_getnseg(fs)
105 1.6 dholland #define lfs_sb_getcleansz(fs) clfs_sb_getcleansz(fs)
106 1.6 dholland #define lfs_sb_getsegtabsz(fs) clfs_sb_getsegtabsz(fs)
107 1.7 dholland #define lfs_sb_getbmask(fs) clfs_sb_getbmask(fs)
108 1.7 dholland #define lfs_sb_getbshift(fs) clfs_sb_getbshift(fs)
109 1.7 dholland #define lfs_sb_getffmask(fs) clfs_sb_getffmask(fs)
110 1.7 dholland #define lfs_sb_getffshift(fs) clfs_sb_getffshift(fs)
111 1.7 dholland #define lfs_sb_getfbshift(fs) clfs_sb_getfbshift(fs)
112 1.7 dholland #define lfs_sb_getblktodb(fs) clfs_sb_getblktodb(fs)
113 1.7 dholland #define lfs_sb_getminfreeseg(fs) clfs_sb_getminfreeseg(fs)
114 1.7 dholland #define lfs_sb_getsumsize(fs) clfs_sb_getsumsize(fs)
115 1.7 dholland #define lfs_sb_getibsize(fs) clfs_sb_getibsize(fs)
116 1.7 dholland #define lfs_sb_gets0addr(fs) clfs_sb_gets0addr(fs)
117 1.7 dholland #define lfs_sb_getsboff(fs, n) clfs_sb_getsboff(fs, n)
118 1.7 dholland #define lfs_sb_getfsmnt(fs) clfs_sb_getfsmnt(fs)
119 1.6 dholland
120 1.1 perseant /*
121 1.8 dholland * This needs to come after the definition of struct clfs. (XXX blah)
122 1.8 dholland */
123 1.8 dholland //#define STRUCT_LFS struct clfs
124 1.8 dholland //#include <ufs/lfs/lfs_accessors.h>
125 1.8 dholland
126 1.8 dholland /*
127 1.1 perseant * Fraction of the could-be-clean segments required to be clean.
128 1.1 perseant */
129 1.1 perseant #define BUSY_LIM 0.5
130 1.1 perseant #define IDLE_LIM 0.9
131 1.1 perseant
132 1.1 perseant __BEGIN_DECLS
133 1.1 perseant
134 1.1 perseant /* lfs_cleanerd.c */
135 1.1 perseant void pwarn(const char *, ...);
136 1.1 perseant void calc_cb(struct clfs *, int, struct clfs_seguse *);
137 1.1 perseant int clean_fs(struct clfs *, CLEANERINFO *);
138 1.5 lukem void dlog(const char *, ...);
139 1.1 perseant void handle_error(struct clfs **, int);
140 1.1 perseant int init_fs(struct clfs *, char *);
141 1.1 perseant int invalidate_segment(struct clfs *, int);
142 1.1 perseant void lfs_ientry(IFILE **, struct clfs *, ino_t, struct ubuf **);
143 1.1 perseant int load_segment(struct clfs *, int, BLOCK_INFO **, int *);
144 1.1 perseant int needs_cleaning(struct clfs *, CLEANERINFO *);
145 1.1 perseant int32_t parse_pseg(struct clfs *, daddr_t, BLOCK_INFO **, int *);
146 1.1 perseant int reinit_fs(struct clfs *);
147 1.1 perseant void reload_ifile(struct clfs *);
148 1.2 perseant void toss_old_blocks(struct clfs *, BLOCK_INFO **, int *, int *);
149 1.1 perseant
150 1.1 perseant /* cleansrv.c */
151 1.1 perseant void check_control_socket(void);
152 1.1 perseant void try_to_become_master(int, char **);
153 1.1 perseant
154 1.1 perseant /* coalesce.c */
155 1.1 perseant int log2int(int);
156 1.1 perseant int clean_all_inodes(struct clfs *);
157 1.1 perseant int fork_coalesce(struct clfs *);
158 1.1 perseant
159 1.1 perseant __END_DECLS
160 1.1 perseant
161 1.1 perseant #endif /* CLEANER_H_ */
162