Whamcloud - gitweb
merge b_devel into HEAD, which will become 0.7.3
[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 #ifndef OBD_FILTER_DEVICENAME
20 # define OBD_FILTER_DEVICENAME "obdfilter"
21 #endif
22
23 #ifndef OBD_FILTER_SAN_DEVICENAME
24 # define OBD_FILTER_SAN_DEVICENAME "sanobdfilter"
25 #endif
26
27 #define LAST_RCVD "last_rcvd"
28 #define FILTER_INIT_OBJID 2
29 /* max creates/sec * journal->j_commit_interval */
30 #define FILTER_SKIP_OBJID (10000 * 5)
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
43 #define FILTER_MOUNT_RECOV 2
44 #define FILTER_RECOVERY_TIMEOUT (obd_timeout * 5 * HZ / 2) /* *waves hands* */
45
46 /* Data stored per server at the head of the last_rcvd file.  In le32 order. */
47 struct filter_server_data {
48         __u8  fsd_uuid[37];        /* server UUID */
49         __u8  fsd_uuid_padding[3]; /* unused */
50         __u64 fsd_last_objid;      /* last created object ID */
51         __u64 fsd_last_transno;    /* last completed transaction ID */
52         __u64 fsd_mount_count;     /* FILTER incarnation number */
53         __u32 fsd_feature_compat;  /* compatible feature flags */
54         __u32 fsd_feature_rocompat;/* read-only compatible feature flags */
55         __u32 fsd_feature_incompat;/* incompatible feature flags */
56         __u32 fsd_server_size;     /* size of server data area */
57         __u32 fsd_client_start;    /* start of per-client data area */
58         __u16 fsd_client_size;     /* size of per-client data area */
59         __u16 fsd_subdir_count;    /* number of subdirectories for objects */
60         __u64 fsd_catalog_oid;     /* recovery catalog object id */
61         __u32 fsd_catalog_ogen;    /* recovery catalog inode generation */
62         __u8  fsd_peeruuid[37];    /* UUID of MDS associated with this OST */
63         __u8  peer_padding[3];     /* unused */
64         __u8  fsd_padding[FILTER_LR_SERVER_SIZE - 140];
65 };
66
67 /* Data stored per client in the last_rcvd file.  In le32 order. */
68 struct filter_client_data {
69         __u8  fcd_uuid[37];        /* client UUID */
70         __u8  fcd_uuid_padding[3]; /* unused */
71         __u64 fcd_last_rcvd;       /* last completed transaction ID */
72         __u64 fcd_mount_count;     /* FILTER incarnation number */
73         __u64 fcd_last_xid;        /* client RPC xid for the last transaction */
74         __u8  fcd_padding[FILTER_LR_CLIENT_SIZE - 64];
75 };
76
77 /* file data for open files on OST */
78 struct filter_file_data {
79         struct portals_handle ffd_handle;
80         atomic_t              ffd_refcount;
81         struct list_head      ffd_export_list; /* export open list - fed_lock */
82         struct file          *ffd_file;         /* file handle */
83 };
84
85 struct filter_dentry_data {
86         struct llog_cookie      fdd_cookie;
87         obd_id                  fdd_objid;
88         __u32                   fdd_magic;
89         atomic_t                fdd_open_count;
90         int                     fdd_flags;
91 };
92
93 #define FILTER_DENTRY_MAGIC 0x9efba101
94 #define FILTER_FLAG_DESTROY 0x0001      /* destroy dentry on last file close */
95
96 /* Limit the returned fields marked valid to those that we actually might set */
97 #define FILTER_VALID_FLAGS (OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLGENER  |\
98                             OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ|\
99                             OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME)
100
101 enum {
102         LPROC_FILTER_READ_BYTES = 0,
103         LPROC_FILTER_WRITE_BYTES = 1,
104         LPROC_FILTER_LAST,
105 };
106
107 /* filter.c */
108 struct dentry *filter_parent(struct obd_device *, obd_mode mode, obd_id objid);
109 struct dentry *filter_parent_lock(struct obd_device *, obd_mode mode,
110                                   obd_id objid, ldlm_mode_t lock_mode,
111                                   struct lustre_handle *lockh);
112 void f_dput(struct dentry *);
113 struct dentry *filter_fid2dentry(struct obd_device *, struct dentry *dir,
114                                  obd_mode mode, obd_id id);
115 struct dentry *__filter_oa2dentry(struct obd_device *obd, struct obdo *oa,
116                                   const char *what);
117 #define filter_oa2dentry(obd, oa) __filter_oa2dentry(obd, oa, __FUNCTION__)
118
119 int filter_finish_transno(struct obd_export *, struct obd_trans_info *, int rc);
120 __u64 filter_next_id(struct filter_obd *);
121 int filter_update_server_data(struct obd_device *, struct file *,
122                               struct filter_server_data *);
123 int filter_common_setup(struct obd_device *, obd_count len, void *buf,
124                         char *option);
125
126 /* filter_io.c */
127 int filter_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
128                   struct obd_ioobj *, int niocount, struct niobuf_remote *,
129                   struct niobuf_local *, struct obd_trans_info *);
130 int filter_commitrw(int cmd, struct obd_export *, struct obdo *, int objcount,
131                     struct obd_ioobj *, int niocount, struct niobuf_local *,
132                     struct obd_trans_info *);
133 int filter_brw(int cmd, struct lustre_handle *, struct obdo *,
134                struct lov_stripe_md *, obd_count oa_bufs, struct brw_page *,
135                struct obd_trans_info *);
136
137 /* filter_log.c */
138 int filter_log_cancel(struct lustre_handle *, struct lov_stripe_md *,
139                       int num_cookies, struct llog_cookie *, int flags);
140 int filter_log_op_create(struct llog_handle *cathandle, struct ll_fid *mds_fid,
141                          obd_id oid, obd_count ogen, struct llog_cookie *);
142 int filter_log_op_orphan(struct llog_handle *cathandle, obd_id oid,
143                          obd_count ogen, struct llog_cookie *);
144 struct llog_handle *filter_get_catalog(struct obd_device *);
145 void filter_put_catalog(struct llog_handle *cathandle);
146
147 /* filter_san.c */
148 int filter_san_setup(struct obd_device *obd, obd_count len, void *buf);
149 int filter_san_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
150                       struct obd_ioobj *, int niocount, struct niobuf_remote *);
151
152 #endif