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