1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37#ifndef OSC_INTERNAL_H
38#define OSC_INTERNAL_H
39
40#define OAP_MAGIC 8675309
41
42struct lu_env;
43
44enum async_flags {
45 ASYNC_READY = 0x1,
46
47 ASYNC_URGENT = 0x2,
48 ASYNC_COUNT_STABLE = 0x4,
49
50
51 ASYNC_HP = 0x10,
52};
53
54struct osc_async_page {
55 int oap_magic;
56 unsigned short oap_cmd;
57 unsigned short oap_interrupted:1;
58
59 struct list_head oap_pending_item;
60 struct list_head oap_rpc_item;
61
62 obd_off oap_obj_off;
63 unsigned oap_page_off;
64 enum async_flags oap_async_flags;
65
66 struct brw_page oap_brw_page;
67
68 struct ptlrpc_request *oap_request;
69 struct client_obd *oap_cli;
70 struct osc_object *oap_obj;
71
72 struct ldlm_lock *oap_ldlm_lock;
73 spinlock_t oap_lock;
74};
75
76#define oap_page oap_brw_page.pg
77#define oap_count oap_brw_page.count
78#define oap_brw_flags oap_brw_page.flag
79
80struct osc_cache_waiter {
81 struct list_head ocw_entry;
82 wait_queue_head_t ocw_waitq;
83 struct osc_async_page *ocw_oap;
84 int ocw_grant;
85 int ocw_rc;
86};
87
88int osc_create(const struct lu_env *env, struct obd_export *exp,
89 struct obdo *oa, struct lov_stripe_md **ea,
90 struct obd_trans_info *oti);
91int osc_real_create(struct obd_export *exp, struct obdo *oa,
92 struct lov_stripe_md **ea, struct obd_trans_info *oti);
93void osc_wake_cache_waiters(struct client_obd *cli);
94int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes);
95void osc_update_next_shrink(struct client_obd *cli);
96
97
98
99
100#include "../include/cl_object.h"
101
102extern struct ptlrpc_request_set *PTLRPCD_SET;
103
104int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
105 __u64 *flags, ldlm_policy_data_t *policy,
106 struct ost_lvb *lvb, int kms_valid,
107 obd_enqueue_update_f upcall,
108 void *cookie, struct ldlm_enqueue_info *einfo,
109 struct lustre_handle *lockh,
110 struct ptlrpc_request_set *rqset, int async, int agl);
111int osc_cancel_base(struct lustre_handle *lockh, __u32 mode);
112
113int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id,
114 __u32 type, ldlm_policy_data_t *policy, __u32 mode,
115 __u64 *flags, void *data, struct lustre_handle *lockh,
116 int unref);
117
118int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo,
119 struct obd_trans_info *oti,
120 obd_enqueue_update_f upcall, void *cookie,
121 struct ptlrpc_request_set *rqset);
122int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo,
123 obd_enqueue_update_f upcall, void *cookie,
124 struct ptlrpc_request_set *rqset);
125int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo,
126 obd_enqueue_update_f upcall, void *cookie,
127 struct ptlrpc_request_set *rqset);
128
129int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *cfg);
130int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
131 struct list_head *ext_list, int cmd, pdl_policy_t p);
132int osc_lru_shrink(struct client_obd *cli, int target);
133
134extern spinlock_t osc_ast_guard;
135
136int osc_cleanup(struct obd_device *obd);
137int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
138
139#if defined (CONFIG_PROC_FS)
140int lproc_osc_attach_seqstat(struct obd_device *dev);
141void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars);
142#else
143static inline int lproc_osc_attach_seqstat(struct obd_device *dev) {return 0;}
144static inline void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars)
145{
146 memset(lvars, 0, sizeof(*lvars));
147}
148#endif
149
150extern struct lu_device_type osc_device_type;
151
152static inline int osc_recoverable_error(int rc)
153{
154 return (rc == -EIO || rc == -EROFS || rc == -ENOMEM ||
155 rc == -EAGAIN || rc == -EINPROGRESS);
156}
157
158static inline unsigned long rpcs_in_flight(struct client_obd *cli)
159{
160 return cli->cl_r_in_flight + cli->cl_w_in_flight;
161}
162
163#ifndef min_t
164#define min_t(type,x,y) \
165 ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
166#endif
167
168struct osc_device {
169 struct cl_device od_cl;
170 struct obd_export *od_exp;
171
172
173 struct osc_stats {
174 uint64_t os_lockless_writes;
175 uint64_t os_lockless_reads;
176 uint64_t os_lockless_truncates;
177 } od_stats;
178
179
180 int od_contention_time;
181 int od_lockless_truncate;
182};
183
184static inline struct osc_device *obd2osc_dev(const struct obd_device *d)
185{
186 return container_of0(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev);
187}
188
189int osc_dlm_lock_pageref(struct ldlm_lock *dlm);
190
191extern struct kmem_cache *osc_quota_kmem;
192struct osc_quota_info {
193
194 struct hlist_node oqi_hash;
195 obd_uid oqi_id;
196};
197int osc_quota_setup(struct obd_device *obd);
198int osc_quota_cleanup(struct obd_device *obd);
199int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[],
200 obd_flag valid, obd_flag flags);
201int osc_quota_chkdq(struct client_obd *cli, const unsigned int qid[]);
202int osc_quotactl(struct obd_device *unused, struct obd_export *exp,
203 struct obd_quotactl *oqctl);
204int osc_quotacheck(struct obd_device *unused, struct obd_export *exp,
205 struct obd_quotactl *oqctl);
206int osc_quota_poll_check(struct obd_export *exp, struct if_quotacheck *qchk);
207
208#endif
209