Whamcloud - gitweb
1be54ecd68417a5799f2322802159963dd595690
[fs/lustre-release.git] / lustre / include / lustre_lfsck.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License version 2 for more details.  A copy is
14  * included in the COPYING file that accompanied this code.
15
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2013, Intel Corporation.
24  */
25 /*
26  * lustre/include/lustre_lfsck.h
27  *
28  * Lustre LFSCK exported functions.
29  *
30  * Author: Fan, Yong <fan.yong@intel.com>
31  */
32
33 #ifndef _LUSTRE_LFSCK_H
34 # define _LUSTRE_LFSCK_H
35
36 #include <lustre/lustre_lfsck_user.h>
37 #include <lustre_dlm.h>
38 #include <lu_object.h>
39 #include <dt_object.h>
40
41 /**
42  * status machine:
43  *
44  *                                      LS_INIT
45  *                                         |
46  *                                   (lfsck|start)
47  *                                         |
48  *                                         v
49  *                                 LS_SCANNING_PHASE1
50  *                                      |       ^
51  *                                      |       :
52  *                                      | (lfsck:restart)
53  *                                      |       :
54  *                                      v       :
55  *      -----------------------------------------------------------------
56  *      |                   |^          |^         |^         |^        |^
57  *      |                   |:          |:         |:         |:        |:
58  *      v                   v:          v:         v:         v:        v:
59  * LS_SCANNING_PHASE2   LS_FAILED  LS_STOPPED  LS_PAUSED LS_CRASHED LS_PARTIAL
60  *      |       ^           ^:          ^:         ^:         ^:        ^:
61  *      |       :           |:          |:         |:         |:        |:
62  *      | (lfsck:restart)   |:          |:         |:         |:        |:
63  *      v       :           |v          |v         |v         |v        |v
64  *      -----------------------------------------------------------------
65  *          |
66  *          v
67  *    LS_COMPLETED
68  */
69 enum lfsck_status {
70         /* The lfsck file is new created, for new MDT, upgrading from old disk,
71          * or re-creating the lfsck file manually. */
72         LS_INIT                 = 0,
73
74         /* The first-step system scanning. */
75         LS_SCANNING_PHASE1      = 1,
76
77         /* The second-step system scanning. */
78         LS_SCANNING_PHASE2      = 2,
79
80         /* The LFSCK processing has completed for all objects. */
81         LS_COMPLETED            = 3,
82
83         /* The LFSCK exited automatically for failure, will not auto restart. */
84         LS_FAILED               = 4,
85
86         /* The LFSCK is stopped manually, will not auto restart. */
87         LS_STOPPED              = 5,
88
89         /* LFSCK is paused automatically when umount,
90          * will be restarted automatically when remount. */
91         LS_PAUSED               = 6,
92
93         /* System crashed during the LFSCK,
94          * will be restarted automatically after recovery. */
95         LS_CRASHED              = 7,
96
97         /* Some OST/MDT failed during the LFSCK, or not join the LFSCK. */
98         LS_PARTIAL              = 8,
99
100         LS_MAX
101 };
102
103 struct lfsck_start_param {
104         struct lfsck_start      *lsp_start;
105         struct ldlm_namespace   *lsp_namespace;
106 };
107
108 enum lfsck_events {
109         LE_LASTID_REBUILDING    = 1,
110         LE_LASTID_REBUILT       = 2,
111 };
112
113 typedef int (*lfsck_out_notify)(const struct lu_env *env, void *data,
114                                 enum lfsck_events event);
115
116 int lfsck_register(const struct lu_env *env, struct dt_device *key,
117                    struct dt_device *next, lfsck_out_notify notify,
118                    void *notify_data, bool master);
119 void lfsck_degister(const struct lu_env *env, struct dt_device *key);
120
121 int lfsck_add_target(const struct lu_env *env, struct dt_device *key,
122                      struct dt_device *tgt, struct obd_export *exp,
123                      __u32 index, bool for_ost);
124 void lfsck_del_target(const struct lu_env *env, struct dt_device *key,
125                       struct dt_device *tgt, __u32 index, bool for_ost);
126
127 int lfsck_start(const struct lu_env *env, struct dt_device *key,
128                 struct lfsck_start_param *lsp);
129 int lfsck_stop(const struct lu_env *env, struct dt_device *key,
130                bool pause);
131
132 int lfsck_get_speed(struct dt_device *key, void *buf, int len);
133 int lfsck_set_speed(struct dt_device *key, int val);
134
135 int lfsck_dump(struct dt_device *key, void *buf, int len, enum lfsck_type type);
136
137 #endif /* _LUSTRE_LFSCK_H */