Whamcloud - gitweb
b=13934
[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  *  lustre/osd/osd_internal.h
5  *  Shared definitions and declarations for osd module
6  *
7  *  Copyright (c) 2006 Cluster File Systems, Inc.
8  *   Author: Nikita Danilov <nikita@clusterfs.com>
9  *
10  *   This file is part of the Lustre file system, http://www.lustre.org
11  *   Lustre is a trademark of Cluster File Systems, Inc.
12  *
13  *   You may have signed or agreed to another license before downloading
14  *   this software.  If so, you are bound by the terms and conditions
15  *   of that agreement, and the following does not apply to you.  See the
16  *   LICENSE file included with this distribution for more information.
17  *
18  *   If you did not agree to a different license, then this copy of Lustre
19  *   is open source software; you can redistribute it and/or modify it
20  *   under the terms of version 2 of the GNU General Public License as
21  *   published by the Free Software Foundation.
22  *
23  *   In either case, Lustre is distributed in the hope that it will be
24  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
25  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  *   license text for more details.
27  */
28
29 #ifndef _OSD_INTERNAL_H
30 #define _OSD_INTERNAL_H
31
32 #if defined(__KERNEL__)
33
34 /* struct rw_semaphore */
35 #include <linux/rwsem.h>
36 /* handle_t, journal_start(), journal_stop() */
37 #include <linux/jbd.h>
38 /* struct dx_hash_info */
39 #include <linux/ldiskfs_fs.h>
40 /* struct dentry */
41 #include <linux/dcache.h>
42 #include <linux/lustre_iam.h>
43
44 /* LUSTRE_OSD_NAME */
45 #include <obd.h>
46 /* class_register_type(), class_unregister_type(), class_get_type() */
47 #include <obd_class.h>
48 #include <lustre_disk.h>
49
50 #include <dt_object.h>
51 #include "osd_oi.h"
52
53 struct inode;
54
55 #define OSD_COUNTERS (0)
56
57 /*
58  * osd device.
59  */
60 struct osd_device {
61         /* super-class */
62         struct dt_device          od_dt_dev;
63         /* information about underlying file system */
64         struct lustre_mount_info *od_mount;
65         /* object index */
66         struct osd_oi             od_oi;
67         /*
68          * XXX temporary stuff for object index: directory where every object
69          * is named by its fid.
70          */
71         struct dentry            *od_obj_area;
72
73         /* Environment for transaction commit callback.
74          * Currently, OSD is based on ext3/JBD. Transaction commit in ext3/JBD
75          * is serialized, that is there is no more than one transaction commit
76          * at a time (JBD journal_commit_transaction() is serialized).
77          * This means that it's enough to have _one_ lu_context.
78          */
79         struct lu_env             od_env_for_commit;
80
81         /*
82          * Fid Capability
83          */
84         unsigned int              od_fl_capa:1;
85         unsigned long             od_capa_timeout;
86         __u32                     od_capa_alg;
87         struct lustre_capa_key   *od_capa_keys;
88         struct hlist_head        *od_capa_hash;
89         
90         cfs_proc_dir_entry_t     *od_proc_entry;
91         struct lprocfs_stats     *od_stats;
92         /*
93          * statfs optimization: we cache a bit.
94          */
95         cfs_time_t                od_osfs_age;
96         struct kstatfs            od_kstatfs;
97         spinlock_t                od_osfs_lock;
98 };
99
100
101 struct osd_thread_info {
102         const struct lu_env   *oti_env;
103
104         struct lu_fid          oti_fid;
105         struct osd_inode_id    oti_id;
106         /*
107          * XXX temporary: for ->i_op calls.
108          */
109         struct qstr            oti_str;
110         struct txn_param       oti_txn;
111         /*
112          * XXX temporary: fake dentry used by xattr calls.
113          */
114         struct dentry          oti_dentry;
115         struct timespec        oti_time;
116         /*
117          * XXX temporary: for capa operations.
118          */
119         struct lustre_capa_key oti_capa_key;
120         struct lustre_capa     oti_capa;
121
122         struct lu_fid_pack     oti_pack;
123
124         /* union to guarantee that ->oti_ipd[] has proper alignment. */
125         union {
126         char                   oti_ipd[DX_IPD_MAX_SIZE];
127                 long long      oti_alignment_lieutenant;
128         };
129 #if OSD_COUNTERS
130         int                    oti_r_locks;
131         int                    oti_w_locks;
132         int                    oti_txns;
133 #endif
134 };
135
136 #ifdef LPROCFS
137 /* osd_lproc.c */
138 void lprocfs_osd_init_vars(struct lprocfs_static_vars *lvars);
139 int osd_procfs_init(struct osd_device *osd, const char *name);
140 int osd_procfs_fini(struct osd_device *osd);
141 void osd_lprocfs_time_start(const struct lu_env *env);
142 void osd_lprocfs_time_end(const struct lu_env *env,
143                           struct osd_device *osd, int op);
144 #endif
145 int osd_statfs(const struct lu_env *env, struct dt_device *dev,
146                struct kstatfs *sfs);
147
148 #endif /* __KERNEL__ */
149 #endif /* _OSD_INTERNAL_H */