Whamcloud - gitweb
Branch b1_4_mountconf
[fs/lustre-release.git] / lustre / obdfilter / filter_internal.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  */
4
5 #ifndef _FILTER_INTERNAL_H
6 #define _FILTER_INTERNAL_H
7
8 #ifdef __KERNEL__
9 # include <linux/spinlock.h>
10 #endif
11 #include <linux/lustre_handles.h>
12 #include <linux/lustre_debug.h>
13 #include <linux/obd.h>
14 #include <linux/lustre_disk.h>
15
16 #define FILTER_LAYOUT_VERSION "2"
17
18 #define HEALTH_CHECK "health_check"
19 #define FILTER_INIT_OBJID 0
20
21 #define FILTER_SUBDIR_COUNT      32            /* set to zero for no subdirs */
22 #define FILTER_GROUPS 3 /* must be at least 3; not dynamic yet */
23
24 #define FILTER_ROCOMPAT_SUPP (0)
25
26 #define FILTER_RECOVERY_TIMEOUT (obd_timeout * 5 * HZ / 2) /* *waves hands* */
27
28 #define FILTER_INCOMPAT_SUPP (OBD_INCOMPAT_GROUPS | OBD_INCOMPAT_OST | \
29                               OBD_INCOMPAT_COMMON_LR)
30
31 #define FILTER_GRANT_CHUNK (2ULL * PTLRPC_MAX_BRW_SIZE)
32 #define GRANT_FOR_LLOG(obd) 16
33
34 /* Data stored per client in the last_rcvd file.  In le32 order. */
35 struct filter_client_data {
36         __u8  fcd_uuid[40];        /* client UUID */
37         __u64 fcd_last_rcvd;       /* last completed transaction ID */
38         __u64 fcd_last_xid;        /* client RPC xid for the last transaction */
39         __u8  fcd_padding[LR_CLIENT_SIZE - 56];
40 };
41
42 #define FILTER_DENTRY_MAGIC 0x9efba101
43 #define FILTER_FLAG_DESTROY 0x0001      /* destroy dentry on last file close */
44
45 /* Limit the returned fields marked valid to those that we actually might set */
46 #define FILTER_VALID_FLAGS (OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLGENER  |\
47                             OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ|\
48                             OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME)
49
50 struct filter_fid {
51         struct ll_fid   ff_fid;
52         __u64           ff_objid;
53         __u64           ff_group;
54 };
55
56 enum {
57         LPROC_FILTER_READ_BYTES = 0,
58         LPROC_FILTER_WRITE_BYTES = 1,
59         LPROC_FILTER_LAST,
60 };
61
62 //#define FILTER_MAX_CACHE_SIZE (32 * 1024 * 1024) /* was OBD_OBJECT_EOF */
63 #define FILTER_MAX_CACHE_SIZE OBD_OBJECT_EOF
64
65 /* We have to pass a 'created' array to fsfilt_map_inode_pages() which we
66  * then ignore.  So we pre-allocate one that everyone can use... */
67 #define OBDFILTER_CREATED_SCRATCHPAD_ENTRIES 1024
68 extern int *obdfilter_created_scratchpad;
69
70 /* filter.c */
71 void f_dput(struct dentry *);
72 struct dentry *filter_fid2dentry(struct obd_device *, struct dentry *dir,
73                                  obd_gr group, obd_id id);
74 struct dentry *__filter_oa2dentry(struct obd_device *obd, struct obdo *oa,
75                                   const char *what, int quiet);
76 #define filter_oa2dentry(obd, oa) __filter_oa2dentry(obd, oa, __FUNCTION__, 0)
77
78 int filter_finish_transno(struct obd_export *, struct obd_trans_info *, int rc);
79 __u64 filter_next_id(struct filter_obd *, struct obdo *);
80 __u64 filter_last_id(struct filter_obd *, struct obdo *);
81 int filter_update_fidea(struct obd_export *exp, struct inode *inode,
82                         void *handle, struct obdo *oa);
83 int filter_update_server_data(struct obd_device *, struct file *,
84                               struct lr_server_data *, int force_sync);
85 int filter_update_last_objid(struct obd_device *, obd_gr, int force_sync);
86 int filter_common_setup(struct obd_device *, obd_count len, void *buf,
87                         void *option);
88 int filter_destroy(struct obd_export *exp, struct obdo *oa,
89                    struct lov_stripe_md *md, struct obd_trans_info *,
90                    struct obd_export *);
91 int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
92                             struct obdo *oa, struct obd_trans_info *oti);
93 int filter_setattr(struct obd_export *exp, struct obdo *oa,
94                    struct lov_stripe_md *md, struct obd_trans_info *oti);
95
96 struct dentry *filter_create_object(struct obd_device *obd, struct obdo *oa);
97
98 /* filter_lvb.c */
99 extern struct ldlm_valblock_ops filter_lvbo;
100
101
102 /* filter_io.c */
103 int filter_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
104                   struct obd_ioobj *, int niocount, struct niobuf_remote *,
105                   struct niobuf_local *, struct obd_trans_info *);
106 int filter_commitrw(int cmd, struct obd_export *, struct obdo *, int objcount,
107                     struct obd_ioobj *, int niocount, struct niobuf_local *,
108                     struct obd_trans_info *, int rc);
109 int filter_brw(int cmd, struct obd_export *, struct obdo *,
110                struct lov_stripe_md *, obd_count oa_bufs, struct brw_page *,
111                struct obd_trans_info *);
112 void flip_into_page_cache(struct inode *inode, struct page *new_page);
113
114 /* filter_io_*.c */
115 struct filter_iobuf;
116 int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount,
117                           struct obd_ioobj *obj, int niocount,
118                           struct niobuf_local *res, struct obd_trans_info *oti,
119                           int rc);
120 obd_size filter_grant_space_left(struct obd_export *exp);
121 long filter_grant(struct obd_export *exp, obd_size current_grant,
122                   obd_size want, obd_size fs_space_left);
123 void filter_grant_commit(struct obd_export *exp, int niocount,
124                          struct niobuf_local *res);
125 struct filter_iobuf *filter_alloc_iobuf(struct filter_obd *, int rw,
126                                         int num_pages);
127 void filter_free_iobuf(struct filter_iobuf *iobuf);
128 int filter_iobuf_add_page(struct obd_device *obd, struct filter_iobuf *iobuf,
129                           struct inode *inode, struct page *page);
130 void *filter_iobuf_get(struct filter_obd *filter, struct obd_trans_info *oti);
131 void filter_iobuf_put(struct filter_obd *filter, struct filter_iobuf *iobuf,
132                       struct obd_trans_info *oti);
133 int filter_direct_io(int rw, struct dentry *dchild, struct filter_iobuf *iobuf,
134                      struct obd_export *exp, struct iattr *attr,
135                      struct obd_trans_info *oti, void **wait_handle);
136
137 /* filter_log.c */
138 struct ost_filterdata {
139         __u32  ofd_epoch;
140 };
141 int filter_log_sz_change(struct llog_handle *cathandle,
142                          struct ll_fid *mds_fid,
143                          __u32 io_epoch,
144                          struct llog_cookie *logcookie,
145                          struct inode *inode);
146 //int filter_get_catalog(struct obd_device *);
147 void filter_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
148                               void *cb_data, int error);
149 int filter_recov_log_mds_ost_cb(struct llog_handle *llh,
150                                struct llog_rec_hdr *rec, void *data);
151
152 /* filter_san.c */
153 int filter_san_setup(struct obd_device *obd, obd_count len, void *buf);
154 int filter_san_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
155                       struct obd_ioobj *, int niocount, struct niobuf_remote *);
156
157 #ifdef LPROCFS
158 void filter_tally_write(struct filter_obd *filter, struct page **pages,
159                         int nr_pages, unsigned long *blocks,
160                         int blocks_per_page);
161 void filter_tally_read(struct filter_obd *filter, struct niobuf_local *lnb,
162                        int niocount);
163 int lproc_filter_attach_seqstat(struct obd_device *dev);
164 #else
165 static inline void filter_tally_write(struct filter_obd *filter,
166                                  struct page **pages, int nr_pages,
167                                  unsigned long *blocks, int blocks_per_page) {}
168 static inline void filter_tally_read(struct filter_obd *filter,
169                                      struct niobuf_local *lnb, int niocount) {}
170 static inline int lproc_filter_attach_seqstat(struct obd_device *dev) {}
171 #endif
172
173 /* Quota stuff */
174 extern quota_interface_t *quota_interface;
175
176 #endif /* _FILTER_INTERNAL_H */