Whamcloud - gitweb
LU-8066 mdd: migrate from proc to sysfs
[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, 2017, 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 <uapi/linux/lustre/lustre_lfsck_user.h>
37 #include <lustre_dlm.h>
38 #include <lu_object.h>
39 #include <dt_object.h>
40
41 struct lfsck_start_param {
42         struct lfsck_start      *lsp_start;
43         __u32                    lsp_index;
44         unsigned int             lsp_index_valid:1;
45 };
46
47 /* For LE_PAIRS_VERIFY returned status */
48 enum lfsck_pv_status {
49         LPVS_INIT               = 0,
50         LPVS_INCONSISTENT       = 1,
51         LPVS_INCONSISTENT_TOFIX = 2,
52 };
53
54 enum lfsck_events_local {
55         LEL_FID_ACCESSED        = 1,
56         LEL_PAIRS_VERIFY_LOCAL  = 2,
57 };
58
59 struct lfsck_req_local {
60         __u32           lrl_event;
61         __u32           lrl_status;
62         __u16           lrl_active;
63         __u16           lrl_padding0;
64         __u32           lrl_padding1;
65         struct lu_fid   lrl_fid;
66         struct filter_fid lrl_ff_client;
67         struct filter_fid lrl_ff_local;
68 };
69
70 struct lfsck_layout_dangling_key {
71         struct lu_fid   lldk_fid;
72         __u32           lldk_comp_id;
73         __u32           lldk_ea_off;
74 };
75
76 typedef int (*lfsck_out_notify)(const struct lu_env *env, void *data,
77                                 enum lfsck_events event);
78
79 int lfsck_register_namespace(const struct lu_env *env, struct dt_device *key,
80                              struct ldlm_namespace *ns);
81 int lfsck_register(const struct lu_env *env, struct dt_device *key,
82                    struct dt_device *next, struct obd_device *obd,
83                    lfsck_out_notify notify, void *notify_data, bool master);
84 void lfsck_degister(const struct lu_env *env, struct dt_device *key);
85
86 int lfsck_add_target(const struct lu_env *env, struct dt_device *key,
87                      struct dt_device *tgt, struct obd_export *exp,
88                      __u32 index, bool for_ost);
89 void lfsck_del_target(const struct lu_env *env, struct dt_device *key,
90                       struct dt_device *tgt, __u32 index, bool for_ost);
91
92 int lfsck_start(const struct lu_env *env, struct dt_device *key,
93                 struct lfsck_start_param *lsp);
94 int lfsck_stop(const struct lu_env *env, struct dt_device *key,
95                struct lfsck_stop *stop);
96 int lfsck_in_notify_local(const struct lu_env *env, struct dt_device *key,
97                           struct lfsck_req_local *lrl, struct thandle *th);
98 int lfsck_in_notify(const struct lu_env *env, struct dt_device *key,
99                     struct lfsck_request *lr);
100 int lfsck_query(const struct lu_env *env, struct dt_device *key,
101                 struct lfsck_request *req, struct lfsck_reply *rep,
102                 struct lfsck_query *que);
103
104 int lfsck_get_speed(struct seq_file *m, char *buf, struct dt_device *key);
105 int lfsck_set_speed(struct dt_device *key, __u32 val);
106 int lfsck_get_windows(char *buf, struct dt_device *key);
107 int lfsck_set_windows(struct dt_device *key, unsigned int val);
108
109 int lfsck_dump(struct seq_file *m, struct dt_device *key, enum lfsck_type type);
110
111 static inline void lfsck_pack_rfa(struct lfsck_req_local *lrl,
112                                   const struct lu_fid *fid,
113                                   enum lfsck_events_local event, __u16 com)
114 {
115         memset(lrl, 0, sizeof(*lrl));
116         lrl->lrl_fid = *fid;
117         lrl->lrl_event = event;
118         lrl->lrl_active = com;
119 }
120
121 static inline bool lovea_slot_is_dummy(const struct lov_ost_data_v1 *obj)
122 {
123         /* zero area does not care about the bytes-order. */
124         if (obj->l_ost_oi.oi.oi_id == 0 && obj->l_ost_oi.oi.oi_seq == 0 &&
125             obj->l_ost_idx == 0 && obj->l_ost_gen == 0)
126                 return true;
127
128         return false;
129 }
130 #endif /* _LUSTRE_LFSCK_H */