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