Whamcloud - gitweb
LU-7349 lfsck: skip auto resume lfsck when mount
[fs/lustre-release.git] / lustre / include / 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.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2011, 2015, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/include/lustre_disk.h
37  *
38  * Lustre disk format definitions.
39  *
40  * Author: Nathan Rutman <nathan@clusterfs.com>
41  */
42
43 #ifndef _LUSTRE_DISK_H
44 #define _LUSTRE_DISK_H
45
46 /** \defgroup disk disk
47  *
48  * @{
49  */
50
51 #include <libcfs/libcfs.h>
52 #include <lnet/types.h>
53
54 /****************** on-disk files *********************/
55
56 #define MDT_LOGS_DIR            "LOGS"  /* COMPAT_146 */
57 #define MOUNT_CONFIGS_DIR       "CONFIGS"
58 #define CONFIGS_FILE            "mountdata"
59 /** Persistent mount data are stored on the disk in this file. */
60 #define MOUNT_DATA_FILE         MOUNT_CONFIGS_DIR"/"CONFIGS_FILE
61 #define LAST_RCVD               "last_rcvd"
62 #define REPLY_DATA              "reply_data"
63 #define LOV_OBJID               "lov_objid"
64 #define LOV_OBJSEQ              "lov_objseq"
65 #define HEALTH_CHECK            "health_check"
66 #define CAPA_KEYS               "capa_keys"
67 #define CHANGELOG_USERS         "changelog_users"
68 #define MGS_NIDTBL_DIR          "NIDTBL_VERSIONS"
69 #define QMT_DIR                 "quota_master"
70 #define QSD_DIR                 "quota_slave"
71 #define HSM_ACTIONS             "hsm_actions"
72 #define LFSCK_DIR               "LFSCK"
73 #define LFSCK_BOOKMARK          "lfsck_bookmark"
74 #define LFSCK_LAYOUT            "lfsck_layout"
75 #define LFSCK_NAMESPACE         "lfsck_namespace"
76
77 /****************** persistent mount data *********************/
78
79 #define LDD_F_SV_TYPE_MDT   0x0001
80 #define LDD_F_SV_TYPE_OST   0x0002
81 #define LDD_F_SV_TYPE_MGS   0x0004
82 #define LDD_F_SV_TYPE_MASK (LDD_F_SV_TYPE_MDT  | \
83                             LDD_F_SV_TYPE_OST  | \
84                             LDD_F_SV_TYPE_MGS)
85 #define LDD_F_SV_ALL        0x0008
86 /** need an index assignment */
87 #define LDD_F_NEED_INDEX    0x0010
88 /** never registered */
89 #define LDD_F_VIRGIN        0x0020
90 /** update the config logs for this server */
91 #define LDD_F_UPDATE        0x0040
92 /** rewrite the LDD */
93 #define LDD_F_REWRITE_LDD   0x0080
94 /** regenerate config logs for this fs or server */
95 #define LDD_F_WRITECONF     0x0100
96 /** COMPAT_14 */
97 #define LDD_F_UPGRADE14     0x0200
98 /** process as lctl conf_param */
99 #define LDD_F_PARAM         0x0400
100 /** all nodes are specified as service nodes */
101 #define LDD_F_NO_PRIMNODE   0x1000
102 /** IR enable flag */
103 #define LDD_F_IR_CAPABLE    0x2000
104 /** the MGS refused to register the target. */
105 #define LDD_F_ERROR         0x4000
106 /** process at lctl conf_param */
107 #define LDD_F_PARAM2            0x8000
108
109 /* opc for target register */
110 #define LDD_F_OPC_REG   0x10000000
111 #define LDD_F_OPC_UNREG 0x20000000
112 #define LDD_F_OPC_READY 0x40000000
113 #define LDD_F_OPC_MASK  0xf0000000
114
115 #define LDD_F_ONDISK_MASK  (LDD_F_SV_TYPE_MASK)
116
117 #define LDD_F_MASK          0xFFFF
118
119 enum ldd_mount_type {
120         LDD_MT_EXT3 = 0,
121         LDD_MT_LDISKFS,
122         LDD_MT_SMFS,
123         LDD_MT_REISERFS,
124         LDD_MT_LDISKFS2,
125         LDD_MT_ZFS,
126         LDD_MT_LAST
127 };
128
129 static inline char *mt_str(enum ldd_mount_type mt)
130 {
131         static char *mount_type_string[] = {
132                 "ext3",
133                 "ldiskfs",
134                 "smfs",
135                 "reiserfs",
136                 "ldiskfs2",
137                 "zfs",
138         };
139         return mount_type_string[mt];
140 }
141
142 static inline char *mt_type(enum ldd_mount_type mt)
143 {
144         static char *mount_type_string[] = {
145                 "osd-ldiskfs",
146                 "osd-ldiskfs",
147                 "osd-smfs",
148                 "osd-reiserfs",
149                 "osd-ldiskfs",
150                 "osd-zfs",
151         };
152         return mount_type_string[mt];
153 }
154
155 #define LDD_INCOMPAT_SUPP 0
156 #define LDD_ROCOMPAT_SUPP 0
157
158 #define LDD_MAGIC 0x1dd00001
159
160 /* On-disk configuration file. In host-endian order. */
161 struct lustre_disk_data {
162         __u32      ldd_magic;
163         __u32      ldd_feature_compat;  /* compatible feature flags */
164         __u32      ldd_feature_rocompat;/* read-only compatible feature flags */
165         __u32      ldd_feature_incompat;/* incompatible feature flags */
166
167         __u32      ldd_config_ver;      /* config rewrite count - not used */
168         __u32      ldd_flags;           /* LDD_SV_TYPE */
169         __u32      ldd_svindex;         /* server index (0001), must match
170                                            svname */
171         __u32      ldd_mount_type;      /* target fs type LDD_MT_* */
172         char       ldd_fsname[64];      /* filesystem this server is part of,
173                                            MTI_NAME_MAXLEN */
174         char       ldd_svname[64];      /* this server's name (lustre-mdt0001)*/
175         __u8       ldd_uuid[40];        /* server UUID (COMPAT_146) */
176
177 /*200*/ char       ldd_userdata[1024 - 200]; /* arbitrary user string */
178 /*1024*/__u8       ldd_padding[4096 - 1024];
179 /*4096*/char       ldd_mount_opts[4096]; /* target fs mount opts */
180 /*8192*/char       ldd_params[4096];     /* key=value pairs */
181 };
182
183
184 #define IS_MDT(data)    ((data)->lsi_flags & LDD_F_SV_TYPE_MDT)
185 #define IS_OST(data)    ((data)->lsi_flags & LDD_F_SV_TYPE_OST)
186 #define IS_MGS(data)    ((data)->lsi_flags & LDD_F_SV_TYPE_MGS)
187 #define IS_SERVER(data) ((data)->lsi_flags & (LDD_F_SV_TYPE_MGS | \
188                          LDD_F_SV_TYPE_MDT | LDD_F_SV_TYPE_OST))
189 #define MT_STR(data)    mt_str((data)->ldd_mount_type)
190
191 /* Make the mdt/ost server obd name based on the filesystem name */
192 static inline int server_make_name(__u32 flags, __u16 index, char *fs,
193                                    char *name)
194 {
195         if (flags & (LDD_F_SV_TYPE_MDT | LDD_F_SV_TYPE_OST)) {
196                 if (!(flags & LDD_F_SV_ALL))
197                         sprintf(name, "%.8s%c%s%04x", fs,
198                                 (flags & LDD_F_VIRGIN) ? ':' :
199                                         ((flags & LDD_F_WRITECONF) ? '=' : '-'),
200                                 (flags & LDD_F_SV_TYPE_MDT) ? "MDT" : "OST",
201                                 index);
202         } else if (flags & LDD_F_SV_TYPE_MGS) {
203                 sprintf(name, "MGS");
204         } else {
205                 CERROR("unknown server type %#x\n", flags);
206                 return 1;
207         }
208         return 0;
209 }
210
211 /****************** mount command *********************/
212
213 /* The lmd is only used internally by Lustre; mount simply passes
214    everything as string options */
215
216 #define LMD_MAGIC               0xbdacbd03
217 #define LMD_PARAMS_MAXLEN       4096
218
219 /* gleaned from the mount command - no persistent info here */
220 struct lustre_mount_data {
221         __u32      lmd_magic;
222         __u32      lmd_flags;         /* lustre mount flags */
223         int        lmd_mgs_failnodes; /* mgs failover node count */
224         int        lmd_exclude_count;
225         int        lmd_recovery_time_soft;
226         int        lmd_recovery_time_hard;
227         char      *lmd_dev;           /* device name */
228         char      *lmd_profile;       /* client only */
229         char      *lmd_mgssec;        /* sptlrpc flavor to mgs */
230         char      *lmd_opts;          /* lustre mount options (as opposed to
231                                          _device_ mount options) */
232         char      *lmd_params;        /* lustre params */
233         __u32     *lmd_exclude;       /* array of OSTs to ignore */
234         char    *lmd_mgs;           /* MGS nid */
235         char    *lmd_osd_type;      /* OSD type */
236 };
237
238 #define LMD_FLG_SERVER          0x0001  /* Mounting a server */
239 #define LMD_FLG_CLIENT          0x0002  /* Mounting a client */
240 #define LMD_FLG_SKIP_LFSCK      0x0004  /* NOT auto resume LFSCK when mount */
241 #define LMD_FLG_ABORT_RECOV     0x0008  /* Abort recovery */
242 #define LMD_FLG_NOSVC           0x0010  /* Only start MGS/MGC for servers,
243                                            no other services */
244 #define LMD_FLG_NOMGS           0x0020  /* Only start target for servers, reusing
245                                            existing MGS services */
246 #define LMD_FLG_WRITECONF       0x0040  /* Rewrite config log */
247 #define LMD_FLG_NOIR            0x0080  /* NO imperative recovery */
248 #define LMD_FLG_NOSCRUB         0x0100  /* Do not trigger scrub automatically */
249 #define LMD_FLG_MGS             0x0200  /* Also start MGS along with server */
250 #define LMD_FLG_IAM             0x0400  /* IAM dir */
251 #define LMD_FLG_NO_PRIMNODE     0x0800  /* all nodes are service nodes */
252 #define LMD_FLG_VIRGIN          0x1000  /* the service registers first time */
253 #define LMD_FLG_UPDATE          0x2000  /* update parameters */
254 #define LMD_FLG_HSM             0x4000  /* Start coordinator */
255
256 #define lmd_is_client(x) ((x)->lmd_flags & LMD_FLG_CLIENT)
257
258
259 /****************** last_rcvd file *********************/
260
261 /** version recovery epoch */
262 #define LR_EPOCH_BITS   32
263 #define lr_epoch(a) ((a) >> LR_EPOCH_BITS)
264 #define LR_EXPIRE_INTERVALS 16 /**< number of intervals to track transno */
265 #define ENOENT_VERSION 1 /** 'virtual' version of non-existent object */
266
267 #define LR_SERVER_SIZE   512
268 #define LR_CLIENT_START 8192
269 #define LR_CLIENT_SIZE   128
270 #if LR_CLIENT_START < LR_SERVER_SIZE
271 #error "Can't have LR_CLIENT_START < LR_SERVER_SIZE"
272 #endif
273
274 /*
275  * This limit is arbitrary (131072 clients on x86), but it is convenient to use
276  * 2^n * PAGE_CACHE_SIZE * 8 for the number of bits that fit an order-n allocation.
277  * If we need more than 131072 clients (order-2 allocation on x86) then this
278  * should become an array of single-page pointers that are allocated on demand.
279  */
280 #if (128 * 1024UL) > (PAGE_CACHE_SIZE * 8)
281 #define LR_MAX_CLIENTS (128 * 1024UL)
282 #else
283 #define LR_MAX_CLIENTS (PAGE_CACHE_SIZE * 8)
284 #endif
285
286 /** COMPAT_146: this is an OST (temporary) */
287 #define OBD_COMPAT_OST          0x00000002
288 /** COMPAT_146: this is an MDT (temporary) */
289 #define OBD_COMPAT_MDT          0x00000004
290 /** 2.0 server, interop flag to show server version is changed */
291 #define OBD_COMPAT_20           0x00000008
292
293 /** MDS handles LOV_OBJID file */
294 #define OBD_ROCOMPAT_LOVOBJID           0x00000001
295 /** store OST index in the IDIF */
296 #define OBD_ROCOMPAT_IDX_IN_IDIF        0x00000002
297
298 /** OST handles group subdirs */
299 #define OBD_INCOMPAT_GROUPS     0x00000001
300 /** this is an OST */
301 #define OBD_INCOMPAT_OST        0x00000002
302 /** this is an MDT */
303 #define OBD_INCOMPAT_MDT        0x00000004
304 /** common last_rvcd format */
305 #define OBD_INCOMPAT_COMMON_LR  0x00000008
306 /** FID is enabled */
307 #define OBD_INCOMPAT_FID        0x00000010
308 /** Size-on-MDS is enabled */
309 #define OBD_INCOMPAT_SOM        0x00000020
310 /** filesystem using iam format to store directory entries */
311 #define OBD_INCOMPAT_IAM_DIR    0x00000040
312 /** LMA attribute contains per-inode incompatible flags */
313 #define OBD_INCOMPAT_LMA        0x00000080
314 /** lmm_stripe_count has been shrunk from __u32 to __u16 and the remaining 16
315  * bits are now used to store a generation. Once we start changing the layout
316  * and bumping the generation, old versions expecting a 32-bit lmm_stripe_count
317  * will be confused by interpreting stripe_count | gen << 16 as the actual
318  * stripe count */
319 #define OBD_INCOMPAT_LMM_VER    0x00000100
320 /** multiple OI files for MDT */
321 #define OBD_INCOMPAT_MULTI_OI   0x00000200
322 /** multiple RPCs in flight */
323 #define OBD_INCOMPAT_MULTI_RPCS 0x00000400
324
325 /* Data stored per server at the head of the last_rcvd file.  In le32 order.
326    This should be common to filter_internal.h, lustre_mds.h */
327 struct lr_server_data {
328         __u8  lsd_uuid[40];        /* server UUID */
329         __u64 lsd_last_transno;    /* last completed transaction ID */
330         __u64 lsd_compat14;        /* reserved - compat with old last_rcvd */
331         __u64 lsd_mount_count;     /* incarnation number */
332         __u32 lsd_feature_compat;  /* compatible feature flags */
333         __u32 lsd_feature_rocompat;/* read-only compatible feature flags */
334         __u32 lsd_feature_incompat;/* incompatible feature flags */
335         __u32 lsd_server_size;     /* size of server data area */
336         __u32 lsd_client_start;    /* start of per-client data area */
337         __u16 lsd_client_size;     /* size of per-client data area */
338         __u16 lsd_subdir_count;    /* number of subdirectories for objects */
339         __u64 lsd_catalog_oid;     /* recovery catalog object id */
340         __u32 lsd_catalog_ogen;    /* recovery catalog inode generation */
341         __u8  lsd_peeruuid[40];    /* UUID of MDS associated with this OST */
342         __u32 lsd_osd_index;       /* index number of OST in LOV */
343         __u32 lsd_padding1;        /* was lsd_mdt_index, unused in 2.4.0 */
344         __u32 lsd_start_epoch;     /* VBR: start epoch from last boot */
345         /** transaction values since lsd_trans_table_time */
346         __u64 lsd_trans_table[LR_EXPIRE_INTERVALS];
347         /** start point of transno table below */
348         __u32 lsd_trans_table_time; /* time of first slot in table above */
349         __u32 lsd_expire_intervals; /* LR_EXPIRE_INTERVALS */
350         __u8  lsd_padding[LR_SERVER_SIZE - 288];
351 };
352
353 /* Data stored per client in the last_rcvd file.  In le32 order. */
354 struct lsd_client_data {
355         __u8  lcd_uuid[40];      /* client UUID */
356         __u64 lcd_last_transno; /* last completed transaction ID */
357         __u64 lcd_last_xid;     /* xid for the last transaction */
358         __u32 lcd_last_result;  /* result from last RPC */
359         __u32 lcd_last_data;    /* per-op data (disposition for open &c.) */
360         /* for MDS_CLOSE requests */
361         __u64 lcd_last_close_transno; /* last completed transaction ID */
362         __u64 lcd_last_close_xid;     /* xid for the last transaction */
363         __u32 lcd_last_close_result;  /* result from last RPC */
364         __u32 lcd_last_close_data;    /* per-op data */
365         /* VBR: last versions */
366         __u64 lcd_pre_versions[4];
367         __u32 lcd_last_epoch;
368         /* generation counter of client slot in last_rcvd */
369         __u32 lcd_generation;
370         __u8  lcd_padding[LR_CLIENT_SIZE - 128];
371 };
372
373
374 /* Data stored in each slot of the reply_data file.
375  *
376  * The lrd_client_gen field is assigned with lcd_generation value
377  * to allow identify which client the reply data belongs to.
378  */
379 struct lsd_reply_data {
380         __u64   lrd_transno;    /* transaction number */
381         __u64   lrd_xid;        /* transmission id */
382         __u64   lrd_data;       /* per-operation data */
383         __u32   lrd_result;     /* request result */
384         __u32   lrd_client_gen; /* client generation */
385 };
386
387 /* Header of the reply_data file */
388 #define LRH_MAGIC 0xbdabda01
389 struct lsd_reply_header {
390         __u32   lrh_magic;
391         __u32   lrh_header_size;
392         __u32   lrh_reply_size;
393         __u8    lrh_pad[sizeof(struct lsd_reply_data) - 12];
394 };
395
396
397 /* bug20354: the lcd_uuid for export of clients may be wrong */
398 static inline void check_lcd(char *obd_name, int index,
399                              struct lsd_client_data *lcd)
400 {
401         size_t length = sizeof(lcd->lcd_uuid);
402         if (strnlen((char*)lcd->lcd_uuid, length) == length) {
403                 lcd->lcd_uuid[length - 1] = '\0';
404
405                 LCONSOLE_ERROR("the client UUID (%s) on %s for exports"
406                                "stored in last_rcvd(index = %d) is bad!\n",
407                                lcd->lcd_uuid, obd_name, index);
408         }
409 }
410
411 /* last_rcvd handling */
412 static inline void lsd_le_to_cpu(struct lr_server_data *buf,
413                                  struct lr_server_data *lsd)
414 {
415         int i;
416         memcpy(lsd->lsd_uuid, buf->lsd_uuid, sizeof(lsd->lsd_uuid));
417         lsd->lsd_last_transno     = le64_to_cpu(buf->lsd_last_transno);
418         lsd->lsd_compat14         = le64_to_cpu(buf->lsd_compat14);
419         lsd->lsd_mount_count      = le64_to_cpu(buf->lsd_mount_count);
420         lsd->lsd_feature_compat   = le32_to_cpu(buf->lsd_feature_compat);
421         lsd->lsd_feature_rocompat = le32_to_cpu(buf->lsd_feature_rocompat);
422         lsd->lsd_feature_incompat = le32_to_cpu(buf->lsd_feature_incompat);
423         lsd->lsd_server_size      = le32_to_cpu(buf->lsd_server_size);
424         lsd->lsd_client_start     = le32_to_cpu(buf->lsd_client_start);
425         lsd->lsd_client_size      = le16_to_cpu(buf->lsd_client_size);
426         lsd->lsd_subdir_count     = le16_to_cpu(buf->lsd_subdir_count);
427         lsd->lsd_catalog_oid      = le64_to_cpu(buf->lsd_catalog_oid);
428         lsd->lsd_catalog_ogen     = le32_to_cpu(buf->lsd_catalog_ogen);
429         memcpy(lsd->lsd_peeruuid, buf->lsd_peeruuid, sizeof(lsd->lsd_peeruuid));
430         lsd->lsd_osd_index        = le32_to_cpu(buf->lsd_osd_index);
431         lsd->lsd_padding1        = le32_to_cpu(buf->lsd_padding1);
432         lsd->lsd_start_epoch      = le32_to_cpu(buf->lsd_start_epoch);
433         for (i = 0; i < LR_EXPIRE_INTERVALS; i++)
434                 lsd->lsd_trans_table[i] = le64_to_cpu(buf->lsd_trans_table[i]);
435         lsd->lsd_trans_table_time = le32_to_cpu(buf->lsd_trans_table_time);
436         lsd->lsd_expire_intervals = le32_to_cpu(buf->lsd_expire_intervals);
437 }
438
439 static inline void lsd_cpu_to_le(struct lr_server_data *lsd,
440                                  struct lr_server_data *buf)
441 {
442         int i;
443         memcpy(buf->lsd_uuid, lsd->lsd_uuid, sizeof(buf->lsd_uuid));
444         buf->lsd_last_transno     = cpu_to_le64(lsd->lsd_last_transno);
445         buf->lsd_compat14         = cpu_to_le64(lsd->lsd_compat14);
446         buf->lsd_mount_count      = cpu_to_le64(lsd->lsd_mount_count);
447         buf->lsd_feature_compat   = cpu_to_le32(lsd->lsd_feature_compat);
448         buf->lsd_feature_rocompat = cpu_to_le32(lsd->lsd_feature_rocompat);
449         buf->lsd_feature_incompat = cpu_to_le32(lsd->lsd_feature_incompat);
450         buf->lsd_server_size      = cpu_to_le32(lsd->lsd_server_size);
451         buf->lsd_client_start     = cpu_to_le32(lsd->lsd_client_start);
452         buf->lsd_client_size      = cpu_to_le16(lsd->lsd_client_size);
453         buf->lsd_subdir_count     = cpu_to_le16(lsd->lsd_subdir_count);
454         buf->lsd_catalog_oid      = cpu_to_le64(lsd->lsd_catalog_oid);
455         buf->lsd_catalog_ogen     = cpu_to_le32(lsd->lsd_catalog_ogen);
456         memcpy(buf->lsd_peeruuid, lsd->lsd_peeruuid, sizeof(buf->lsd_peeruuid));
457         buf->lsd_osd_index        = cpu_to_le32(lsd->lsd_osd_index);
458         buf->lsd_padding1         = cpu_to_le32(lsd->lsd_padding1);
459         buf->lsd_start_epoch      = cpu_to_le32(lsd->lsd_start_epoch);
460         for (i = 0; i < LR_EXPIRE_INTERVALS; i++)
461                 buf->lsd_trans_table[i] = cpu_to_le64(lsd->lsd_trans_table[i]);
462         buf->lsd_trans_table_time = cpu_to_le32(lsd->lsd_trans_table_time);
463         buf->lsd_expire_intervals = cpu_to_le32(lsd->lsd_expire_intervals);
464 }
465
466 static inline void lcd_le_to_cpu(struct lsd_client_data *buf,
467                                  struct lsd_client_data *lcd)
468 {
469         memcpy(lcd->lcd_uuid, buf->lcd_uuid, sizeof (lcd->lcd_uuid));
470         lcd->lcd_last_transno       = le64_to_cpu(buf->lcd_last_transno);
471         lcd->lcd_last_xid           = le64_to_cpu(buf->lcd_last_xid);
472         lcd->lcd_last_result        = le32_to_cpu(buf->lcd_last_result);
473         lcd->lcd_last_data          = le32_to_cpu(buf->lcd_last_data);
474         lcd->lcd_last_close_transno = le64_to_cpu(buf->lcd_last_close_transno);
475         lcd->lcd_last_close_xid     = le64_to_cpu(buf->lcd_last_close_xid);
476         lcd->lcd_last_close_result  = le32_to_cpu(buf->lcd_last_close_result);
477         lcd->lcd_last_close_data    = le32_to_cpu(buf->lcd_last_close_data);
478         lcd->lcd_pre_versions[0]    = le64_to_cpu(buf->lcd_pre_versions[0]);
479         lcd->lcd_pre_versions[1]    = le64_to_cpu(buf->lcd_pre_versions[1]);
480         lcd->lcd_pre_versions[2]    = le64_to_cpu(buf->lcd_pre_versions[2]);
481         lcd->lcd_pre_versions[3]    = le64_to_cpu(buf->lcd_pre_versions[3]);
482         lcd->lcd_last_epoch         = le32_to_cpu(buf->lcd_last_epoch);
483         lcd->lcd_generation         = le32_to_cpu(buf->lcd_generation);
484 }
485
486 static inline void lcd_cpu_to_le(struct lsd_client_data *lcd,
487                                  struct lsd_client_data *buf)
488 {
489         memcpy(buf->lcd_uuid, lcd->lcd_uuid, sizeof (lcd->lcd_uuid));
490         buf->lcd_last_transno       = cpu_to_le64(lcd->lcd_last_transno);
491         buf->lcd_last_xid           = cpu_to_le64(lcd->lcd_last_xid);
492         buf->lcd_last_result        = cpu_to_le32(lcd->lcd_last_result);
493         buf->lcd_last_data          = cpu_to_le32(lcd->lcd_last_data);
494         buf->lcd_last_close_transno = cpu_to_le64(lcd->lcd_last_close_transno);
495         buf->lcd_last_close_xid     = cpu_to_le64(lcd->lcd_last_close_xid);
496         buf->lcd_last_close_result  = cpu_to_le32(lcd->lcd_last_close_result);
497         buf->lcd_last_close_data    = cpu_to_le32(lcd->lcd_last_close_data);
498         buf->lcd_pre_versions[0]    = cpu_to_le64(lcd->lcd_pre_versions[0]);
499         buf->lcd_pre_versions[1]    = cpu_to_le64(lcd->lcd_pre_versions[1]);
500         buf->lcd_pre_versions[2]    = cpu_to_le64(lcd->lcd_pre_versions[2]);
501         buf->lcd_pre_versions[3]    = cpu_to_le64(lcd->lcd_pre_versions[3]);
502         buf->lcd_last_epoch         = cpu_to_le32(lcd->lcd_last_epoch);
503         buf->lcd_generation         = cpu_to_le32(lcd->lcd_generation);
504 }
505
506 static inline __u64 lcd_last_transno(struct lsd_client_data *lcd)
507 {
508         return (lcd->lcd_last_transno > lcd->lcd_last_close_transno ?
509                 lcd->lcd_last_transno : lcd->lcd_last_close_transno);
510 }
511
512 static inline __u64 lcd_last_xid(struct lsd_client_data *lcd)
513 {
514         return (lcd->lcd_last_xid > lcd->lcd_last_close_xid ?
515                 lcd->lcd_last_xid : lcd->lcd_last_close_xid);
516 }
517
518 /****************** superblock additional info *********************/
519 #ifdef __KERNEL__
520
521 struct ll_sb_info;
522
523 struct lustre_sb_info {
524         int                       lsi_flags;
525         struct obd_device        *lsi_mgc;     /* mgc obd */
526         struct lustre_mount_data *lsi_lmd;     /* mount command info */
527         struct ll_sb_info        *lsi_llsbi;   /* add'l client sbi info */
528         struct dt_device         *lsi_dt_dev;  /* dt device to access disk fs*/
529         atomic_t                  lsi_mounts;  /* references to the srv_mnt */
530         char                      lsi_svname[MTI_NAME_MAXLEN];
531         char                      lsi_osd_obdname[64];
532         char                      lsi_osd_uuid[64];
533         struct obd_export        *lsi_osd_exp;
534         char                      lsi_osd_type[16];
535         char                      lsi_fstype[16];
536         struct backing_dev_info   lsi_bdi;     /* each client mountpoint needs
537                                                   own backing_dev_info */
538         struct list_head          lsi_lwp_list;
539         spinlock_t                lsi_lwp_lock;
540         unsigned long             lsi_lwp_started:1;
541 };
542
543 #define LSI_UMOUNT_FAILOVER              0x00200000
544 #define LSI_BDI_INITIALIZED              0x00400000
545
546 #define     s2lsi(sb)        ((struct lustre_sb_info *)((sb)->s_fs_info))
547 #define     s2lsi_nocast(sb) ((sb)->s_fs_info)
548
549 #define     get_profile_name(sb)   (s2lsi(sb)->lsi_lmd->lmd_profile)
550 #define     get_mount_flags(sb)    (s2lsi(sb)->lsi_lmd->lmd_flags)
551 #define     get_mntdev_name(sb)    (s2lsi(sb)->lsi_lmd->lmd_dev)
552
553 #endif /* __KERNEL__ */
554
555 /****************** mount lookup info *********************/
556
557 struct lustre_mount_info {
558         char                    *lmi_name;
559         struct super_block      *lmi_sb;
560         struct list_head         lmi_list_chain;
561 };
562
563 /****************** prototypes *********************/
564
565 #ifdef __KERNEL__
566 /* obd_mount.c */
567 int server_name2fsname(const char *svname, char *fsname, const char **endptr);
568 int server_name2svname(const char *label, char *svname, const char **endptr,
569                        size_t svsize);
570 int server_name_is_ost(const char *svname);
571 int target_name2index(const char *svname, __u32 *idx, const char **endptr);
572
573 int lustre_put_lsi(struct super_block *sb);
574 int lustre_start_simple(char *obdname, char *type, char *uuid,
575                         char *s1, char *s2, char *s3, char *s4);
576 int lustre_start_mgc(struct super_block *sb);
577 void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb,
578                                                   struct vfsmount *mnt));
579 void lustre_register_kill_super_cb(void (*cfs)(struct super_block *sb));
580 int lustre_common_put_super(struct super_block *sb);
581
582 # ifdef HAVE_SERVER_SUPPORT
583 /* obd_mount_server.c */
584 int server_fill_super(struct super_block *sb);
585 struct lustre_mount_info *server_get_mount(const char *name);
586 int server_put_mount(const char *name, bool dereg_mnt);
587 struct mgs_target_info;
588 int server_mti_print(const char *title, struct mgs_target_info *mti);
589 void server_calc_timeout(struct lustre_sb_info *lsi, struct obd_device *obd);
590 # endif
591
592 int mgc_fsname2resid(char *fsname, struct ldlm_res_id *res_id, int type);
593 #endif /* __KERNEL__ */
594
595 /** @} disk */
596
597 #endif // _LUSTRE_DISK_H