Whamcloud - gitweb
LU-12273 lod: metadata overstriping
[fs/lustre-release.git] / lustre / include / uapi / linux / lustre / lustre_disk.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, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2011, 2016, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  *
31  * Lustre disk format definitions.
32  *
33  * Author: Nathan Rutman <nathan.rutman@seagate.com>
34  */
35
36 #ifndef _UAPI_LUSTRE_DISK_H
37 #define _UAPI_LUSTRE_DISK_H
38
39 /** \defgroup disk disk
40  *
41  * @{
42  */
43 #include <linux/types.h>
44 #include <linux/uuid.h>
45 #include <linux/lnet/lnet-types.h> /* for lnet_nid_t */
46
47 /****************** on-disk files ********************/
48
49 #define MDT_LOGS_DIR            "LOGS"  /* COMPAT_146 */
50 #define MOUNT_CONFIGS_DIR       "CONFIGS"
51 #define CONFIGS_FILE            "mountdata"
52 /** Persistent mount data are stored on the disk in this file. */
53 #define MOUNT_DATA_FILE         MOUNT_CONFIGS_DIR"/"CONFIGS_FILE
54 #define LAST_RCVD               "last_rcvd"
55 #define REPLY_DATA              "reply_data"
56 #define LOV_OBJID               "lov_objid"
57 #define LOV_OBJSEQ              "lov_objseq"
58 #define HEALTH_CHECK            "health_check"
59 #define CAPA_KEYS               "capa_keys"
60 #define CHANGELOG_USERS         "changelog_users"
61 #define MGS_NIDTBL_DIR          "NIDTBL_VERSIONS"
62 #define QMT_DIR                 "quota_master"
63 #define QSD_DIR                 "quota_slave"
64 #define QSD_DIR_DT              "quota_slave_dt"
65 #define QSD_DIR_MD              "quota_slave_md"
66 #define HSM_ACTIONS             "hsm_actions"
67 #define LFSCK_DIR               "LFSCK"
68 #define LFSCK_BOOKMARK          "lfsck_bookmark"
69 #define LFSCK_LAYOUT            "lfsck_layout"
70 #define LFSCK_NAMESPACE         "lfsck_namespace"
71 #define REMOTE_PARENT_DIR       "REMOTE_PARENT_DIR"
72 #define INDEX_BACKUP_DIR        "index_backup"
73 #define MDT_ORPHAN_DIR          "PENDING"
74
75 /* On-disk configuration file. In host-endian order. */
76 struct lustre_disk_data {
77         __u32 ldd_magic;
78         __u32 ldd_feature_compat;       /* compatible feature flags */
79         __u32 ldd_feature_rocompat;     /* read-only compatible feature flags */
80         __u32 ldd_feature_incompat;     /* incompatible feature flags */
81
82         __u32 ldd_config_ver;           /* config rewrite count - not used */
83         __u32 ldd_flags;                /* LDD_SV_TYPE */
84         __u32 ldd_svindex;              /* server index (0001), must match
85                                          * svname
86                                          */
87         __u32 ldd_mount_type;           /* target fs type LDD_MT_* */
88         char  ldd_fsname[64];           /* filesystem this server is part of,
89                                          * MTI_NAME_MAXLEN
90                                          */
91         char  ldd_svname[64];           /* this server's name (lustre-mdt0001)*/
92         __u8  ldd_uuid[40];             /* server UUID (COMPAT_146) */
93
94         char  ldd_userdata[1024 - 200]; /* arbitrary user string '200' */
95         __u8  ldd_padding[4096 - 1024]; /* 1024 */
96         char  ldd_mount_opts[4096];     /* target fs mount opts '4096' */
97         char  ldd_params[4096];         /* key=value pairs '8192' */
98 };
99
100 /****************** persistent mount data *********************/
101
102 #define LDD_F_SV_TYPE_MDT       0x0001
103 #define LDD_F_SV_TYPE_OST       0x0002
104 #define LDD_F_SV_TYPE_MGS       0x0004
105 #define LDD_F_SV_TYPE_MASK      (LDD_F_SV_TYPE_MDT  | \
106                                  LDD_F_SV_TYPE_OST  | \
107                                  LDD_F_SV_TYPE_MGS)
108 #define LDD_F_SV_ALL            0x0008
109 /** need an index assignment */
110 #define LDD_F_NEED_INDEX        0x0010
111 /** never registered */
112 #define LDD_F_VIRGIN            0x0020
113 /** update the config logs for this server */
114 #define LDD_F_UPDATE            0x0040
115 /** rewrite the LDD */
116 #define LDD_F_REWRITE_LDD       0x0080
117 /** regenerate config logs for this fs or server */
118 #define LDD_F_WRITECONF         0x0100
119 /** COMPAT_14 */
120 /*#define LDD_F_UPGRADE14               0x0200 deprecated since 1.8 */
121 /** process as lctl conf_param */
122 #define LDD_F_PARAM             0x0400
123 /** all nodes are specified as service nodes */
124 #define LDD_F_NO_PRIMNODE       0x1000
125 /** IR enable flag */
126 #define LDD_F_IR_CAPABLE        0x2000
127 /** the MGS refused to register the target. */
128 #define LDD_F_ERROR             0x4000
129 /** process at lctl conf_param */
130 #define LDD_F_PARAM2            0x8000
131 /** the target shouldn't use local logs */
132 #define LDD_F_NO_LOCAL_LOGS     0x10000
133
134 #define LDD_MAGIC 0x1dd00001
135
136 #define XATTR_TARGET_RENAME "trusted.rename_tgt"
137
138 enum ldd_mount_type {
139         LDD_MT_EXT3 = 0,
140         LDD_MT_LDISKFS = 1,
141         LDD_MT_REISERFS = 3,
142         LDD_MT_LDISKFS2 = 4,
143         LDD_MT_ZFS = 5,
144         LDD_MT_LAST
145 };
146
147 /****************** last_rcvd file *********************/
148
149 #define LR_EXPIRE_INTERVALS 16  /**< number of intervals to track transno */
150 #define LR_SERVER_SIZE  512
151 #define LR_CLIENT_START 8192
152 #define LR_CLIENT_SIZE  128
153 #if LR_CLIENT_START < LR_SERVER_SIZE
154 #error "Can't have LR_CLIENT_START < LR_SERVER_SIZE"
155 #endif
156
157 /*
158  * Data stored per server at the head of the last_rcvd file. In le32 order.
159  */
160 struct lr_server_data {
161         __u8  lsd_uuid[40];        /* server UUID */
162         __u64 lsd_last_transno;    /* last completed transaction ID */
163         __u64 lsd_compat14;        /* reserved - compat with old last_rcvd */
164         __u64 lsd_mount_count;     /* incarnation number */
165         __u32 lsd_feature_compat;  /* compatible feature flags */
166         __u32 lsd_feature_rocompat;/* read-only compatible feature flags */
167         __u32 lsd_feature_incompat;/* incompatible feature flags */
168         __u32 lsd_server_size;     /* size of server data area */
169         __u32 lsd_client_start;    /* start of per-client data area */
170         __u16 lsd_client_size;     /* size of per-client data area */
171         __u16 lsd_subdir_count;    /* number of subdirectories for objects */
172         __u64 lsd_catalog_oid;     /* recovery catalog object id */
173         __u32 lsd_catalog_ogen;    /* recovery catalog inode generation */
174         __u8  lsd_peeruuid[40];    /* UUID of MDS associated with this OST */
175         __u32 lsd_osd_index;       /* index number of OST in LOV */
176         __u32 lsd_padding1;        /* was lsd_mdt_index, unused in 2.4.0 */
177         __u32 lsd_start_epoch;     /* VBR: start epoch from last boot */
178         /** transaction values since lsd_trans_table_time */
179         __u64 lsd_trans_table[LR_EXPIRE_INTERVALS];
180         /** start point of transno table below */
181         __u32 lsd_trans_table_time; /* time of first slot in table above */
182         __u32 lsd_expire_intervals; /* LR_EXPIRE_INTERVALS */
183         __u8  lsd_padding[LR_SERVER_SIZE - 288];
184 };
185
186 /* Data stored per client in the last_rcvd file. In le32 order. */
187 struct lsd_client_data {
188         __u8  lcd_uuid[40];             /* client UUID */
189         __u64 lcd_last_transno;         /* last completed transaction ID */
190         __u64 lcd_last_xid;             /* xid for the last transaction */
191         __u32 lcd_last_result;          /* result from last RPC */
192         __u32 lcd_last_data;            /* per-op data (disposition for
193                                          * open &c.)
194                                          */
195         /* for MDS_CLOSE requests */
196         __u64 lcd_last_close_transno;   /* last completed transaction ID */
197         __u64 lcd_last_close_xid;       /* xid for the last transaction */
198         __u32 lcd_last_close_result;    /* result from last RPC */
199         __u32 lcd_last_close_data;      /* per-op data */
200         /* VBR: last versions */
201         __u64 lcd_pre_versions[4];
202         __u32 lcd_last_epoch;
203         /* generation counter of client slot in last_rcvd */
204         __u32 lcd_generation;
205         __u8  lcd_padding[LR_CLIENT_SIZE - 128];
206 };
207
208 /* Data stored in each slot of the reply_data file.
209  *
210  * The lrd_client_gen field is assigned with lcd_generation value
211  * to allow identify which client the reply data belongs to.
212  */
213 struct lsd_reply_data_v1 {
214         __u64 lrd_transno;      /* transaction number */
215         __u64 lrd_xid;          /* transmission id */
216         __u64 lrd_data;         /* per-operation data */
217         __u32 lrd_result;       /* request result */
218         __u32 lrd_client_gen;   /* client generation */
219 };
220
221 struct lsd_reply_data_v2 {
222         __u64 lrd_transno;      /* transaction number */
223         __u64 lrd_xid;          /* transmission id */
224         __u64 lrd_data;         /* per-operation data */
225         __u32 lrd_result;       /* request result */
226         __u32 lrd_client_gen;   /* client generation */
227         __u32 lrd_batch_idx;    /* sub request index in the batched RPC */
228         __u32 lrd_padding[7];   /* unused fields, total size is 8X __u64 */
229 };
230
231 #define lsd_reply_data lsd_reply_data_v2
232
233 /* Header of the reply_data file */
234 #define LRH_MAGIC_V1            0xbdabda01
235 #define LRH_MAGIC_V2            0xbdabda02
236 #define LRH_MAGIC               LRH_MAGIC_V1
237
238 /* Don't change the header size for compatibility. */
239 struct lsd_reply_header {
240         __u32   lrh_magic;
241         __u32   lrh_header_size;
242         __u32   lrh_reply_size;
243         __u8    lrh_pad[sizeof(struct lsd_reply_data_v1) - 12];
244 };
245
246 /****************** nodemap *********************/
247
248 enum nodemap_idx_type {
249         NODEMAP_EMPTY_IDX = 0,          /* index created with blank record */
250         NODEMAP_CLUSTER_IDX = 1,        /* a nodemap cluster of nodes */
251         NODEMAP_RANGE_IDX = 2,          /* nid range assigned to a nm cluster */
252         NODEMAP_UIDMAP_IDX = 3,         /* uid map assigned to a nm cluster */
253         NODEMAP_GIDMAP_IDX = 4,         /* gid map assigned to a nm cluster */
254         NODEMAP_PROJIDMAP_IDX = 5,      /* projid map assigned to nm cluster */
255         NODEMAP_NID_MASK_IDX = 6,       /* large NID setup for a nm cluster */
256         NODEMAP_GLOBAL_IDX = 15,        /* stores nodemap activation status */
257 };
258
259 /* This is needed for struct nodemap_clustre_rec. Please don't move
260  * to lustre_idl.h which will break user land builds.
261  */
262 #define LUSTRE_NODEMAP_NAME_LENGTH     16
263
264 /* lu_nodemap flags */
265 enum nm_flag_bits {
266         NM_FL_ALLOW_ROOT_ACCESS = 0x1,
267         NM_FL_TRUST_CLIENT_IDS = 0x2,
268         NM_FL_DENY_UNKNOWN = 0x4,
269         NM_FL_MAP_UID = 0x8,
270         NM_FL_MAP_GID = 0x10,
271         NM_FL_ENABLE_AUDIT = 0x20,
272         NM_FL_FORBID_ENCRYPT = 0x40,
273         NM_FL_MAP_PROJID = 0x80,
274 };
275
276 enum nm_flag2_bits {
277         NM_FL2_READONLY_MOUNT = 0x1,
278 };
279
280 /* Nodemap records, uses 32 byte record length.
281  * New nodemap config records can be added into NODEMAP_CLUSTER_IDX
282  * with a new nk_cluster_subid value, as long as the records are
283  * kept at 32 bytes in size.  New global config records can be added
284  * into NODEMAP_GLOBAL_IDX with a new nk_global_subid.  This avoids
285  * breaking compatibility.  Do not change the record size.  If a
286  * new ID type or range is needed, a new IDX type should be used.
287  */
288 struct nodemap_cluster_rec {
289         char                    ncr_name[LUSTRE_NODEMAP_NAME_LENGTH + 1];
290         enum nm_flag_bits       ncr_flags:8;
291         enum nm_flag2_bits      ncr_flags2:8;
292         __u8                    ncr_padding1;
293         __u32                   ncr_squash_projid;
294         __u32                   ncr_squash_uid;
295         __u32                   ncr_squash_gid;
296 };
297
298 /* lnet_nid_t is 8 bytes */
299 struct nodemap_range_rec {
300         lnet_nid_t      nrr_start_nid;
301         lnet_nid_t      nrr_end_nid;
302         __u64           nrr_padding1;
303         __u64           nrr_padding2;
304 };
305
306 struct nodemap_range2_rec {
307         struct lnet_nid nrr_nid_prefix;
308         __u32           nrr_padding1; /* these fields may be used if */
309         __u32           nrr_padding2; /* nrr_nid_prefix.nid_size > 12 */
310         __u16           nrr_padding3;
311         __u8            nrr_padding4;
312         __u8            nrr_netmask;
313 };
314
315 struct nodemap_id_rec {
316         __u32   nir_id_fs;
317         __u32   nir_padding1;
318         __u64   nir_padding2;
319         __u64   nir_padding3;
320         __u64   nir_padding4;
321 };
322
323 struct nodemap_global_rec {
324         __u8    ngr_is_active;
325         __u8    ngr_padding1;
326         __u16   ngr_padding2;
327         __u32   ngr_padding3;
328         __u64   ngr_padding4;
329         __u64   ngr_padding5;
330         __u64   ngr_padding6;
331 };
332
333 struct nodemap_cluster_roles_rec {
334         __u64 ncrr_roles;       /* enum nodemap_rbac_roles */
335         __u64 ncrr_unused1;
336         __u64 ncrr_unused2;
337         __u64 ncrr_unused3;
338 };
339
340 union nodemap_rec {
341         struct nodemap_cluster_rec ncr;
342         struct nodemap_range_rec nrr;
343         struct nodemap_range2_rec nrr2;
344         struct nodemap_id_rec nir;
345         struct nodemap_global_rec ngr;
346         struct nodemap_cluster_roles_rec ncrr;
347 };
348
349 /* sub-keys for records of type NODEMAP_CLUSTER_IDX */
350 enum nodemap_cluster_rec_subid {
351         NODEMAP_CLUSTER_REC = 0,   /* nodemap_cluster_rec */
352         NODEMAP_CLUSTER_ROLES = 1, /* nodemap_cluster_roles_rec */
353 };
354
355 /* first 4 bits of the nodemap_id is the index type */
356 struct nodemap_key {
357         __u32 nk_nodemap_id;
358         union {
359                 __u32 nk_cluster_subid;
360                 __u32 nk_range_id;
361                 __u32 nk_id_client;
362                 __u32 nk_unused;
363         };
364 };
365
366 #define NM_TYPE_MASK 0x0FFFFFFF
367 #define NM_TYPE_SHIFT 28
368
369 /* file structure used for saving OI scrub bookmark state for restart */
370 #define OSD_OI_FID_OID_BITS_MAX 10
371 #define OSD_OI_FID_NR_MAX       (1UL << OSD_OI_FID_OID_BITS_MAX)
372 #define SCRUB_OI_BITMAP_SIZE    (OSD_OI_FID_NR_MAX >> 3)
373
374 #define SCRUB_MAGIC_V1                  0x4C5FD252
375 #define SCRUB_MAGIC_V2                  0x4C5FE253
376
377 enum scrub_flags {
378         /* OI files have been recreated, OI mappings should be re-inserted. */
379         SF_RECREATED    = 0x0000000000000001ULL,
380
381         /* OI files are invalid, should be rebuild ASAP */
382         SF_INCONSISTENT = 0x0000000000000002ULL,
383
384         /* OI scrub is triggered automatically. */
385         SF_AUTO         = 0x0000000000000004ULL,
386
387         /* The device is upgraded from 1.8 format. */
388         SF_UPGRADE      = 0x0000000000000008ULL,
389 };
390
391 enum scrub_status {
392         /* The scrub file is new created, for new MDT, upgrading from old disk,
393          * or re-creating the scrub file manually.
394          */
395         SS_INIT         = 0,
396
397         /* The scrub is checking/repairing the OI files. */
398         SS_SCANNING     = 1,
399
400         /* The scrub checked/repaired the OI files successfully. */
401         SS_COMPLETED    = 2,
402
403         /* The scrub failed to check/repair the OI files. */
404         SS_FAILED       = 3,
405
406         /* The scrub is stopped manually, the OI files may be inconsistent. */
407         SS_STOPPED      = 4,
408
409         /* The scrub is paused automatically when umount. */
410         SS_PAUSED       = 5,
411
412         /* The scrub crashed during the scanning, should be restarted. */
413         SS_CRASHED      = 6,
414 };
415
416 enum scrub_param {
417         /* Exit when fail. */
418         SP_FAILOUT      = 0x0001,
419
420         /* Check only without repairing. */
421         SP_DRYRUN       = 0x0002,
422 };
423
424 #ifdef __KERNEL__
425 /* v6.2-rc5-72-g5e6a51787fef kernel APIs need type to be guid_t */
426 #define uuid_le        guid_t
427 #endif
428
429 struct scrub_file {
430         uuid_le sf_uuid;                    /* 128-bit uuid for volume */
431         __u64   sf_flags;                   /* see 'enum scrub_flags' */
432         __u32   sf_magic;                   /* SCRUB_MAGIC_V1/V2 */
433         __u16   sf_status;                  /* see 'enum scrub_status' */
434         __u16   sf_param;                   /* see 'enum scrub_param' */
435         __s64   sf_time_last_complete;      /* wallclock of last scrub finish */
436         __s64   sf_time_latest_start;       /* wallclock of last scrub run */
437         __s64   sf_time_last_checkpoint;    /* wallclock of last checkpoint */
438         __u64   sf_pos_latest_start;        /* OID of last scrub start */
439         __u64   sf_pos_last_checkpoint;     /* OID of last scrub checkpoint */
440         __u64   sf_pos_first_inconsistent;  /* OID first object to update */
441         __u64   sf_items_checked;           /* number objects checked */
442         __u64   sf_items_updated;           /* number objects updated */
443         __u64   sf_items_failed;            /* number objects unrepairable */
444         __u64   sf_items_updated_prior;     /* num objects fixed before scan */
445         __u64   sf_items_noscrub;           /* number of objects skipped due to
446                                              * LDISKFS_STATE_LUSTRE_NOSCRUB
447                                              */
448         __u64   sf_items_igif;              /* number of IGIF(no FID) objects */
449         __u32   sf_run_time;                /* scrub runtime in seconds */
450         __u32   sf_success_count;           /* number of completed runs */
451         __u16   sf_oi_count;                /* number of OI files */
452         __u16   sf_internal_flags;          /* flags to keep after reset, see
453                                              * 'enum scrub_internal_flags'
454                                              */
455         __u32   sf_reserved_1;
456         __u64   sf_reserved_2[16];
457         __u8    sf_oi_bitmap[SCRUB_OI_BITMAP_SIZE]; /* OI files recreated */
458 };
459
460 /** @} disk */
461
462 #endif /* _UAPI_LUSTRE_DISK_H */