Whamcloud - gitweb
eeb98e952b660fba589e49750510d001837b157f
[fs/lustre-release.git] / lustre / mgs / mgs_internal.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
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.
11  *
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).
17  *
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
21  *
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
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #ifndef _MGS_INTERNAL_H
38 #define _MGS_INTERNAL_H
39
40 #ifdef __KERNEL__
41 # include <linux/fs.h>
42 #endif
43 #include <libcfs/libcfs.h>
44 #include <lustre/lustre_idl.h>
45 #include <lustre_lib.h>
46 #include <lustre_dlm.h>
47 #include <lustre_log.h>
48 #include <lustre_export.h>
49
50 /* mgs_llog.c */
51 int class_dentry_readdir(struct obd_device *obd, struct dentry *dir,
52                          struct vfsmount *inmnt,
53                          struct list_head *dentry_list);
54
55 struct mgs_tgt_srpc_conf {
56         struct mgs_tgt_srpc_conf  *mtsc_next;
57         char                      *mtsc_tgt;
58         struct sptlrpc_rule_set    mtsc_rset;
59 };
60
61 #define INDEX_MAP_SIZE  8192     /* covers indicies to FFFF */
62 #define FSDB_LOG_EMPTY  0x0001  /* missing client log */
63 #define FSDB_OLDLOG14   0x0002  /* log starts in old (1.4) style */
64
65
66 struct fs_db {
67         char              fsdb_name[9];
68         struct list_head  fsdb_list;           /* list of databases */
69         struct semaphore  fsdb_sem;
70         void             *fsdb_ost_index_map;  /* bitmap of used indicies */
71         void             *fsdb_mdt_index_map;  /* bitmap of used indicies */
72         /* COMPAT_146 these items must be recorded out of the old client log */
73         char             *fsdb_clilov;         /* COMPAT_146 client lov name */
74         char             *fsdb_clilmv;
75         char             *fsdb_mdtlov;         /* COMPAT_146 mds lov name */
76         char             *fsdb_mdtlmv;
77         char             *fsdb_mdc;            /* COMPAT_146 mdc name */
78         /* end COMPAT_146 */
79         __u32             fsdb_flags;
80         __u32             fsdb_gen;
81
82         /* in-memory copy of the srpc rules, guarded by fsdb_sem */
83         struct sptlrpc_rule_set   fsdb_srpc_gen;
84         struct mgs_tgt_srpc_conf *fsdb_srpc_tgt;
85         unsigned int              fsdb_srpc_fl_udesc:1;
86 };
87
88 int mgs_init_fsdb_list(struct obd_device *obd);
89 int mgs_cleanup_fsdb_list(struct obd_device *obd);
90 int mgs_get_fsdb_srpc_from_llog(struct obd_device *obd, struct fs_db *fsdb);
91 int mgs_check_index(struct obd_device *obd, struct mgs_target_info *mti);
92 int mgs_check_failnid(struct obd_device *obd, struct mgs_target_info *mti);
93 int mgs_write_log_target(struct obd_device *obd, struct mgs_target_info *mti);
94 int mgs_upgrade_sv_14(struct obd_device *obd, struct mgs_target_info *mti);
95 int mgs_erase_log(struct obd_device *obd, char *name);
96 int mgs_erase_logs(struct obd_device *obd, char *fsname);
97 int mgs_setparam(struct obd_device *obd, struct lustre_cfg *lcfg, char *fsname);
98
99 int mgs_pool_cmd(struct obd_device *obd, enum lcfg_command_type cmd,
100                  char *poolname, char *fsname, char *ostname);
101
102 /* mgs_fs.c */
103 int mgs_client_add(struct obd_device *obd, struct obd_export *exp,
104                    void *localdata);
105 int mgs_client_free(struct obd_export *exp);
106 int mgs_fs_setup(struct obd_device *obd, struct vfsmount *mnt);
107 int mgs_fs_cleanup(struct obd_device *obddev);
108
109 #define strsuf(buf, suffix) (strcmp((buf)+strlen(buf)-strlen(suffix), (suffix)))
110 #ifdef LPROCFS
111 int lproc_mgs_setup(struct obd_device *dev);
112 int lproc_mgs_cleanup(struct obd_device *obd);
113 int lproc_mgs_add_live(struct obd_device *obd, struct fs_db *fsdb);
114 int lproc_mgs_del_live(struct obd_device *obd, struct fs_db *fsdb);
115 void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars);
116 #else
117 static inline int lproc_mgs_setup(struct obd_device *dev)
118 {return 0;}
119 static inline int lproc_mgs_cleanup(struct obd_device *obd)
120 {return 0;}
121 static inline int lproc_mgs_add_live(struct obd_device *obd, struct fs_db *fsdb)
122 {return 0;}
123 static inline int lproc_mgs_del_live(struct obd_device *obd, struct fs_db *fsdb)
124 {return 0;}
125 static void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars)
126 {
127         memset(lvars, 0, sizeof(*lvars));
128 }
129 #endif
130
131 /* mgs/lproc_mgs.c */
132 enum {
133         LPROC_MGS_CONNECT = 0,
134         LPROC_MGS_DISCONNECT,
135         LPROC_MGS_EXCEPTION,
136         LPROC_MGS_TARGET_REG,
137         LPROC_MGS_TARGET_DEL,
138         LPROC_MGS_LAST
139 };
140 void mgs_counter_incr(struct obd_export *exp, int opcode);
141 void mgs_stats_counter_init(struct lprocfs_stats *stats);
142
143 #endif /* _MGS_INTERNAL_H */