1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2003 Cluster File Systems, Inc.
6 * This code is issued under the GNU General Public License.
7 * See the file COPYING in this distribution
10 #ifndef _FILTER_INTERNAL_H
11 #define _FILTER_INTERNAL_H
14 # include <linux/spinlock.h>
16 #include <linux/lustre_handles.h>
17 #include <linux/obd.h>
19 #define LAST_RCVD "last_rcvd"
20 #define FILTER_INIT_OBJID 0
22 #define FILTER_LR_SERVER_SIZE 512
24 #define FILTER_LR_CLIENT_START 8192
25 #define FILTER_LR_CLIENT_SIZE 128
27 /* This limit is arbitrary, but for now we fit it in 1 page (32k clients) */
28 #define FILTER_LR_MAX_CLIENTS (PAGE_SIZE * 8)
30 #define FILTER_RECOVERY_TIMEOUT (obd_timeout * 5 * HZ / 2) /* *waves hands* */
32 #define FILTER_ROCOMPAT_SUPP (0)
34 #define FILTER_INCOMPAT_GROUPS 0x00000001
35 #define FILTER_INCOMPAT_SUPP (FILTER_INCOMPAT_GROUPS)
37 #define FILTER_GRANT_CHUNK (2ULL*1024*1024)
39 /* Data stored per server at the head of the last_rcvd file. In le32 order.
40 * Try to keep this the same as mds_server_data so we might one day merge. */
41 struct filter_server_data {
42 __u8 fsd_uuid[40]; /* server UUID */
43 __u64 fsd_unused; /* was fsd_last_objid - don't use for now */
44 __u64 fsd_last_transno; /* last completed transaction ID */
45 __u64 fsd_mount_count; /* FILTER incarnation number */
46 __u32 fsd_feature_compat; /* compatible feature flags */
47 __u32 fsd_feature_rocompat;/* read-only compatible feature flags */
48 __u32 fsd_feature_incompat;/* incompatible feature flags */
49 __u32 fsd_server_size; /* size of server data area */
50 __u32 fsd_client_start; /* start of per-client data area */
51 __u16 fsd_client_size; /* size of per-client data area */
52 __u16 fsd_subdir_count; /* number of subdirectories for objects */
53 __u64 fsd_catalog_oid; /* recovery catalog object id */
54 __u32 fsd_catalog_ogen; /* recovery catalog inode generation */
55 __u8 fsd_peeruuid[40]; /* UUID of MDS associated with this OST */
56 __u8 fsd_padding[FILTER_LR_SERVER_SIZE - 140];
59 /* Data stored per client in the last_rcvd file. In le32 order. */
60 struct filter_client_data {
61 __u8 fcd_uuid[40]; /* client UUID */
62 __u64 fcd_last_rcvd; /* last completed transaction ID */
63 __u64 fcd_last_xid; /* client RPC xid for the last transaction */
64 __u32 fcd_group; /* client group num*/
65 __u8 fcd_padding[FILTER_LR_CLIENT_SIZE - 60];
68 #define FILTER_DENTRY_MAGIC 0x9efba101
69 #define FILTER_FLAG_DESTROY 0x0001 /* destroy dentry on last file close */
71 /* Limit the returned fields marked valid to those that we actually might set */
72 #define FILTER_VALID_FLAGS (OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLGENER |\
73 OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ|\
74 OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME)
77 LPROC_FILTER_READ_BYTES = 0,
78 LPROC_FILTER_WRITE_BYTES = 1,
82 #define FILTER_MAX_CACHE_SIZE (32 * 1024 * 1024) /* was OBD_OBJECT_EOF */
84 /* We have to pass a 'created' array to fsfilt_map_inode_pages() which we
85 * then ignore. So we pre-allocate one that everyone can use... */
86 #define OBDFILTER_CREATED_SCRATCHPAD_ENTRIES 1024
87 extern int *obdfilter_created_scratchpad;
90 void f_dput(struct dentry *);
91 struct dentry *filter_id2dentry(struct obd_device *, struct dentry *dir,
92 obd_gr group, obd_id id);
93 struct dentry *__filter_oa2dentry(struct obd_device *obd, struct obdo *oa,
95 #define filter_oa2dentry(obd, oa) __filter_oa2dentry(obd, oa, __FUNCTION__)
97 int filter_finish_transno(struct obd_export *, struct obd_trans_info *, int rc);
98 __u64 filter_next_id(struct filter_obd *, int group);
99 __u64 filter_last_id(struct filter_obd *, int group);
100 int filter_update_server_data(struct obd_device *, struct file *,
101 struct filter_server_data *, int force_sync);
102 int filter_update_last_objid(struct obd_device *, obd_gr, int force_sync);
103 int filter_common_setup(struct obd_device *, obd_count len, void *buf,
106 struct dentry *filter_crow_object(struct obd_device *obd, struct obdo *oa);
108 int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
109 struct obdo *oa, struct obd_trans_info *oti);
111 int filter_setattr(struct obd_export *exp, struct obdo *oa,
112 struct lov_stripe_md *md, struct obd_trans_info *oti,
113 struct lustre_capa *capa);
115 int filter_create_object(struct obd_device *obd, struct obdo *oa);
118 extern struct ldlm_valblock_ops filter_lvbo;
122 int filter_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
123 struct obd_ioobj *, int niocount, struct niobuf_remote *,
124 struct niobuf_local *, struct obd_trans_info *,
125 struct lustre_capa *capa);
126 int filter_commitrw(int cmd, struct obd_export *, struct obdo *, int objcount,
127 struct obd_ioobj *, int niocount, struct niobuf_local *,
128 struct obd_trans_info *, int rc);
129 int filter_write_extents(struct obd_export *exp, struct obd_ioobj *obj,
130 int objcount, int niocount,struct niobuf_local *local,
132 int filter_do_cow(struct obd_export *exp, struct obd_ioobj *obj,
133 int nioo, struct niobuf_remote *rnb);
134 int filter_brw(int cmd, struct obd_export *, struct obdo *,
135 struct lov_stripe_md *, obd_count oa_bufs, struct brw_page *,
136 struct obd_trans_info *);
137 void flip_into_page_cache(struct inode *inode, struct page *new_page);
139 void filter_free_dio_pages(int objcount, struct obd_ioobj *obj,
140 int niocount, struct niobuf_local *res);
143 int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount,
144 struct obd_ioobj *obj, int niocount,
145 struct niobuf_local *res, struct obd_trans_info *oti,
147 obd_size filter_grant_space_left(struct obd_export *exp);
148 long filter_grant(struct obd_export *exp, obd_size current_grant,
149 obd_size want, obd_size fs_space_left);
150 void filter_grant_commit(struct obd_export *exp, int niocount,
151 struct niobuf_local *res);
153 int filter_alloc_iobuf(int rw, int num_pages, void **ret);
154 void filter_free_iobuf(void *iobuf);
155 int filter_iobuf_add_page(struct obd_device *obd, void *iobuf,
156 struct inode *inode, struct page *page);
157 int filter_direct_io(int rw, struct dentry *dchild, void *iobuf,
158 struct obd_export *exp, struct iattr *attr,
159 struct obd_trans_info *oti, void **wait_handle);
162 struct ost_filterdata {
166 int filter_log_sz_change(struct obd_device *obd,
167 struct lustre_id *id, __u32 io_epoch,
168 struct llog_cookie *logcookie,
169 struct inode *inode);
171 //int filter_get_catalog(struct obd_device *);
172 void filter_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
173 void *cb_data, int error);
174 int filter_recov_log_unlink_cb(struct llog_handle *llh,
175 struct llog_rec_hdr *rec, void *data);
178 int filter_san_setup(struct obd_device *obd, obd_count len, void *buf);
179 int filter_san_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
180 struct obd_ioobj *, int niocount, struct niobuf_remote *);
183 void filter_tally_write(struct filter_obd *filter, struct page **pages,
184 int nr_pages, unsigned long *blocks,
185 int blocks_per_page);
186 void filter_tally_read(struct filter_obd *filter, struct niobuf_local *lnb,
188 int lproc_filter_attach_seqstat(struct obd_device *dev);
190 static inline filter_tally_write(struct filter_obd *filter,
191 struct page **pages, int nr_pages,
192 unsigned long *blocks, int blocks_per_page) {}
193 static inline void filter_tally_read(struct filter_obd *filter,
194 struct niobuf_local *lnb, int niocount)
196 static inline lproc_filter_attach_seqstat(struct obd_device *dev) {}
200 int filter_init_capa_keys(struct obd_device *obd);
201 void filter_free_capa_keys(struct filter_obd *filter);
202 int filter_update_capa_key(struct obd_device *obd, struct lustre_capa_key *key);
203 int filter_verify_capa(int cmd, struct obd_export *exp, struct lustre_capa *capa);
204 int filter_verify_fid(struct obd_export *exp, struct inode *inode,
205 struct lustre_capa *capa);