1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #ifndef _FILTER_INTERNAL_H
38 #define _FILTER_INTERNAL_H
41 # include <linux/spinlock.h>
43 #include <lustre_handles.h>
44 #include <lustre_debug.h>
46 #include <lprocfs_status.h>
48 #define FILTER_LAYOUT_VERSION "2"
50 #define FILTER_INIT_OBJID 0
52 #define FILTER_SUBDIR_COUNT 32 /* set to zero for no subdirs */
53 #define FILTER_GROUPS 3 /* must be at least 3; not dynamic yet */
55 #define FILTER_ROCOMPAT_SUPP (0)
57 #define FILTER_INCOMPAT_SUPP (OBD_INCOMPAT_GROUPS | OBD_INCOMPAT_OST | \
58 OBD_INCOMPAT_COMMON_LR)
60 #define FILTER_GRANT_CHUNK (2ULL * PTLRPC_MAX_BRW_SIZE)
61 #define FILTER_GRANT_SHRINK_LIMIT (16ULL * FILTER_GRANT_CHUNK)
62 #define GRANT_FOR_LLOG(obd) 16
64 extern struct file_operations filter_per_export_stats_fops;
65 extern struct file_operations filter_per_nid_stats_fops;
67 /* Limit the returned fields marked valid to those that we actually might set */
68 #define FILTER_VALID_FLAGS (OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLGENER |\
69 OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ|\
70 OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME)
73 struct ll_fid ff_fid; /* ff_fid.f_type == file stripe number */
78 /* per-client-per-object persistent state (LRU) */
79 struct filter_mod_data {
80 struct list_head fmd_list; /* linked to fed_mod_list */
81 __u64 fmd_id; /* object being written to */
82 __u64 fmd_gr; /* group being written to */
83 __u64 fmd_mactime_xid;/* xid highest {m,a,c}time setattr */
84 unsigned long fmd_expire; /* jiffies when it should expire */
85 int fmd_refcount; /* reference counter - list holds 1 */
88 #ifdef HAVE_BGL_SUPPORT
89 #define FILTER_FMD_MAX_NUM_DEFAULT 128 /* many active files per client on BGL */
91 #define FILTER_FMD_MAX_NUM_DEFAULT 32
93 /* Client cache seconds */
94 #define FILTER_FMD_MAX_AGE_DEFAULT ((obd_timeout + 10) * HZ)
96 #ifndef HAVE_PAGE_CONSTANT
97 #define mapping_cap_page_constant_write(mapping) 0
98 #define SetPageConstant(page) do {} while (0)
99 #define ClearPageConstant(page) do {} while (0)
102 struct filter_mod_data *filter_fmd_find(struct obd_export *exp,
103 obd_id objid, obd_gr group);
104 struct filter_mod_data *filter_fmd_get(struct obd_export *exp,
105 obd_id objid, obd_gr group);
106 void filter_fmd_put(struct obd_export *exp, struct filter_mod_data *fmd);
107 void filter_fmd_expire(struct obd_export *exp);
110 LPROC_FILTER_READ_BYTES = 0,
111 LPROC_FILTER_WRITE_BYTES = 1,
112 LPROC_FILTER_GET_PAGE = 2,
113 LPROC_FILTER_NO_PAGE = 3,
114 LPROC_FILTER_CACHE_ACCESS = 4,
115 LPROC_FILTER_CACHE_HIT = 5,
116 LPROC_FILTER_CACHE_MISS = 6,
120 //#define FILTER_MAX_CACHE_SIZE (32 * 1024 * 1024) /* was OBD_OBJECT_EOF */
121 #define FILTER_MAX_CACHE_SIZE OBD_OBJECT_EOF
123 /* We have to pass a 'created' array to fsfilt_map_inode_pages() which we
124 * then ignore. So we pre-allocate one that everyone can use... */
125 #define OBDFILTER_CREATED_SCRATCHPAD_ENTRIES 1024
126 extern int *obdfilter_created_scratchpad;
128 extern void target_recovery_fini(struct obd_device *obd);
129 extern void target_recovery_init(struct lu_target *lut,
130 svc_handler_t handler);
133 void f_dput(struct dentry *);
134 struct dentry *filter_fid2dentry(struct obd_device *, struct dentry *dir,
135 obd_gr group, obd_id id);
136 struct dentry *__filter_oa2dentry(struct obd_device *obd, struct obdo *oa,
137 const char *what, int quiet);
138 #define filter_oa2dentry(obd, oa) __filter_oa2dentry(obd, oa, __FUNCTION__, 0)
140 int filter_finish_transno(struct obd_export *, struct inode *,
141 struct obd_trans_info *, int rc, int force_sync);
142 __u64 filter_next_id(struct filter_obd *, struct obdo *);
143 __u64 filter_last_id(struct filter_obd *, obd_gr group);
144 int filter_update_fidea(struct obd_export *exp, struct inode *inode,
145 void *handle, struct obdo *oa);
146 int filter_update_server_data(struct obd_device *, struct file *,
147 struct lr_server_data *, int force_sync);
148 int filter_update_last_objid(struct obd_device *, obd_gr, int force_sync);
149 int filter_common_setup(struct obd_device *, struct lustre_cfg *lcfg,
151 int filter_destroy(struct obd_export *exp, struct obdo *oa,
152 struct lov_stripe_md *md, struct obd_trans_info *,
153 struct obd_export *, void *);
154 int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
155 struct obdo *oa, struct obd_trans_info *oti);
156 int filter_setattr(struct obd_export *exp, struct obd_info *oinfo,
157 struct obd_trans_info *oti);
159 struct dentry *filter_create_object(struct obd_device *obd, struct obdo *oa);
161 struct obd_llog_group *filter_find_olg(struct obd_device *obd, int group);
164 extern struct ldlm_valblock_ops filter_lvbo;
168 int filter_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
169 struct obd_ioobj *, struct niobuf_remote *,
170 int *, struct niobuf_local *, struct obd_trans_info *,
171 struct lustre_capa *);
172 int filter_commitrw(int cmd, struct obd_export *, struct obdo *, int objcount,
173 struct obd_ioobj *, struct niobuf_remote *, int,
174 struct niobuf_local *, struct obd_trans_info *, int rc);
175 int filter_brw(int cmd, struct obd_export *, struct obd_info *oinfo,
176 obd_count oa_bufs, struct brw_page *pga, struct obd_trans_info *);
177 void filter_invalidate_cache(struct obd_device *, struct obd_ioobj *,
178 struct niobuf_remote *, struct inode *);
182 int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount,
183 struct obd_ioobj *obj, struct niobuf_remote *, int,
184 struct niobuf_local *res, struct obd_trans_info *oti,
186 obd_size filter_grant_space_left(struct obd_export *exp);
187 long filter_grant(struct obd_export *exp, obd_size current_grant,
188 obd_size want, obd_size fs_space_left);
189 void filter_grant_commit(struct obd_export *exp, int niocount,
190 struct niobuf_local *res);
191 void filter_grant_incoming(struct obd_export *exp, struct obdo *oa);
192 struct filter_iobuf *filter_alloc_iobuf(struct filter_obd *, int rw,
194 void filter_free_iobuf(struct filter_iobuf *iobuf);
195 int filter_iobuf_add_page(struct obd_device *obd, struct filter_iobuf *iobuf,
196 struct inode *inode, struct page *page);
197 void *filter_iobuf_get(struct filter_obd *filter, struct obd_trans_info *oti);
198 void filter_iobuf_put(struct filter_obd *filter, struct filter_iobuf *iobuf,
199 struct obd_trans_info *oti);
200 int filter_direct_io(int rw, struct dentry *dchild, struct filter_iobuf *iobuf,
201 struct obd_export *exp, struct iattr *attr,
202 struct obd_trans_info *oti, void **wait_handle);
203 int filter_clear_truncated_page(struct inode *inode);
206 struct ost_filterdata {
209 int filter_log_sz_change(struct llog_handle *cathandle,
210 struct ll_fid *mds_fid,
212 struct llog_cookie *logcookie,
213 struct inode *inode);
214 //int filter_get_catalog(struct obd_device *);
215 void filter_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
216 void *cb_data, int error);
217 int filter_recov_log_mds_ost_cb(struct llog_handle *llh,
218 struct llog_rec_hdr *rec, void *data);
221 void filter_tally(struct obd_export *exp, struct page **pages, int nr_pages,
222 unsigned long *blocks, int blocks_per_page, int wr);
223 int lproc_filter_attach_seqstat(struct obd_device *dev);
224 void lprocfs_filter_init_vars(struct lprocfs_static_vars *lvars);
226 static inline void filter_tally(struct obd_export *exp, struct page **pages,
227 int nr_pages, unsigned long *blocks,
228 int blocks_per_page, int wr) {}
229 static inline int lproc_filter_attach_seqstat(struct obd_device *dev) {}
230 static void lprocfs_filter_init_vars(struct lprocfs_static_vars *lvars)
232 memset(lvars, 0, sizeof(*lvars));
237 extern quota_interface_t *filter_quota_interface_ref;
239 int filter_update_capa_key(struct obd_device *obd, struct lustre_capa_key *key);
240 int filter_auth_capa(struct obd_export *exp, struct lu_fid *fid, __u64 mdsid,
241 struct lustre_capa *capa, __u64 opc);
242 int filter_capa_fixoa(struct obd_export *exp, struct obdo *oa, __u64 mdsid,
243 struct lustre_capa *capa);
244 void filter_free_capa_keys(struct filter_obd *filter);
246 void blacklist_add(uid_t uid);
247 void blacklist_del(uid_t uid);
248 int blacklist_display(char *buf, int bufsize);
250 #endif /* _FILTER_INTERNAL_H */