Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / cmm / mdc_internal.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  lustre/cmm/cmm_internal.h
5  *  Lustre Cluster Metadata Manager (cmm),
6  *  MDC device
7  *
8  *  Copyright (C) 2006 Cluster File Systems, Inc.
9  *   Author: Mike Pershin <tappro@clusterfs.com>
10  *
11  *   This file is part of the Lustre file system, http://www.lustre.org
12  *   Lustre is a trademark of Cluster File Systems, Inc.
13  *
14  *   You may have signed or agreed to another license before downloading
15  *   this software.  If so, you are bound by the terms and conditions
16  *   of that agreement, and the following does not apply to you.  See the
17  *   LICENSE file included with this distribution for more information.
18  *
19  *   If you did not agree to a different license, then this copy of Lustre
20  *   is open source software; you can redistribute it and/or modify it
21  *   under the terms of version 2 of the GNU General Public License as
22  *   published by the Free Software Foundation.
23  *
24  *   In either case, Lustre is distributed in the hope that it will be
25  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
26  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  *   license text for more details.
28  */
29
30 #ifndef _CMM_MDC_INTERNAL_H
31 #define _CMM_MDC_INTERNAL_H
32
33 #if defined(__KERNEL__)
34
35 #include <lustre_net.h>
36 #include <obd.h>
37 #include <md_object.h>
38
39 struct mdc_cli_desc {
40         struct lustre_handle     cl_conn;
41         /* uuid of remote MDT to connect */
42         struct obd_uuid          cl_srv_uuid;
43         /* mdc uuid */
44         struct obd_uuid          cl_cli_uuid;
45         /* export of mdc obd */
46         struct obd_export        *cl_exp;
47 };
48
49 struct mdc_device {
50         struct md_device        mc_md_dev;
51         /* other MD servers in cluster */
52         struct list_head        mc_linkage;
53         mdsno_t                 mc_num;
54         struct mdc_cli_desc     mc_desc;
55         struct semaphore        mc_fid_sem;
56 };
57
58 struct mdc_thread_info {
59         struct md_op_data       mci_opdata;
60         struct ptlrpc_request  *mci_req;
61 };
62
63 struct mdc_object {
64         struct md_object        mco_obj;
65 };
66
67 static inline struct lu_device *mdc2lu_dev(struct mdc_device *mc)
68 {
69         return (&mc->mc_md_dev.md_lu_dev);
70 }
71
72 static inline struct mdc_device *md2mdc_dev(struct md_device *md)
73 {
74         return container_of0(md, struct mdc_device, mc_md_dev);
75 }
76
77 static inline struct mdc_device *mdc_obj2dev(struct mdc_object *mco)
78 {
79         return (md2mdc_dev(md_obj2dev(&mco->mco_obj)));
80 }
81
82 static inline struct mdc_object *lu2mdc_obj(struct lu_object *lo)
83 {
84         return container_of0(lo, struct mdc_object, mco_obj.mo_lu);
85 }
86
87 static inline struct mdc_object *md2mdc_obj(struct md_object *mo)
88 {
89         return container_of0(mo, struct mdc_object, mco_obj);
90 }
91
92 static inline struct mdc_device *lu2mdc_dev(struct lu_device *ld)
93 {
94         return container_of0(ld, struct mdc_device, mc_md_dev.md_lu_dev);
95 }
96
97 struct lu_object *mdc_object_alloc(const struct lu_env *,
98                                    const struct lu_object_header *,
99                                    struct lu_device *);
100
101 void mdc_init_ea_size(const struct lu_env *env, struct mdc_device *mc, 
102                       int max_mdsize, int max_cookiesize);
103 #ifdef HAVE_SPLIT_SUPPORT
104 int mdc_send_page(struct cmm_device *cmm, const struct lu_env *env,
105                   struct md_object *mo, struct page *page, __u32 end);
106 #endif
107
108 #endif /* __KERNEL__ */
109 #endif /* _CMM_MDC_INTERNAL_H */