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