Whamcloud - gitweb
Make previously optional ->oti_{w,r}_locks sanity checks mandatory to simplify
[fs/lustre-release.git] / lustre / osd / osd_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  * lustre/osd/osd_internal.h
37  *
38  * Shared definitions and declarations for osd module
39  *
40  * Author: Nikita Danilov <nikita@clusterfs.com>
41  */
42
43 #ifndef _OSD_INTERNAL_H
44 #define _OSD_INTERNAL_H
45
46 #if defined(__KERNEL__)
47
48 /* struct rw_semaphore */
49 #include <linux/rwsem.h>
50 /* handle_t, journal_start(), journal_stop() */
51 #include <linux/jbd.h>
52 /* struct dx_hash_info */
53 #include <linux/ldiskfs_fs.h>
54 /* struct dentry */
55 #include <linux/dcache.h>
56 #include <linux/lustre_iam.h>
57
58 /* LUSTRE_OSD_NAME */
59 #include <obd.h>
60 /* class_register_type(), class_unregister_type(), class_get_type() */
61 #include <obd_class.h>
62 #include <lustre_disk.h>
63
64 #include <dt_object.h>
65 #include "osd_oi.h"
66
67 struct inode;
68
69 /*
70  * osd device.
71  */
72 struct osd_device {
73         /* super-class */
74         struct dt_device          od_dt_dev;
75         /* information about underlying file system */
76         struct lustre_mount_info *od_mount;
77         /* object index */
78         struct osd_oi             od_oi;
79         /*
80          * XXX temporary stuff for object index: directory where every object
81          * is named by its fid.
82          */
83         struct dentry            *od_obj_area;
84
85         /* Environment for transaction commit callback.
86          * Currently, OSD is based on ext3/JBD. Transaction commit in ext3/JBD
87          * is serialized, that is there is no more than one transaction commit
88          * at a time (JBD journal_commit_transaction() is serialized).
89          * This means that it's enough to have _one_ lu_context.
90          */
91         struct lu_env             od_env_for_commit;
92
93         /*
94          * Fid Capability
95          */
96         unsigned int              od_fl_capa:1;
97         unsigned long             od_capa_timeout;
98         __u32                     od_capa_alg;
99         struct lustre_capa_key   *od_capa_keys;
100         struct hlist_head        *od_capa_hash;
101         
102         cfs_proc_dir_entry_t     *od_proc_entry;
103         struct lprocfs_stats     *od_stats;
104         /*
105          * statfs optimization: we cache a bit.
106          */
107         cfs_time_t                od_osfs_age;
108         struct kstatfs            od_kstatfs;
109         spinlock_t                od_osfs_lock;
110 };
111
112
113 struct osd_thread_info {
114         const struct lu_env   *oti_env;
115
116         struct lu_fid          oti_fid;
117         struct osd_inode_id    oti_id;
118         /*
119          * XXX temporary: for ->i_op calls.
120          */
121         struct qstr            oti_str;
122         struct txn_param       oti_txn;
123         /*
124          * XXX temporary: fake dentry used by xattr calls.
125          */
126         struct dentry          oti_dentry;
127         struct timespec        oti_time;
128         /*
129          * XXX temporary: fake struct file for osd_object_sync
130          */
131         struct file            oti_file;
132         /*
133          * XXX temporary: for capa operations.
134          */
135         struct lustre_capa_key oti_capa_key;
136         struct lustre_capa     oti_capa;
137
138         struct lu_fid_pack     oti_pack;
139
140         /* union to guarantee that ->oti_ipd[] has proper alignment. */
141         union {
142         char                   oti_ipd[DX_IPD_MAX_SIZE];
143                 long long      oti_alignment_lieutenant;
144         };
145         int                    oti_r_locks;
146         int                    oti_w_locks;
147         int                    oti_txns;
148 };
149
150 #ifdef LPROCFS
151 /* osd_lproc.c */
152 void lprocfs_osd_init_vars(struct lprocfs_static_vars *lvars);
153 int osd_procfs_init(struct osd_device *osd, const char *name);
154 int osd_procfs_fini(struct osd_device *osd);
155 void osd_lprocfs_time_start(const struct lu_env *env);
156 void osd_lprocfs_time_end(const struct lu_env *env,
157                           struct osd_device *osd, int op);
158 #endif
159 int osd_statfs(const struct lu_env *env, struct dt_device *dev,
160                struct kstatfs *sfs);
161
162 #endif /* __KERNEL__ */
163 #endif /* _OSD_INTERNAL_H */