Whamcloud - gitweb
LU-1303 lod: transfer default striping from parent/fs
[fs/lustre-release.git] / lustre / cmm / mdc_internal.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 /*
31  * This file is part of Lustre, http://www.lustre.org/
32  * Lustre is a trademark of Sun Microsystems, Inc.
33  *
34  * lustre/cmm/mdc_internal.h
35  *
36  * Lustre Cluster Metadata Manager (cmm), MDC device
37  *
38  * Author: Mike Pershin <tappro@clusterfs.com>
39  */
40
41 #ifndef _CMM_MDC_INTERNAL_H
42 #define _CMM_MDC_INTERNAL_H
43
44 #if defined(__KERNEL__)
45
46 #include <lustre_net.h>
47 #include <obd.h>
48 #include <md_object.h>
49 /**
50  * \addtogroup cmm
51  * @{
52  */
53 /**
54  * \defgroup cmm_mdc cmm_mdc
55  *
56  * This is mdc wrapper device to work with old MDC obd-based devices.
57  * @{
58  */
59 /**
60  * MDC client description.
61  */
62 struct mdc_cli_desc {
63         /** uuid of remote MDT to connect */
64         struct obd_uuid          cl_srv_uuid;
65         /** mdc uuid */
66         struct obd_uuid          cl_cli_uuid;
67         /** export of mdc obd */
68         struct obd_export        *cl_exp;
69 };
70
71 /**
72  * MDC device.
73  */
74 struct mdc_device {
75         /** md_device instance for MDC */
76         struct md_device        mc_md_dev;
77         /** other MD servers in cluster */
78         cfs_list_t              mc_linkage;
79         /** number of current device */
80         mdsno_t                 mc_num;
81         /** mdc client description */
82         struct mdc_cli_desc     mc_desc;
83         /** Protects ??*/
84         cfs_semaphore_t         mc_fid_sem;
85 };
86
87 /**
88  * mdc thread info. Local storage for varios data.
89  */
90 struct mdc_thread_info {
91         /** Storage for md_op_data */
92         struct md_op_data       mci_opdata;
93         /** Storage for ptlrpc request */
94         struct ptlrpc_request  *mci_req;
95 };
96
97 /** mdc object. */
98 struct mdc_object {
99         /** md_object instance for mdc_object */
100         struct md_object        mco_obj;
101 };
102
103 /** Get lu_device from mdc_device. */
104 static inline struct lu_device *mdc2lu_dev(struct mdc_device *mc)
105 {
106         return (&mc->mc_md_dev.md_lu_dev);
107 }
108
109 /** Get mdc_device from md_device. */
110 static inline struct mdc_device *md2mdc_dev(struct md_device *md)
111 {
112         return container_of0(md, struct mdc_device, mc_md_dev);
113 }
114
115 /** Get mdc_device from mdc_object. */
116 static inline struct mdc_device *mdc_obj2dev(struct mdc_object *mco)
117 {
118         return (md2mdc_dev(md_obj2dev(&mco->mco_obj)));
119 }
120
121 /** Get mdc_object from lu_object. */
122 static inline struct mdc_object *lu2mdc_obj(struct lu_object *lo)
123 {
124         return container_of0(lo, struct mdc_object, mco_obj.mo_lu);
125 }
126
127 /** Get mdc_object from md_object. */
128 static inline struct mdc_object *md2mdc_obj(struct md_object *mo)
129 {
130         return container_of0(mo, struct mdc_object, mco_obj);
131 }
132
133 /** Get mdc_device from lu_device. */
134 static inline struct mdc_device *lu2mdc_dev(struct lu_device *ld)
135 {
136         return container_of0(ld, struct mdc_device, mc_md_dev.md_lu_dev);
137 }
138
139 struct lu_object *mdc_object_alloc(const struct lu_env *,
140                                    const struct lu_object_header *,
141                                    struct lu_device *);
142
143 void cmm_mdc_init_ea_size(const struct lu_env *env, struct mdc_device *mc,
144                       int max_mdsize, int max_cookiesize);
145 #ifdef HAVE_SPLIT_SUPPORT
146 int mdc_send_page(struct cmm_device *cmm, const struct lu_env *env,
147                   struct md_object *mo, struct page *page, __u32 end);
148 #endif
149 /** @} */
150 /** @} */
151 #endif /* __KERNEL__ */
152 #endif /* _CMM_MDC_INTERNAL_H */