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 FILTER_LAYOUT_VERSION "2"
21 #ifndef OBD_FILTER_DEVICENAME
22 # define OBD_FILTER_DEVICENAME "obdfilter"
25 #ifndef OBD_FILTER_SAN_DEVICENAME
26 # define OBD_FILTER_SAN_DEVICENAME "sanobdfilter"
29 #define LAST_RCVD "last_rcvd"
30 #define FILTER_INIT_OBJID 0
32 #define FILTER_LR_SERVER_SIZE 512
34 #define FILTER_LR_CLIENT_START 8192
35 #define FILTER_LR_CLIENT_SIZE 128
37 /* This limit is arbitrary, but for now we fit it in 1 page (32k clients) */
38 #define FILTER_LR_MAX_CLIENTS (PAGE_SIZE * 8)
39 #define FILTER_LR_MAX_CLIENT_WORDS (FILTER_LR_MAX_CLIENTS/sizeof(unsigned long))
41 #define FILTER_SUBDIR_COUNT 32 /* set to zero for no subdirs */
42 #define FILTER_GROUPS 3 /* must be at least 3; not dynamic yet */
44 #define FILTER_RECOVERY_TIMEOUT (obd_timeout * 5 * HZ / 2) /* *waves hands* */
46 #define FILTER_ROCOMPAT_SUPP (0)
48 #define FILTER_INCOMPAT_GROUPS 0x00000001
49 #define FILTER_INCOMPAT_SUPP (FILTER_INCOMPAT_GROUPS)
51 /* Data stored per server at the head of the last_rcvd file. In le32 order.
52 * Try to keep this the same as mds_server_data so we might one day merge. */
53 struct filter_server_data {
54 __u8 fsd_uuid[40]; /* server UUID */
55 __u64 fsd_unused; /* was fsd_last_objid - don't use for now */
56 __u64 fsd_last_transno; /* last completed transaction ID */
57 __u64 fsd_mount_count; /* FILTER incarnation number */
58 __u32 fsd_feature_compat; /* compatible feature flags */
59 __u32 fsd_feature_rocompat;/* read-only compatible feature flags */
60 __u32 fsd_feature_incompat;/* incompatible feature flags */
61 __u32 fsd_server_size; /* size of server data area */
62 __u32 fsd_client_start; /* start of per-client data area */
63 __u16 fsd_client_size; /* size of per-client data area */
64 __u16 fsd_subdir_count; /* number of subdirectories for objects */
65 __u64 fsd_catalog_oid; /* recovery catalog object id */
66 __u32 fsd_catalog_ogen; /* recovery catalog inode generation */
67 __u8 fsd_peeruuid[40]; /* UUID of MDS associated with this OST */
68 __u8 fsd_padding[FILTER_LR_SERVER_SIZE - 140];
71 /* Data stored per client in the last_rcvd file. In le32 order. */
72 struct filter_client_data {
73 __u8 fcd_uuid[40]; /* client UUID */
74 __u64 fcd_last_rcvd; /* last completed transaction ID */
75 __u64 fcd_last_xid; /* client RPC xid for the last transaction */
76 __u8 fcd_padding[FILTER_LR_CLIENT_SIZE - 56];
79 #define FILTER_DENTRY_MAGIC 0x9efba101
80 #define FILTER_FLAG_DESTROY 0x0001 /* destroy dentry on last file close */
82 /* Limit the returned fields marked valid to those that we actually might set */
83 #define FILTER_VALID_FLAGS (OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLGENER |\
84 OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ|\
85 OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME)
88 LPROC_FILTER_READ_BYTES = 0,
89 LPROC_FILTER_WRITE_BYTES = 1,
94 struct dentry *filter_parent(struct obd_device *, obd_gr group, obd_id objid);
95 struct dentry *filter_parent_lock(struct obd_device *, obd_gr, obd_id,
96 ldlm_mode_t, struct lustre_handle *);
97 void f_dput(struct dentry *);
98 struct dentry *filter_fid2dentry(struct obd_device *, struct dentry *dir,
99 obd_gr group, obd_id id);
100 struct dentry *__filter_oa2dentry(struct obd_device *obd, struct obdo *oa,
102 #define filter_oa2dentry(obd, oa) __filter_oa2dentry(obd, oa, __FUNCTION__)
104 int filter_finish_transno(struct obd_export *, struct obd_trans_info *, int rc);
105 __u64 filter_next_id(struct filter_obd *, struct obdo *);
106 __u64 filter_last_id(struct filter_obd *, struct obdo *);
107 int filter_update_server_data(struct obd_device *, struct file *,
108 struct filter_server_data *, int force_sync);
109 int filter_update_last_objid(struct obd_device *, obd_gr, int force_sync);
110 int filter_common_setup(struct obd_device *, obd_count len, void *buf,
114 int filter_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
115 struct obd_ioobj *, int niocount, struct niobuf_remote *,
116 struct niobuf_local *, struct obd_trans_info *);
117 int filter_commitrw(int cmd, struct obd_export *, struct obdo *, int objcount,
118 struct obd_ioobj *, int niocount, struct niobuf_local *,
119 struct obd_trans_info *);
120 int filter_brw(int cmd, struct obd_export *, struct obdo *,
121 struct lov_stripe_md *, obd_count oa_bufs, struct brw_page *,
122 struct obd_trans_info *);
123 void flip_into_page_cache(struct inode *inode, struct page *new_page);
126 int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount,
127 struct obd_ioobj *obj, int niocount,
128 struct niobuf_local *res, struct obd_trans_info *oti);
131 struct ost_filterdata {
134 int filter_log_sz_change(struct llog_handle *cathandle,
135 struct ll_fid *mds_fid,
137 struct llog_cookie *logcookie,
138 struct inode *inode);
139 //int filter_get_catalog(struct obd_device *);
140 void filter_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
141 void *cb_data, int error);
142 int filter_recov_log_unlink_cb(struct llog_handle *llh,
143 struct llog_rec_hdr *rec, void *data);
146 int filter_san_setup(struct obd_device *obd, obd_count len, void *buf);
147 int filter_san_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
148 struct obd_ioobj *, int niocount, struct niobuf_remote *);
151 void filter_tally_write(struct filter_obd *filter, struct page **pages,
152 int nr_pages, unsigned long *blocks,
153 int blocks_per_page);
154 void filter_tally_read(struct filter_obd *filter, struct niobuf_local *lnb,
156 int lproc_filter_attach_seqstat(struct obd_device *dev);
158 static inline filter_tally_write(struct filter_obd *filter,
159 struct page **pages, int nr_pages,
160 unsigned long *blocks, int blocks_per_page) {}
161 static inline void filter_tally_read(struct filter_obd *filter,
162 struct niobuf_local *lnb, int niocount)
164 static inline lproc_filter_attach_seqstat(struct obd_device *dev) {}