4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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.
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
23 * Copyright (c) 2012, 2017, Intel Corporation.
26 * lustre/include/lustre/lustre_lfsck_user.h
28 * Lustre LFSCK userspace interfaces.
30 * Author: Fan, Yong <fan.yong@intel.com>
33 #ifndef _LUSTRE_LFSCK_USER_H
34 # define _LUSTRE_LFSCK_USER_H
36 #include <linux/types.h>
37 #include <linux/lustre/lustre_user.h>
53 * -----------------------------------------------------------------
57 * LS_SCANNING_PHASE2 LS_FAILED LS_STOPPED LS_PAUSED LS_CRASHED LS_PARTIAL
61 * | (lfsck:restart) |: |: |: |: |:
63 * -----------------------------------------------------------------
69 /* The lfsck file is new created, for new MDT, upgrading from old disk,
70 * or re-creating the lfsck file manually. */
73 /* The first-step system scanning. The checked items during the phase1
74 * scanning depends on the LFSCK type. */
75 LS_SCANNING_PHASE1 = 1,
77 /* The second-step system scanning. The checked items during the phase2
78 * scanning depends on the LFSCK type. */
79 LS_SCANNING_PHASE2 = 2,
81 /* The LFSCK processing has completed for all objects. */
84 /* The LFSCK exited automatically for failure, will not auto restart. */
87 /* The LFSCK is stopped manually, will not auto restart. */
90 /* LFSCK is paused automatically when umount,
91 * will be restarted automatically when remount. */
94 /* System crashed during the LFSCK,
95 * will be restarted automatically after recovery. */
98 /* Some OST/MDT failed during the LFSCK, or not join the LFSCK. */
101 /* The LFSCK is failed because its controller is failed. */
104 /* The LFSCK is stopped because its controller is stopped. */
107 /* The LFSCK is paused because its controller is paused. */
113 static inline const char *lfsck_status2name(int status)
115 static const char * const lfsck_status_names[] = {
117 [LS_SCANNING_PHASE1] = "scanning-phase1",
118 [LS_SCANNING_PHASE2] = "scanning-phase2",
119 [LS_COMPLETED] = "completed",
120 [LS_FAILED] = "failed",
121 [LS_STOPPED] = "stopped",
122 [LS_PAUSED] = "paused",
123 [LS_CRASHED] = "crashed",
124 [LS_PARTIAL] = "partial",
125 [LS_CO_FAILED] = "co-failed",
126 [LS_CO_STOPPED] = "co-stopped",
127 [LS_CO_PAUSED] = "co-paused"
130 if (status < 0 || status >= LS_MAX)
133 return lfsck_status_names[status];
136 enum lfsck_param_flags {
137 /* Reset LFSCK iterator position to the device beginning. */
140 /* Exit when fail. */
141 LPF_FAILOUT = 0x0002,
143 /* Dryrun mode, only check without modification */
146 /* LFSCK runs on all targets. */
147 LPF_ALL_TGT = 0x0008,
149 /* Broadcast the command to other MDTs. Only valid on the sponsor MDT */
150 LPF_BROADCAST = 0x0010,
152 /* Handle orphan OST-objects. */
153 LPF_OST_ORPHAN = 0x0020,
155 /* Create OST-object for dangling LOV EA. */
156 LPF_CREATE_OSTOBJ = 0x0040,
158 /* Create MDT-object for dangling name entry. */
159 LPF_CREATE_MDTOBJ = 0x0080,
161 /* Do not return until the LFSCK not running. */
164 /* Delay to create OST-object for dangling LOV EA. */
165 LPF_DELAY_CREATE_OSTOBJ = 0x0200,
169 /* For MDT and OST internal OSD consistency check/repair. */
170 LFSCK_TYPE_SCRUB = 0x0000,
172 /* For MDT-OST (layout, object) consistency check/repair. */
173 LFSCK_TYPE_LAYOUT = 0x0001,
175 /* For MDT (FID-in-dirent, linkEA) consistency check/repair. */
176 LFSCK_TYPE_NAMESPACE = 0x0004,
177 LFSCK_TYPES_SUPPORTED = (LFSCK_TYPE_SCRUB | LFSCK_TYPE_LAYOUT |
178 LFSCK_TYPE_NAMESPACE),
179 LFSCK_TYPES_DEF = LFSCK_TYPES_SUPPORTED,
180 LFSCK_TYPES_ALL = ((__u16)(~0))
183 #define LFSCK_VERSION_V1 1
184 #define LFSCK_VERSION_V2 2
186 #define LFSCK_SPEED_NO_LIMIT 0
187 #define LFSCK_SPEED_LIMIT_DEF LFSCK_SPEED_NO_LIMIT
188 #define LFSCK_ASYNC_WIN_DEFAULT 1024
189 #define LFSCK_ASYNC_WIN_MAX ((__u16)(~0))
190 #define LFSCK_TYPE_BITS 16
192 enum lfsck_start_valid {
193 LSV_SPEED_LIMIT = 0x00000001,
194 LSV_ERROR_HANDLE = 0x00000002,
195 LSV_DRYRUN = 0x00000004,
196 LSV_ASYNC_WINDOWS = 0x00000008,
197 LSV_CREATE_OSTOBJ = 0x00000010,
198 LSV_CREATE_MDTOBJ = 0x00000020,
199 LSV_DELAY_CREATE_OSTOBJ = 0x00000040,
202 /* Arguments for starting lfsck. */
204 /* Which arguments are valid, see 'enum lfsck_start_valid'. */
207 /* How many items can be scanned at most per second. */
208 __u32 ls_speed_limit;
210 /* For compatibility between user space tools and kernel service. */
213 /* Which LFSCK components to be (have been) started. */
216 /* Flags for the LFSCK, see 'enum lfsck_param_flags'. */
219 /* The windows size for async requests pipeline. */
220 __u16 ls_async_windows;
226 __u16 ls_padding_1; /* For 64-bits aligned. */
233 __u32 lu_mdts_count[LFSCK_TYPE_BITS][LS_MAX + 1];
234 __u32 lu_osts_count[LFSCK_TYPE_BITS][LS_MAX + 1];
235 __u64 lu_repaired[LFSCK_TYPE_BITS];
238 #endif /* _LUSTRE_LFSCK_USER_H */