]> git.ipfire.org Git - thirdparty/mdadm.git/blame - mdmon.h
main: factor out code to parse layout for raid10 and faulty.
[thirdparty/mdadm.git] / mdmon.h
CommitLineData
a54d5262
DW
1/*
2 * mdmon - monitor external metadata arrays
3 *
4 * Copyright (C) 2007-2008 Neil Brown <neilb@suse.de>
5 * Copyright (C) 2007-2008 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
549e9569
NB
21enum array_state { clear, inactive, suspended, readonly, read_auto,
22 clean, active, write_pending, active_idle, bad_word};
23
24enum sync_action { idle, reshape, resync, recover, check, repair, bad_action };
25
26
27struct active_array {
28 struct mdinfo info;
29 struct supertype *container;
30 struct active_array *next, *replaces;
31
32 int action_fd;
c052ba30 33 int resync_start_fd;
e9dd1598 34 int metadata_fd; /* for monitoring rw/ro status */
549e9569
NB
35
36 enum array_state prev_state, curr_state, next_state;
37 enum sync_action prev_action, curr_action, next_action;
38
6c3fb95c
NB
39 int check_degraded; /* flag set by mon, read by manage */
40
549e9569
NB
41 int devnum;
42
c052ba30 43 unsigned long long resync_start;
549e9569
NB
44};
45
2e735d19
NB
46/*
47 * Metadata updates are handled by the monitor thread,
48 * as it has exclusive access to the metadata.
49 * When the manager want to updates metadata, either
50 * for it's own reason (e.g. committing a spare) or
51 * on behalf of mdadm, it creates a metadata_update
52 * structure and queues it to the monitor.
53 * Updates are created and processed by code under the
54 * superswitch. All common code sees them as opaque
55 * blobs.
56 */
2e735d19 57extern struct metadata_update *update_queue, *update_queue_handled;
549e9569
NB
58
59#define MD_MAJOR 9
60
61extern struct active_array *container;
549e9569
NB
62extern struct active_array *discard_this;
63extern struct active_array *pending_discard;
3e70c845 64extern struct md_generic_cmd *active_cmd;
549e9569
NB
65
66
e0d6609f 67void remove_pidfile(char *devname);
549e9569
NB
68void do_monitor(struct supertype *container);
69void do_manager(struct supertype *container);
295646b3
DW
70int make_control_sock(char *devname);
71int make_pidfile(char *devname, int o_excl);
72extern int socket_hup_requested;
6144ed44 73extern int sigterm;
549e9569
NB
74
75int read_dev_state(int fd);
103f2410 76int get_resync_start(struct active_array *a);
883a6142 77int is_container_member(struct mdstat_ent *mdstat, char *container);
549e9569
NB
78
79struct mdstat_ent *mdstat_read(int hold, int start);
80
e0d6609f 81extern int exit_now, manager_ready;
4d43913c 82extern int mon_tid, mgr_tid;
1eb252b8 83extern int monitor_loop_cnt;
593add1b
DW
84
85/* helper routine to determine resync completion since MaxSector is a
86 * moving target
87 */
88static inline int is_resync_complete(struct active_array *a)
89{
90 if (a->resync_start >= a->info.component_size)
91 return 1;
92 return 0;
93}
94