cleaner.h revision 1.13 1 #ifndef CLEANER_H_
2 #define CLEANER_H_
3
4 /*
5 * An abbreviated version of the SEGUSE data structure.
6 */
7 struct clfs_seguse {
8 u_int32_t nbytes;
9 u_int32_t nsums;
10 u_int32_t flags;
11 u_int64_t lastmod;
12 u_int64_t priority;
13 };
14
15 /*
16 * The cleaner's view of the superblock data structure.
17 */
18 struct clfs {
19 union {
20 struct dlfs u_32;
21 struct dlfs64 u_64;
22 } lfs_dlfs_u;
23 unsigned lfs_is64 : 1;
24
25 /* Ifile */
26 int clfs_ifilefd; /* Ifile file descriptor */
27 struct uvnode *lfs_ivnode; /* Ifile vnode */
28 struct lfs_fhandle clfs_ifilefh; /* Ifile file handle */
29
30 /* Device */
31 int clfs_devfd; /* Device file descriptor */
32 struct uvnode *clfs_devvp; /* Device vnode */
33 char *clfs_dev; /* Name of device */
34
35 /* Cache of segment status */
36 struct clfs_seguse *clfs_segtab; /* Abbreviated seguse table */
37 struct clfs_seguse **clfs_segtabp; /* pointers to same */
38
39 /* Progress status */
40 int clfs_nactive; /* How many segments' blocks we have */
41 int clfs_onhold; /* If cleaning this fs is on hold */
42 };
43
44 /*
45 * Get lfs accessors that use struct clfs. This must come after the
46 * definition of struct clfs. (blah)
47 */
48 #define STRUCT_LFS struct clfs
49 #include <ufs/lfs/lfs_accessors.h>
50
51 /*
52 * Fraction of the could-be-clean segments required to be clean.
53 */
54 #define BUSY_LIM 0.5
55 #define IDLE_LIM 0.9
56
57 __BEGIN_DECLS
58
59 /* lfs_cleanerd.c */
60 void pwarn(const char *, ...);
61 void calc_cb(struct clfs *, int, struct clfs_seguse *);
62 void dlog(const char *, ...);
63 void handle_error(struct clfs **, int);
64 int init_fs(struct clfs *, char *);
65 int invalidate_segment(struct clfs *, int);
66 void lfs_ientry(IFILE **, struct clfs *, ino_t, struct ubuf **);
67 int load_segment(struct clfs *, int, BLOCK_INFO **, int *);
68 int reinit_fs(struct clfs *);
69 void reload_ifile(struct clfs *);
70 void toss_old_blocks(struct clfs *, BLOCK_INFO **, blkcnt_t *, int *);
71
72 /* cleansrv.c */
73 void check_control_socket(void);
74 void try_to_become_master(int, char **);
75
76 /* coalesce.c */
77 int clean_all_inodes(struct clfs *);
78 int fork_coalesce(struct clfs *);
79
80 __END_DECLS
81
82 #endif /* CLEANER_H_ */
83