1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 #ifndef _FILTER_INTERNAL_H
6 #define _FILTER_INTERNAL_H
9 # include <linux/spinlock.h>
11 #include <lustre_disk.h>
12 #include <lustre_handles.h>
13 #include <lustre_debug.h>
15 #include <lprocfs_status.h>
17 #define FILTER_LAYOUT_VERSION "2"
19 #define FILTER_INIT_OBJID 0
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 */
24 #define FILTER_ROCOMPAT_SUPP (0)
26 #define FILTER_INCOMPAT_SUPP (OBD_INCOMPAT_GROUPS | OBD_INCOMPAT_OST | \
27 OBD_INCOMPAT_COMMON_LR)
29 #define FILTER_GRANT_CHUNK (2ULL * PTLRPC_MAX_BRW_SIZE)
30 #define GRANT_FOR_LLOG(obd) 16
32 #define FILTER_RECOVERY_TIMEOUT (obd_timeout * 5 * HZ / 2) /* *waves hands* */
34 extern struct file_operations filter_per_export_stats_fops;
36 /* Data stored per client in the last_rcvd file. In le32 order. */
37 struct filter_client_data {
38 __u8 fcd_uuid[40]; /* client UUID */
39 __u64 fcd_last_rcvd; /* last completed transaction ID */
40 __u64 fcd_last_xid; /* client RPC xid for the last transaction */
41 __u8 fcd_padding[LR_CLIENT_SIZE - 56];
44 /* Limit the returned fields marked valid to those that we actually might set */
45 #define FILTER_VALID_FLAGS (OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLGENER |\
46 OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ|\
47 OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME)
50 struct ll_fid ff_fid; /* ff_fid.f_type == file stripe number */
55 /* per-client-per-object persistent state (LRU) */
56 struct filter_mod_data {
57 struct list_head fmd_list; /* linked to fed_mod_list */
58 __u64 fmd_id; /* object being written to */
59 __u64 fmd_gr; /* group being written to */
60 __u64 fmd_mactime_xid;/* xid highest {m,a,c}time setattr */
61 unsigned long fmd_expire; /* jiffies when it should expire */
62 int fmd_refcount; /* reference counter - list holds 1 */
66 #define FILTER_FMD_MAX_NUM_DEFAULT 128 /* many active files per client on BGL */
68 #define FILTER_FMD_MAX_NUM_DEFAULT 32
70 #define FILTER_FMD_MAX_AGE_DEFAULT ((obd_timeout + 10) * HZ)
72 struct filter_mod_data *filter_fmd_find(struct obd_export *exp,
73 obd_id objid, obd_gr group);
74 struct filter_mod_data *filter_fmd_get(struct obd_export *exp,
75 obd_id objid, obd_gr group);
76 void filter_fmd_put(struct obd_export *exp, struct filter_mod_data *fmd);
77 void filter_fmd_expire(struct obd_export *exp);
80 LPROC_FILTER_READ_BYTES = 0,
81 LPROC_FILTER_WRITE_BYTES = 1,
85 //#define FILTER_MAX_CACHE_SIZE (32 * 1024 * 1024) /* was OBD_OBJECT_EOF */
86 #define FILTER_MAX_CACHE_SIZE OBD_OBJECT_EOF
88 /* We have to pass a 'created' array to fsfilt_map_inode_pages() which we
89 * then ignore. So we pre-allocate one that everyone can use... */
90 #define OBDFILTER_CREATED_SCRATCHPAD_ENTRIES 1024
91 extern int *obdfilter_created_scratchpad;
94 void f_dput(struct dentry *);
95 struct dentry *filter_fid2dentry(struct obd_device *, struct dentry *dir,
96 obd_gr group, obd_id id);
97 struct dentry *__filter_oa2dentry(struct obd_device *obd, struct obdo *oa,
98 const char *what, int quiet);
99 #define filter_oa2dentry(obd, oa) __filter_oa2dentry(obd, oa, __FUNCTION__, 0)
101 int filter_finish_transno(struct obd_export *, struct obd_trans_info *, int rc);
102 __u64 filter_next_id(struct filter_obd *, struct obdo *);
103 __u64 filter_last_id(struct filter_obd *, obd_gr group);
104 int filter_update_fidea(struct obd_export *exp, struct inode *inode,
105 void *handle, struct obdo *oa);
106 int filter_update_server_data(struct obd_device *, struct file *,
107 struct lr_server_data *, int force_sync);
108 int filter_update_last_objid(struct obd_device *, obd_gr, int force_sync);
109 int filter_common_setup(struct obd_device *, obd_count len, void *buf,
111 int filter_destroy(struct obd_export *exp, struct obdo *oa,
112 struct lov_stripe_md *md, struct obd_trans_info *,
113 struct obd_export *);
114 int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
115 struct obdo *oa, struct obd_trans_info *oti);
116 int filter_setattr(struct obd_export *exp, struct obd_info *oinfo,
117 struct obd_trans_info *oti);
119 struct dentry *filter_create_object(struct obd_device *obd, struct obdo *oa);
122 extern struct ldlm_valblock_ops filter_lvbo;
126 int filter_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
127 struct obd_ioobj *, int niocount, struct niobuf_remote *,
128 struct niobuf_local *, struct obd_trans_info *);
129 int filter_commitrw(int cmd, struct obd_export *, struct obdo *, int objcount,
130 struct obd_ioobj *, int niocount, struct niobuf_local *,
131 struct obd_trans_info *, int rc);
132 int filter_brw(int cmd, struct obd_export *, struct obd_info *oinfo,
133 obd_count oa_bufs, struct brw_page *pga, struct obd_trans_info *);
134 void flip_into_page_cache(struct inode *inode, struct page *new_page);
138 int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount,
139 struct obd_ioobj *obj, int niocount,
140 struct niobuf_local *res, struct obd_trans_info *oti,
142 obd_size filter_grant_space_left(struct obd_export *exp);
143 long filter_grant(struct obd_export *exp, obd_size current_grant,
144 obd_size want, obd_size fs_space_left);
145 void filter_grant_commit(struct obd_export *exp, int niocount,
146 struct niobuf_local *res);
147 struct filter_iobuf *filter_alloc_iobuf(struct filter_obd *, int rw,
149 void filter_free_iobuf(struct filter_iobuf *iobuf);
150 int filter_iobuf_add_page(struct obd_device *obd, struct filter_iobuf *iobuf,
151 struct inode *inode, struct page *page);
152 void *filter_iobuf_get(struct filter_obd *filter, struct obd_trans_info *oti);
153 void filter_iobuf_put(struct filter_obd *filter, struct filter_iobuf *iobuf,
154 struct obd_trans_info *oti);
155 int filter_direct_io(int rw, struct dentry *dchild, struct filter_iobuf *iobuf,
156 struct obd_export *exp, struct iattr *attr,
157 struct obd_trans_info *oti, void **wait_handle);
158 int filter_clear_truncated_page(struct inode *inode);
161 struct ost_filterdata {
164 int filter_log_sz_change(struct llog_handle *cathandle,
165 struct ll_fid *mds_fid,
167 struct llog_cookie *logcookie,
168 struct inode *inode);
169 //int filter_get_catalog(struct obd_device *);
170 void filter_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
171 void *cb_data, int error);
172 int filter_recov_log_mds_ost_cb(struct llog_handle *llh,
173 struct llog_rec_hdr *rec, void *data);
176 void filter_tally_write(struct obd_export *exp, struct page **pages,
177 int nr_pages, unsigned long *blocks,
178 int blocks_per_page);
179 void filter_tally_read(struct obd_export *exp, struct page **pages,
180 int nr_pages, unsigned long *blocks,
181 int blocks_per_page);
182 int lproc_filter_attach_seqstat(struct obd_device *dev);
184 static inline void filter_tally_write(struct obd_export *exp,
185 struct page **pages, int nr_pages,
186 unsigned long *blocks, int blocks_per_page) {}
187 static inline void filter_tally_read(struct obd_export *exp,
188 struct page **pages, int nr_pages,
189 unsigned long *blocks, int blocks_per_page) {}
190 static inline void filter_tally_read(struct filter_obd *filter,
191 struct page **pages, int nr_pages,
192 unsigned long *blocks, int blocks_per_page) {}
193 static inline int lproc_filter_attach_seqstat(struct obd_device *dev) {}
197 extern quota_interface_t *filter_quota_interface_ref;
200 #endif /* _FILTER_INTERNAL_H */