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