Whamcloud - gitweb
b=1021,2720
[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  * Copyright (C) 2003 Cluster File Systems, Inc.
5  *
6  * This code is issued under the GNU General Public License.
7  * See the file COPYING in this distribution
8  */
9
10 #ifndef _FILTER_INTERNAL_H
11 #define _FILTER_INTERNAL_H
12
13 #ifdef __KERNEL__
14 # include <linux/spinlock.h>
15 #endif
16 #include <linux/lustre_handles.h>
17 #include <linux/obd.h>
18
19 #define FILTER_LAYOUT_VERSION "2"
20
21 #ifndef OBD_FILTER_DEVICENAME
22 # define OBD_FILTER_DEVICENAME "obdfilter"
23 #endif
24
25 #ifndef OBD_FILTER_SAN_DEVICENAME
26 # define OBD_FILTER_SAN_DEVICENAME "sanobdfilter"
27 #endif
28
29 #define LAST_RCVD "last_rcvd"
30 #define FILTER_INIT_OBJID 0
31
32 #define FILTER_LR_SERVER_SIZE    512
33
34 #define FILTER_LR_CLIENT_START   8192
35 #define FILTER_LR_CLIENT_SIZE    128
36
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))
40
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 */
43
44 #define FILTER_RECOVERY_TIMEOUT (obd_timeout * 5 * HZ / 2) /* *waves hands* */
45
46 #define FILTER_ROCOMPAT_SUPP   (0)
47
48 #define FILTER_INCOMPAT_GROUPS 0x00000001
49 #define FILTER_INCOMPAT_SUPP   (FILTER_INCOMPAT_GROUPS)
50
51 #define FILTER_GRANT_CHUNK (2ULL*1024*1024)
52
53 /* Data stored per server at the head of the last_rcvd file.  In le32 order.
54  * Try to keep this the same as mds_server_data so we might one day merge. */
55 struct filter_server_data {
56         __u8  fsd_uuid[40];        /* server UUID */
57         __u64 fsd_unused;          /* was fsd_last_objid - don't use for now */
58         __u64 fsd_last_transno;    /* last completed transaction ID */
59         __u64 fsd_mount_count;     /* FILTER incarnation number */
60         __u32 fsd_feature_compat;  /* compatible feature flags */
61         __u32 fsd_feature_rocompat;/* read-only compatible feature flags */
62         __u32 fsd_feature_incompat;/* incompatible feature flags */
63         __u32 fsd_server_size;     /* size of server data area */
64         __u32 fsd_client_start;    /* start of per-client data area */
65         __u16 fsd_client_size;     /* size of per-client data area */
66         __u16 fsd_subdir_count;    /* number of subdirectories for objects */
67         __u64 fsd_catalog_oid;     /* recovery catalog object id */
68         __u32 fsd_catalog_ogen;    /* recovery catalog inode generation */
69         __u8  fsd_peeruuid[40];    /* UUID of MDS associated with this OST */
70         __u8  fsd_padding[FILTER_LR_SERVER_SIZE - 140];
71 };
72
73 /* Data stored per client in the last_rcvd file.  In le32 order. */
74 struct filter_client_data {
75         __u8  fcd_uuid[40];        /* client UUID */
76         __u64 fcd_last_rcvd;       /* last completed transaction ID */
77         __u64 fcd_last_xid;        /* client RPC xid for the last transaction */
78         __u8  fcd_padding[FILTER_LR_CLIENT_SIZE - 56];
79 };
80
81 #define FILTER_DENTRY_MAGIC 0x9efba101
82 #define FILTER_FLAG_DESTROY 0x0001      /* destroy dentry on last file close */
83
84 /* Limit the returned fields marked valid to those that we actually might set */
85 #define FILTER_VALID_FLAGS (OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLGENER  |\
86                             OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ|\
87                             OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME)
88
89 enum {
90         LPROC_FILTER_READ_BYTES = 0,
91         LPROC_FILTER_WRITE_BYTES = 1,
92         LPROC_FILTER_LAST,
93 };
94
95 #define FILTER_MAX_CACHE_SIZE OBD_OBJECT_EOF
96
97 /* filter.c */
98 void f_dput(struct dentry *);
99 struct dentry *filter_fid2dentry(struct obd_device *, struct dentry *dir,
100                                  obd_gr group, obd_id id);
101 struct dentry *__filter_oa2dentry(struct obd_device *obd, struct obdo *oa,
102                                   const char *what);
103 #define filter_oa2dentry(obd, oa) __filter_oa2dentry(obd, oa, __FUNCTION__)
104
105 int filter_finish_transno(struct obd_export *, struct obd_trans_info *, int rc);
106 __u64 filter_next_id(struct filter_obd *, struct obdo *);
107 __u64 filter_last_id(struct filter_obd *, struct obdo *);
108 int filter_update_server_data(struct obd_device *, struct file *,
109                               struct filter_server_data *, int force_sync);
110 int filter_update_last_objid(struct obd_device *, obd_gr, int force_sync);
111 int filter_common_setup(struct obd_device *, obd_count len, void *buf,
112                         char *option);
113
114 /* filter_lvb.c */
115 extern struct ldlm_valblock_ops filter_lvbo;
116
117
118 /* filter_io.c */
119 int filter_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
120                   struct obd_ioobj *, int niocount, struct niobuf_remote *,
121                   struct niobuf_local *, struct obd_trans_info *);
122 int filter_commitrw(int cmd, struct obd_export *, struct obdo *, int objcount,
123                     struct obd_ioobj *, int niocount, struct niobuf_local *,
124                     struct obd_trans_info *);
125 int filter_brw(int cmd, struct obd_export *, struct obdo *,
126                struct lov_stripe_md *, obd_count oa_bufs, struct brw_page *,
127                struct obd_trans_info *);
128 void flip_into_page_cache(struct inode *inode, struct page *new_page);
129
130 /* filter_io_*.c */
131 int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount,
132                           struct obd_ioobj *obj, int niocount,
133                           struct niobuf_local *res, struct obd_trans_info *oti);
134 obd_size filter_grant_space_left(struct obd_export *exp);
135 long filter_grant(struct obd_export *exp, obd_size current_grant,
136                   obd_size want, obd_size fs_space_left);
137 void filter_grant_commit(struct obd_export *exp, int niocount,
138                          struct niobuf_local *res);
139
140 /* filter_log.c */
141 struct ost_filterdata {
142         __u32  ofd_epoch;
143 };
144 int filter_log_sz_change(struct llog_handle *cathandle,
145                          struct ll_fid *mds_fid,
146                          __u32 io_epoch,
147                          struct llog_cookie *logcookie,
148                          struct inode *inode);
149 //int filter_get_catalog(struct obd_device *);
150 void filter_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
151                               void *cb_data, int error);
152 int filter_recov_log_unlink_cb(struct llog_handle *llh,
153                                struct llog_rec_hdr *rec, void *data);
154
155 /* filter_san.c */
156 int filter_san_setup(struct obd_device *obd, obd_count len, void *buf);
157 int filter_san_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
158                       struct obd_ioobj *, int niocount, struct niobuf_remote *);
159
160 #ifdef __KERNEL__
161 void filter_tally_write(struct filter_obd *filter, struct page **pages,
162                         int nr_pages, unsigned long *blocks, 
163                         int blocks_per_page);
164 void filter_tally_read(struct filter_obd *filter, struct niobuf_local *lnb, 
165                        int niocount);
166 int lproc_filter_attach_seqstat(struct obd_device *dev);
167 #else
168 static inline filter_tally_write(struct filter_obd *filter, 
169                                  struct page **pages, int nr_pages, 
170                                  unsigned long *blocks, int blocks_per_page) {}
171 static inline void  filter_tally_read(struct filter_obd *filter, 
172                                       struct niobuf_local *lnb, int niocount)
173                                       {}
174 static inline lproc_filter_attach_seqstat(struct obd_device *dev) {}
175 #endif
176
177
178 #endif