xref: /netbsd-src/libexec/lfs_cleanerd/cleaner.h (revision ec175d5025cc4a68e365c9c5f02ec4d00d30596e)
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 		lfs_dobyteswap : 1,
25 		lfs_hasolddirfmt : 1;
26 
27 	/* Ifile */
28 	int clfs_ifilefd;	   /* Ifile file descriptor */
29 	struct uvnode *lfs_ivnode; /* Ifile vnode */
30 	struct lfs_fhandle clfs_ifilefh;	   /* Ifile file handle */
31 
32 	/* Device */
33 	int clfs_devfd;		   /* Device file descriptor */
34 	struct uvnode *clfs_devvp; /* Device vnode */
35 	char *clfs_dev;		   /* Name of device */
36 
37 	/* Cache of segment status */
38 	struct clfs_seguse  *clfs_segtab;  /* Abbreviated seguse table */
39 	struct clfs_seguse **clfs_segtabp; /* pointers to same */
40 
41 	/* Progress status */
42 	int clfs_nactive;	   /* How many segments' blocks we have */
43 	int clfs_onhold;	   /* If cleaning this fs is on hold */
44 };
45 
46 /*
47  * Get lfs accessors that use struct clfs. This must come after the
48  * definition of struct clfs. (blah)
49  */
50 #define STRUCT_LFS struct clfs
51 #include <ufs/lfs/lfs_accessors.h>
52 
53 /*
54  * Fraction of the could-be-clean segments required to be clean.
55  */
56 #define BUSY_LIM 0.5
57 #define IDLE_LIM 0.9
58 
59 __BEGIN_DECLS
60 
61 /* lfs_cleanerd.c */
62 void pwarn(const char *, ...);
63 void calc_cb(struct clfs *, int, struct clfs_seguse *);
64 void dlog(const char *, ...);
65 void handle_error(struct clfs **, int);
66 int init_fs(struct clfs *, char *);
67 int invalidate_segment(struct clfs *, int);
68 void lfs_ientry(IFILE **, struct clfs *, ino_t, struct ubuf **);
69 int load_segment(struct clfs *, int, BLOCK_INFO **, int *);
70 int reinit_fs(struct clfs *);
71 void reload_ifile(struct clfs *);
72 void toss_old_blocks(struct clfs *, BLOCK_INFO **, blkcnt_t *, int *);
73 
74 /* cleansrv.c */
75 void check_control_socket(void);
76 void try_to_become_master(int, char **);
77 
78 /* coalesce.c */
79 int clean_all_inodes(struct clfs *);
80 int fork_coalesce(struct clfs *);
81 
82 __END_DECLS
83 
84 #endif /* CLEANER_H_ */
85