1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/include/lustre_disk.h
38 * Lustre disk format definitions.
40 * Author: Nathan Rutman <nathan@clusterfs.com>
43 #ifndef _LUSTRE_DISK_H
44 #define _LUSTRE_DISK_H
46 #include <libcfs/libcfs.h>
47 #include <lnet/types.h>
49 /****************** on-disk files *********************/
51 #define MDT_LOGS_DIR "LOGS" /* COMPAT_146 */
52 #define MOUNT_CONFIGS_DIR "CONFIGS"
53 #define CONFIGS_FILE "mountdata"
54 /** Persistent mount data are stored on the disk in this file. */
55 #define MOUNT_DATA_FILE MOUNT_CONFIGS_DIR"/"CONFIGS_FILE
56 #define LAST_RCVD "last_rcvd"
57 #define LOV_OBJID "lov_objid"
58 #define HEALTH_CHECK "health_check"
59 #define CAPA_KEYS "capa_keys"
61 /****************** persistent mount data *********************/
63 #define LDD_F_SV_TYPE_MDT 0x0001
64 #define LDD_F_SV_TYPE_OST 0x0002
65 #define LDD_F_SV_TYPE_MGS 0x0004
66 /** need an index assignment */
67 #define LDD_F_NEED_INDEX 0x0010
68 /** never registered */
69 #define LDD_F_VIRGIN 0x0020
70 /** update the config logs for this server*/
71 #define LDD_F_UPDATE 0x0040
72 /** rewrite the LDD */
73 #define LDD_F_REWRITE_LDD 0x0080
74 /** regenerate all logs for this fs */
75 #define LDD_F_WRITECONF 0x0100
77 #define LDD_F_UPGRADE14 0x0200
78 /** process as lctl conf_param */
79 #define LDD_F_PARAM 0x0400
80 /** backend fs make use of IAM directory format. */
81 #define LDD_F_IAM_DIR 0x0800
92 static inline char *mt_str(enum ldd_mount_type mt)
94 static char *mount_type_string[] = {
101 return mount_type_string[mt];
104 #define LDD_INCOMPAT_SUPP 0
105 #define LDD_ROCOMPAT_SUPP 0
107 #define LDD_MAGIC 0x1dd00001
109 /* On-disk configuration file. In host-endian order. */
110 struct lustre_disk_data {
112 __u32 ldd_feature_compat; /* compatible feature flags */
113 __u32 ldd_feature_rocompat;/* read-only compatible feature flags */
114 __u32 ldd_feature_incompat;/* incompatible feature flags */
116 __u32 ldd_config_ver; /* config rewrite count - not used */
117 __u32 ldd_flags; /* LDD_SV_TYPE */
118 __u32 ldd_svindex; /* server index (0001), must match
120 __u32 ldd_mount_type; /* target fs type LDD_MT_* */
121 char ldd_fsname[64]; /* filesystem this server is part of */
122 char ldd_svname[64]; /* this server's name (lustre-mdt0001)*/
123 __u8 ldd_uuid[40]; /* server UUID (COMPAT_146) */
125 /*200*/ char ldd_userdata[1024 - 200]; /* arbitrary user string */
126 /*1024*/__u8 ldd_padding[4096 - 1024];
127 /*4096*/char ldd_mount_opts[4096]; /* target fs mount opts */
128 /*8192*/char ldd_params[4096]; /* key=value pairs */
131 #define IS_MDT(data) ((data)->ldd_flags & LDD_F_SV_TYPE_MDT)
132 #define IS_OST(data) ((data)->ldd_flags & LDD_F_SV_TYPE_OST)
133 #define IS_MGS(data) ((data)->ldd_flags & LDD_F_SV_TYPE_MGS)
134 #define MT_STR(data) mt_str((data)->ldd_mount_type)
136 /* Make the mdt/ost server obd name based on the filesystem name */
137 static inline int server_make_name(__u32 flags, __u16 index, char *fs,
140 if (flags & (LDD_F_SV_TYPE_MDT | LDD_F_SV_TYPE_OST)) {
141 sprintf(name, "%.8s-%s%04x", fs,
142 (flags & LDD_F_SV_TYPE_MDT) ? "MDT" : "OST",
144 } else if (flags & LDD_F_SV_TYPE_MGS) {
145 sprintf(name, "MGS");
147 CERROR("unknown server type %#x\n", flags);
153 /* Get the index from the obd name */
154 int server_name2index(char *svname, __u32 *idx, char **endptr);
157 /****************** mount command *********************/
159 /* The lmd is only used internally by Lustre; mount simply passes
160 everything as string options */
162 #define LMD_MAGIC 0xbdacbd03
164 /* gleaned from the mount command - no persistent info here */
165 struct lustre_mount_data {
167 __u32 lmd_flags; /* lustre mount flags */
168 int lmd_mgs_failnodes; /* mgs failover node count */
169 int lmd_exclude_count;
170 char *lmd_dev; /* device name */
171 char *lmd_profile; /* client only */
172 char *lmd_opts; /* lustre mount options (as opposed to
173 _device_ mount options) */
174 __u32 *lmd_exclude; /* array of OSTs to ignore */
177 #define LMD_FLG_SERVER 0x0001 /* Mounting a server */
178 #define LMD_FLG_CLIENT 0x0002 /* Mounting a client */
179 #define LMD_FLG_ABORT_RECOV 0x0008 /* Abort recovery */
180 #define LMD_FLG_NOSVC 0x0010 /* Only start MGS/MGC for servers,
182 #define LMD_FLG_NOMGS 0x0020 /* Only start target for servers, reusing
183 existing MGS services */
185 #define lmd_is_client(x) ((x)->lmd_flags & LMD_FLG_CLIENT)
188 /****************** last_rcvd file *********************/
190 #define LR_SERVER_SIZE 512
191 #define LR_CLIENT_START 8192
192 #define LR_CLIENT_SIZE 128
193 #if LR_CLIENT_START < LR_SERVER_SIZE
194 #error "Can't have LR_CLIENT_START < LR_SERVER_SIZE"
198 * This limit is arbitrary (131072 clients on x86), but it is convenient to use
199 * 2^n * CFS_PAGE_SIZE * 8 for the number of bits that fit an order-n allocation.
200 * If we need more than 131072 clients (order-2 allocation on x86) then this
201 * should become an array of single-page pointers that are allocated on demand.
203 #if (128 * 1024UL) > (CFS_PAGE_SIZE * 8)
204 #define LR_MAX_CLIENTS (128 * 1024UL)
206 #define LR_MAX_CLIENTS (CFS_PAGE_SIZE * 8)
209 /** COMPAT_146: this is an OST (temporary) */
210 #define OBD_COMPAT_OST 0x00000002
211 /** COMPAT_146: this is an MDT (temporary) */
212 #define OBD_COMPAT_MDT 0x00000004
214 /** MDS handles LOV_OBJID file */
215 #define OBD_ROCOMPAT_LOVOBJID 0x00000001
217 /** OST handles group subdirs */
218 #define OBD_INCOMPAT_GROUPS 0x00000001
219 /** this is an OST */
220 #define OBD_INCOMPAT_OST 0x00000002
221 /** this is an MDT */
222 #define OBD_INCOMPAT_MDT 0x00000004
223 /** common last_rvcd format */
224 #define OBD_INCOMPAT_COMMON_LR 0x00000008
225 /** FID is enabled */
226 #define OBD_INCOMPAT_FID 0x00000010
228 * lustre disk using iam format to store directory entries
230 #define OBD_INCOMPAT_IAM_DIR 0x00000020
233 /* Data stored per server at the head of the last_rcvd file. In le32 order.
234 This should be common to filter_internal.h, lustre_mds.h */
235 struct lr_server_data {
236 __u8 lsd_uuid[40]; /* server UUID */
237 __u64 lsd_last_transno; /* last completed transaction ID */
238 __u64 lsd_compat14; /* reserved - compat with old last_rcvd */
239 __u64 lsd_mount_count; /* incarnation number */
240 __u32 lsd_feature_compat; /* compatible feature flags */
241 __u32 lsd_feature_rocompat;/* read-only compatible feature flags */
242 __u32 lsd_feature_incompat;/* incompatible feature flags */
243 __u32 lsd_server_size; /* size of server data area */
244 __u32 lsd_client_start; /* start of per-client data area */
245 __u16 lsd_client_size; /* size of per-client data area */
246 __u16 lsd_subdir_count; /* number of subdirectories for objects */
247 __u64 lsd_catalog_oid; /* recovery catalog object id */
248 __u32 lsd_catalog_ogen; /* recovery catalog inode generation */
249 __u8 lsd_peeruuid[40]; /* UUID of MDS associated with this OST */
250 __u32 lsd_ost_index; /* index number of OST in LOV */
251 __u32 lsd_mdt_index; /* index number of MDT in LMV */
252 __u8 lsd_padding[LR_SERVER_SIZE - 148];
255 /* Data stored per client in the last_rcvd file. In le32 order. */
256 struct lsd_client_data {
257 __u8 lcd_uuid[40]; /* client UUID */
258 __u64 lcd_last_transno; /* last completed transaction ID */
259 __u64 lcd_last_xid; /* xid for the last transaction */
260 __u32 lcd_last_result; /* result from last RPC */
261 __u32 lcd_last_data; /* per-op data (disposition for open &c.) */
262 /* for MDS_CLOSE requests */
263 __u64 lcd_last_close_transno; /* last completed transaction ID */
264 __u64 lcd_last_close_xid; /* xid for the last transaction */
265 __u32 lcd_last_close_result; /* result from last RPC */
266 __u32 lcd_last_close_data; /* per-op data */
267 __u8 lcd_padding[LR_CLIENT_SIZE - 88];
272 /****************** superblock additional info *********************/
275 struct lustre_sb_info {
277 struct obd_device *lsi_mgc; /* mgc obd */
278 struct lustre_mount_data *lsi_lmd; /* mount command info */
279 struct lustre_disk_data *lsi_ldd; /* mount info on-disk */
280 struct ll_sb_info *lsi_llsbi; /* add'l client sbi info */
281 struct vfsmount *lsi_srv_mnt; /* the one server mount */
282 atomic_t lsi_mounts; /* references to the srv_mnt */
285 #define LSI_SERVER 0x00000001
286 #define LSI_UMOUNT_FORCE 0x00000010
287 #define LSI_UMOUNT_FAILOVER 0x00000020
289 #define s2lsi(sb) ((struct lustre_sb_info *)((sb)->s_fs_info))
290 #define s2lsi_nocast(sb) ((sb)->s_fs_info)
292 #define get_profile_name(sb) (s2lsi(sb)->lsi_lmd->lmd_profile)
294 #endif /* __KERNEL__ */
296 /****************** mount lookup info *********************/
298 struct lustre_mount_info {
300 struct super_block *lmi_sb;
301 struct vfsmount *lmi_mnt;
302 struct list_head lmi_list_chain;
305 /****************** prototypes *********************/
308 #include <obd_class.h>
311 void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb));
312 void lustre_register_kill_super_cb(void (*cfs)(struct super_block *sb));
315 int lustre_common_put_super(struct super_block *sb);
316 int lustre_process_log(struct super_block *sb, char *logname,
317 struct config_llog_instance *cfg);
318 int lustre_end_log(struct super_block *sb, char *logname,
319 struct config_llog_instance *cfg);
320 struct lustre_mount_info *server_get_mount(const char *name);
321 struct lustre_mount_info *server_get_mount_2(const char *name);
322 int server_put_mount(const char *name, struct vfsmount *mnt);
323 int server_put_mount_2(const char *name, struct vfsmount *mnt);
324 int server_register_target(struct super_block *sb);
325 struct mgs_target_info;
326 int server_mti_print(char *title, struct mgs_target_info *mti);
329 int mgc_fsname2resid(char *fsname, struct ldlm_res_id *res_id);
333 #endif // _LUSTRE_DISK_H