xref: /linux/fs/bcachefs/progress.h (revision 4a4b30ea80d8cb5e8c4c62bb86201f4ea0d9b030)
1*baabeb49SKent Overstreet /* SPDX-License-Identifier: GPL-2.0 */
2*baabeb49SKent Overstreet #ifndef _BCACHEFS_PROGRESS_H
3*baabeb49SKent Overstreet #define _BCACHEFS_PROGRESS_H
4*baabeb49SKent Overstreet 
5*baabeb49SKent Overstreet /*
6*baabeb49SKent Overstreet  * Lame progress indicators
7*baabeb49SKent Overstreet  *
8*baabeb49SKent Overstreet  * We don't like to use these because they print to the dmesg console, which is
9*baabeb49SKent Overstreet  * spammy - we much prefer to be wired up to a userspace programm (e.g. via
10*baabeb49SKent Overstreet  * thread_with_file) and have it print the progress indicator.
11*baabeb49SKent Overstreet  *
12*baabeb49SKent Overstreet  * But some code is old and doesn't support that, or runs in a context where
13*baabeb49SKent Overstreet  * that's not yet practical (mount).
14*baabeb49SKent Overstreet  */
15*baabeb49SKent Overstreet 
16*baabeb49SKent Overstreet struct progress_indicator_state {
17*baabeb49SKent Overstreet 	unsigned long		next_print;
18*baabeb49SKent Overstreet 	u64			nodes_seen;
19*baabeb49SKent Overstreet 	u64			nodes_total;
20*baabeb49SKent Overstreet 	struct btree		*last_node;
21*baabeb49SKent Overstreet };
22*baabeb49SKent Overstreet 
23*baabeb49SKent Overstreet void bch2_progress_init(struct progress_indicator_state *, struct bch_fs *, u64);
24*baabeb49SKent Overstreet void bch2_progress_update_iter(struct btree_trans *,
25*baabeb49SKent Overstreet 			       struct progress_indicator_state *,
26*baabeb49SKent Overstreet 			       struct btree_iter *,
27*baabeb49SKent Overstreet 			       const char *);
28*baabeb49SKent Overstreet 
29*baabeb49SKent Overstreet #endif /* _BCACHEFS_PROGRESS_H */
30