Whamcloud - gitweb
port llog fixes from b1_6 into HEAD
[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 <lustre_disk.h>
12 #include <lustre_handles.h>
13 #include <lustre_debug.h>
14 #include <obd.h>
15 #include <lprocfs_status.h>
16
17 #define FILTER_LAYOUT_VERSION "2"
18
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_INCOMPAT_SUPP (OBD_INCOMPAT_GROUPS | OBD_INCOMPAT_OST | \
27                               OBD_INCOMPAT_COMMON_LR)
28
29 #define FILTER_GRANT_CHUNK (2ULL * PTLRPC_MAX_BRW_SIZE)
30 #define GRANT_FOR_LLOG(obd) 16
31
32 #define FILTER_RECOVERY_TIMEOUT (obd_timeout * 5 * HZ / 2) /* *waves hands* */
33
34 extern struct file_operations filter_per_export_stats_fops;
35
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         __u32 fcd_group;           /* mds group */
42         __u8  fcd_padding[LR_CLIENT_SIZE - 60];
43 };
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;         /* ff_fid.f_type == file stripe number */
52         __u64           ff_objid;
53         __u64           ff_group;
54 };
55
56 /* per-client-per-object persistent state (LRU) */
57 struct filter_mod_data {
58         struct list_head fmd_list;      /* linked to fed_mod_list */
59         __u64            fmd_id;        /* object being written to */
60         __u64            fmd_gr;        /* group being written to */
61         __u64            fmd_mactime_xid;/* xid highest {m,a,c}time setattr */
62         unsigned long    fmd_expire;    /* jiffies when it should expire */
63         int              fmd_refcount;  /* reference counter - list holds 1 */
64 };
65
66 #ifdef BGL_SUPPORT
67 #define FILTER_FMD_MAX_NUM_DEFAULT 128 /* many active files per client on BGL */
68 #else
69 #define FILTER_FMD_MAX_NUM_DEFAULT  32
70 #endif
71 #define FILTER_FMD_MAX_AGE_DEFAULT ((obd_timeout + 10) * HZ)
72
73 struct filter_mod_data *filter_fmd_find(struct obd_export *exp,
74                                         obd_id objid, obd_gr group);
75 struct filter_mod_data *filter_fmd_get(struct obd_export *exp,
76                                        obd_id objid, obd_gr group);
77 void filter_fmd_put(struct obd_export *exp, struct filter_mod_data *fmd);
78 void filter_fmd_expire(struct obd_export *exp);
79
80 enum {
81         LPROC_FILTER_READ_BYTES = 0,
82         LPROC_FILTER_WRITE_BYTES = 1,
83         LPROC_FILTER_LAST,
84 };
85
86 //#define FILTER_MAX_CACHE_SIZE (32 * 1024 * 1024) /* was OBD_OBJECT_EOF */
87 #define FILTER_MAX_CACHE_SIZE OBD_OBJECT_EOF
88
89 /* We have to pass a 'created' array to fsfilt_map_inode_pages() which we
90  * then ignore.  So we pre-allocate one that everyone can use... */
91 #define OBDFILTER_CREATED_SCRATCHPAD_ENTRIES 1024
92 extern int *obdfilter_created_scratchpad;
93
94 extern void target_recovery_fini(struct obd_device *obd);
95 extern void target_recovery_init(struct obd_device *obd,
96                                  svc_handler_t handler);
97
98 /* filter.c */
99 void f_dput(struct dentry *);
100 struct dentry *filter_fid2dentry(struct obd_device *, struct dentry *dir,
101                                  obd_gr group, obd_id id);
102 struct dentry *__filter_oa2dentry(struct obd_device *obd, struct obdo *oa,
103                                   const char *what, int quiet);
104 #define filter_oa2dentry(obd, oa) __filter_oa2dentry(obd, oa, __FUNCTION__, 0)
105
106 int filter_finish_transno(struct obd_export *, struct obd_trans_info *, int rc,
107                           int force_sync);
108 __u64 filter_next_id(struct filter_obd *, struct obdo *);
109 __u64 filter_last_id(struct filter_obd *, obd_gr group);
110 int filter_update_fidea(struct obd_export *exp, struct inode *inode,
111                         void *handle, struct obdo *oa);
112 int filter_update_server_data(struct obd_device *, struct file *,
113                               struct lr_server_data *, int force_sync);
114 int filter_update_last_objid(struct obd_device *, obd_gr, int force_sync);
115 int filter_common_setup(struct obd_device *, struct lustre_cfg *lcfg,
116                         void *option);
117 int filter_destroy(struct obd_export *exp, struct obdo *oa,
118                    struct lov_stripe_md *md, struct obd_trans_info *,
119                    struct obd_export *);
120 int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
121                             struct obdo *oa, struct obd_trans_info *oti);
122 int filter_setattr(struct obd_export *exp, struct obd_info *oinfo,
123                    struct obd_trans_info *oti);
124
125 struct dentry *filter_create_object(struct obd_device *obd, struct obdo *oa);
126
127 struct obd_llog_group *filter_find_olg(struct obd_device *obd, int group);
128
129 /* filter_lvb.c */
130 extern struct ldlm_valblock_ops filter_lvbo;
131
132
133 /* filter_io.c */
134 int filter_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
135                   struct obd_ioobj *, int niocount, struct niobuf_remote *,
136                   struct niobuf_local *, struct obd_trans_info *,
137                   struct lustre_capa *);
138 int filter_commitrw(int cmd, struct obd_export *, struct obdo *, int objcount,
139                     struct obd_ioobj *, int niocount, struct niobuf_local *,
140                     struct obd_trans_info *, int rc);
141 int filter_brw(int cmd, struct obd_export *, struct obd_info *oinfo,
142                obd_count oa_bufs, struct brw_page *pga, struct obd_trans_info *);
143 void flip_into_page_cache(struct inode *inode, struct page *new_page);
144
145 /* filter_io_*.c */
146 struct filter_iobuf;
147 int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount,
148                           struct obd_ioobj *obj, int niocount,
149                           struct niobuf_local *res, struct obd_trans_info *oti,
150                           int rc);
151 obd_size filter_grant_space_left(struct obd_export *exp);
152 long filter_grant(struct obd_export *exp, obd_size current_grant,
153                   obd_size want, obd_size fs_space_left);
154 void filter_grant_commit(struct obd_export *exp, int niocount,
155                          struct niobuf_local *res);
156 struct filter_iobuf *filter_alloc_iobuf(struct filter_obd *, int rw,
157                                         int num_pages);
158 void filter_free_iobuf(struct filter_iobuf *iobuf);
159 int filter_iobuf_add_page(struct obd_device *obd, struct filter_iobuf *iobuf,
160                           struct inode *inode, struct page *page);
161 void *filter_iobuf_get(struct filter_obd *filter, struct obd_trans_info *oti);
162 void filter_iobuf_put(struct filter_obd *filter, struct filter_iobuf *iobuf,
163                       struct obd_trans_info *oti);
164 int filter_direct_io(int rw, struct dentry *dchild, struct filter_iobuf *iobuf,
165                      struct obd_export *exp, struct iattr *attr,
166                      struct obd_trans_info *oti, void **wait_handle);
167 int filter_clear_truncated_page(struct inode *inode);
168
169 /* filter_log.c */
170 struct ost_filterdata {
171         __u32  ofd_epoch;
172 };
173 int filter_log_sz_change(struct llog_handle *cathandle,
174                          struct ll_fid *mds_fid,
175                          __u32 ioepoch,
176                          struct llog_cookie *logcookie,
177                          struct inode *inode);
178 //int filter_get_catalog(struct obd_device *);
179 void filter_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
180                               void *cb_data, int error);
181 int filter_recov_log_mds_ost_cb(struct llog_handle *llh,
182                                struct llog_rec_hdr *rec, void *data);
183
184 #ifdef LPROCFS
185 void filter_tally(struct obd_export *exp, struct page **pages, int nr_pages,
186                   unsigned long *blocks, int blocks_per_page, int wr);
187 int lproc_filter_attach_seqstat(struct obd_device *dev);
188 void lprocfs_filter_init_vars(struct lprocfs_static_vars *lvars);
189 #else
190 static inline void filter_tally(struct obd_export *exp, struct page **pages,
191                                 int nr_pages, unsigned long *blocks,
192                                 int blocks_per_page, int wr) {}
193 static inline int lproc_filter_attach_seqstat(struct obd_device *dev) {}
194 static void lprocfs_filter_init_vars(struct lprocfs_static_vars *lvars)
195 {
196         memset(lvars, 0, sizeof(*lvars));
197 }
198 #endif
199
200 /* Quota stuff */
201 extern quota_interface_t *filter_quota_interface_ref;
202
203 /* Capability */
204 static inline __u64 obdo_mdsno(struct obdo *oa)
205 {
206         return oa->o_gr - FILTER_GROUP_MDS0;
207 }
208
209 int filter_update_capa_key(struct obd_device *obd, struct lustre_capa_key *key);
210 int filter_auth_capa(struct obd_export *exp, struct lu_fid *fid, __u64 mdsid,
211                      struct lustre_capa *capa, __u64 opc);
212 void filter_free_capa_keys(struct filter_obd *filter);
213
214 void blacklist_add(uid_t uid);
215 void blacklist_del(uid_t uid);
216 int blacklist_display(char *buf, int bufsize);
217
218 #endif /* _FILTER_INTERNAL_H */