b69bd9da9470ff86e7a6cf92ffc4d5ca8f2eb5a7
[cascardo/linux.git] / drivers / staging / lustre / 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, 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 "../../include/linux/libcfs/libcfs.h"
52 #include "../../include/linux/lnet/types.h"
53 #include <linux/backing-dev.h>
54
55 /****************** persistent mount data *********************/
56
57 #define LDD_F_SV_TYPE_MDT   0x0001
58 #define LDD_F_SV_TYPE_OST   0x0002
59 #define LDD_F_SV_TYPE_MGS   0x0004
60 #define LDD_F_SV_TYPE_MASK (LDD_F_SV_TYPE_MDT  | \
61                             LDD_F_SV_TYPE_OST  | \
62                             LDD_F_SV_TYPE_MGS)
63 #define LDD_F_SV_ALL    0x0008
64
65 /****************** mount command *********************/
66
67 /* The lmd is only used internally by Lustre; mount simply passes
68    everything as string options */
69
70 #define LMD_MAGIC    0xbdacbd03
71 #define LMD_PARAMS_MAXLEN       4096
72
73 /* gleaned from the mount command - no persistent info here */
74 struct lustre_mount_data {
75         __u32      lmd_magic;
76         __u32      lmd_flags;    /* lustre mount flags */
77         int     lmd_mgs_failnodes; /* mgs failover node count */
78         int     lmd_exclude_count;
79         int     lmd_recovery_time_soft;
80         int     lmd_recovery_time_hard;
81         char      *lmd_dev;        /* device name */
82         char      *lmd_profile;       /* client only */
83         char      *lmd_mgssec;  /* sptlrpc flavor to mgs */
84         char      *lmd_opts;      /* lustre mount options (as opposed to
85                                          _device_ mount options) */
86         char      *lmd_params;  /* lustre params */
87         __u32     *lmd_exclude;       /* array of OSTs to ignore */
88         char    *lmd_mgs;          /* MGS nid */
89         char    *lmd_osd_type;      /* OSD type */
90 };
91
92 #define LMD_FLG_SERVER          0x0001  /* Mounting a server */
93 #define LMD_FLG_CLIENT          0x0002  /* Mounting a client */
94 #define LMD_FLG_ABORT_RECOV     0x0008  /* Abort recovery */
95 #define LMD_FLG_NOSVC           0x0010  /* Only start MGS/MGC for servers,
96                                            no other services */
97 #define LMD_FLG_NOMGS           0x0020  /* Only start target for servers, reusing
98                                            existing MGS services */
99 #define LMD_FLG_WRITECONF       0x0040  /* Rewrite config log */
100 #define LMD_FLG_NOIR            0x0080  /* NO imperative recovery */
101 #define LMD_FLG_NOSCRUB         0x0100  /* Do not trigger scrub automatically */
102 #define LMD_FLG_MGS             0x0200  /* Also start MGS along with server */
103 #define LMD_FLG_IAM             0x0400  /* IAM dir */
104 #define LMD_FLG_NO_PRIMNODE     0x0800  /* all nodes are service nodes */
105 #define LMD_FLG_VIRGIN          0x1000  /* the service registers first time */
106 #define LMD_FLG_UPDATE          0x2000  /* update parameters */
107 #define LMD_FLG_HSM             0x4000  /* Start coordinator */
108
109 #define lmd_is_client(x) ((x)->lmd_flags & LMD_FLG_CLIENT)
110
111 /****************** last_rcvd file *********************/
112
113 /** version recovery epoch */
114 #define LR_EPOCH_BITS   32
115 #define lr_epoch(a) ((a) >> LR_EPOCH_BITS)
116 #define LR_EXPIRE_INTERVALS 16 /**< number of intervals to track transno */
117 #define ENOENT_VERSION 1 /** 'virtual' version of non-existent object */
118
119 /****************** superblock additional info *********************/
120
121 struct ll_sb_info;
122
123 struct lustre_sb_info {
124         int                    lsi_flags;
125         struct obd_device       *lsi_mgc;     /* mgc obd */
126         struct lustre_mount_data *lsi_lmd;     /* mount command info */
127         struct ll_sb_info       *lsi_llsbi;   /* add'l client sbi info */
128         struct dt_device         *lsi_dt_dev;  /* dt device to access disk fs*/
129         struct vfsmount   *lsi_srv_mnt; /* the one server mount */
130         atomic_t              lsi_mounts;  /* references to the srv_mnt */
131         char                      lsi_svname[MTI_NAME_MAXLEN];
132         char                      lsi_osd_obdname[64];
133         char                      lsi_osd_uuid[64];
134         struct obd_export        *lsi_osd_exp;
135         char                      lsi_osd_type[16];
136         char                      lsi_fstype[16];
137         struct backing_dev_info   lsi_bdi;     /* each client mountpoint needs
138                                                   own backing_dev_info */
139 };
140
141 #define LSI_UMOUNT_FAILOVER           0x00200000
142 #define LSI_BDI_INITIALIZED           0x00400000
143
144 #define     s2lsi(sb)   ((struct lustre_sb_info *)((sb)->s_fs_info))
145 #define     s2lsi_nocast(sb) ((sb)->s_fs_info)
146
147 #define     get_profile_name(sb)   (s2lsi(sb)->lsi_lmd->lmd_profile)
148 #define     get_mount_flags(sb)    (s2lsi(sb)->lsi_lmd->lmd_flags)
149 #define     get_mntdev_name(sb)    (s2lsi(sb)->lsi_lmd->lmd_dev)
150
151 /****************** mount lookup info *********************/
152
153 struct lustre_mount_info {
154         char             *lmi_name;
155         struct super_block   *lmi_sb;
156         struct vfsmount      *lmi_mnt;
157         struct list_head            lmi_list_chain;
158 };
159
160 /****************** prototypes *********************/
161
162 /* obd_mount.c */
163
164 int lustre_start_mgc(struct super_block *sb);
165 void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb,
166                                                   struct vfsmount *mnt));
167 void lustre_register_kill_super_cb(void (*cfs)(struct super_block *sb));
168 int lustre_common_put_super(struct super_block *sb);
169
170 int mgc_fsname2resid(char *fsname, struct ldlm_res_id *res_id, int type);
171
172 /** @} disk */
173
174 #endif /* _LUSTRE_DISK_H */