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