]> git.ipfire.org Git - thirdparty/mdadm.git/blob - mdmon.h
pr_err for mdmon.
[thirdparty/mdadm.git] / mdmon.h
1 /*
2 * mdmon - monitor external metadata arrays
3 *
4 * Copyright (C) 2007-2009 Neil Brown <neilb@suse.de>
5 * Copyright (C) 2007-2009 Intel Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #undef pr_err
22 #define pr_err(fmt ...) fprintf(stderr, "mdmon: " fmt)
23
24 enum array_state { clear, inactive, suspended, readonly, read_auto,
25 clean, active, write_pending, active_idle, bad_word};
26
27 enum sync_action { idle, reshape, resync, recover, check, repair, bad_action };
28
29
30 struct active_array {
31 struct mdinfo info;
32 struct supertype *container;
33 struct active_array *next, *replaces;
34 int to_remove;
35
36 int action_fd;
37 int resync_start_fd;
38 int metadata_fd; /* for monitoring rw/ro status */
39 int sync_completed_fd; /* for checkpoint notification events */
40 unsigned long long last_checkpoint; /* sync_completed fires for many
41 * reasons this field makes sure the
42 * kernel has made progress before
43 * moving the checkpoint. It is
44 * cleared by the metadata handler
45 * when it determines recovery is
46 * terminated.
47 */
48
49 enum array_state prev_state, curr_state, next_state;
50 enum sync_action prev_action, curr_action, next_action;
51
52 int check_degraded; /* flag set by mon, read by manage */
53 int check_reshape; /* flag set by mon, read by manage */
54 };
55
56 /*
57 * Metadata updates are handled by the monitor thread,
58 * as it has exclusive access to the metadata.
59 * When the manager want to updates metadata, either
60 * for it's own reason (e.g. committing a spare) or
61 * on behalf of mdadm, it creates a metadata_update
62 * structure and queues it to the monitor.
63 * Updates are created and processed by code under the
64 * superswitch. All common code sees them as opaque
65 * blobs.
66 */
67 extern struct metadata_update *update_queue, *update_queue_handled;
68
69 #define MD_MAJOR 9
70
71 extern struct active_array *container;
72 extern struct active_array *discard_this;
73 extern struct active_array *pending_discard;
74 extern struct md_generic_cmd *active_cmd;
75
76
77 void remove_pidfile(char *devname);
78 void do_monitor(struct supertype *container);
79 void do_manager(struct supertype *container);
80 extern int sigterm;
81
82 int read_dev_state(int fd);
83 int is_container_member(struct mdstat_ent *mdstat, char *container);
84
85 struct mdstat_ent *mdstat_read(int hold, int start);
86
87 extern int exit_now, manager_ready;
88 extern int mon_tid, mgr_tid;
89 extern int monitor_loop_cnt;
90
91 /* helper routine to determine resync completion since MaxSector is a
92 * moving target
93 */
94 static inline int is_resync_complete(struct mdinfo *array)
95 {
96 if (array->resync_start >= array->component_size)
97 return 1;
98 return 0;
99 }
100