Commit | Line | Data |
---|---|---|
d7e09d03 PT |
1 | /* |
2 | * GPL HEADER START | |
3 | * | |
4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 only, | |
8 | * as published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * General Public License version 2 for more details (a copy is included | |
14 | * in the LICENSE file that accompanied this code). | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * version 2 along with this program; If not, see | |
18 | * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf | |
19 | * | |
20 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
21 | * CA 95054 USA or visit www.sun.com if you need additional information or | |
22 | * have any questions. | |
23 | * | |
24 | * GPL HEADER END | |
25 | */ | |
26 | /* | |
27 | * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. | |
28 | * Use is subject to license terms. | |
29 | * | |
1dc563a6 | 30 | * Copyright (c) 2011, 2015, Intel Corporation. |
d7e09d03 PT |
31 | */ |
32 | /* | |
33 | * This file is part of Lustre, http://www.lustre.org/ | |
34 | * Lustre is a trademark of Sun Microsystems, Inc. | |
35 | */ | |
36 | ||
37 | #ifndef OSC_INTERNAL_H | |
38 | #define OSC_INTERNAL_H | |
39 | ||
40 | #define OAP_MAGIC 8675309 | |
41 | ||
aefd9d71 LX |
42 | extern atomic_t osc_pool_req_count; |
43 | extern unsigned int osc_reqpool_maxreqcount; | |
44 | extern struct ptlrpc_request_pool *osc_rq_pool; | |
45 | ||
d7e09d03 PT |
46 | struct lu_env; |
47 | ||
48 | enum async_flags { | |
49 | ASYNC_READY = 0x1, /* ap_make_ready will not be called before this | |
30aa9c52 OD |
50 | * page is added to an rpc |
51 | */ | |
d7e09d03 PT |
52 | ASYNC_URGENT = 0x2, /* page must be put into an RPC before return */ |
53 | ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called | |
30aa9c52 OD |
54 | * to give the caller a chance to update |
55 | * or cancel the size of the io | |
56 | */ | |
d7e09d03 PT |
57 | ASYNC_HP = 0x10, |
58 | }; | |
59 | ||
60 | struct osc_async_page { | |
61 | int oap_magic; | |
62 | unsigned short oap_cmd; | |
63 | unsigned short oap_interrupted:1; | |
64 | ||
65 | struct list_head oap_pending_item; | |
66 | struct list_head oap_rpc_item; | |
67 | ||
21aef7d9 | 68 | u64 oap_obj_off; |
d7e09d03 PT |
69 | unsigned oap_page_off; |
70 | enum async_flags oap_async_flags; | |
71 | ||
72 | struct brw_page oap_brw_page; | |
73 | ||
74 | struct ptlrpc_request *oap_request; | |
75 | struct client_obd *oap_cli; | |
76 | struct osc_object *oap_obj; | |
77 | ||
78 | struct ldlm_lock *oap_ldlm_lock; | |
79 | spinlock_t oap_lock; | |
80 | }; | |
81 | ||
82 | #define oap_page oap_brw_page.pg | |
83 | #define oap_count oap_brw_page.count | |
84 | #define oap_brw_flags oap_brw_page.flag | |
85 | ||
86 | struct osc_cache_waiter { | |
87 | struct list_head ocw_entry; | |
88 | wait_queue_head_t ocw_waitq; | |
89 | struct osc_async_page *ocw_oap; | |
90 | int ocw_grant; | |
91 | int ocw_rc; | |
92 | }; | |
93 | ||
d7e09d03 PT |
94 | void osc_wake_cache_waiters(struct client_obd *cli); |
95 | int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes); | |
96 | void osc_update_next_shrink(struct client_obd *cli); | |
97 | ||
98 | /* | |
99 | * cl integration. | |
100 | */ | |
3ee30015 | 101 | #include "../include/cl_object.h" |
d7e09d03 PT |
102 | |
103 | extern struct ptlrpc_request_set *PTLRPCD_SET; | |
104 | ||
105 | int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, | |
106 | __u64 *flags, ldlm_policy_data_t *policy, | |
107 | struct ost_lvb *lvb, int kms_valid, | |
108 | obd_enqueue_update_f upcall, | |
109 | void *cookie, struct ldlm_enqueue_info *einfo, | |
110 | struct lustre_handle *lockh, | |
111 | struct ptlrpc_request_set *rqset, int async, int agl); | |
112 | int osc_cancel_base(struct lustre_handle *lockh, __u32 mode); | |
113 | ||
114 | int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, | |
115 | __u32 type, ldlm_policy_data_t *policy, __u32 mode, | |
875332d4 | 116 | __u64 *flags, void *data, struct lustre_handle *lockh, |
d7e09d03 PT |
117 | int unref); |
118 | ||
119 | int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, | |
120 | struct obd_trans_info *oti, | |
121 | obd_enqueue_update_f upcall, void *cookie, | |
122 | struct ptlrpc_request_set *rqset); | |
123 | int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, | |
124 | obd_enqueue_update_f upcall, void *cookie, | |
125 | struct ptlrpc_request_set *rqset); | |
126 | int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, | |
127 | obd_enqueue_update_f upcall, void *cookie, | |
128 | struct ptlrpc_request_set *rqset); | |
129 | ||
130 | int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *cfg); | |
131 | int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, | |
c5c4c6fa | 132 | struct list_head *ext_list, int cmd); |
d7e09d03 PT |
133 | int osc_lru_shrink(struct client_obd *cli, int target); |
134 | ||
135 | extern spinlock_t osc_ast_guard; | |
136 | ||
d7e09d03 PT |
137 | int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg); |
138 | ||
d7e09d03 PT |
139 | int lproc_osc_attach_seqstat(struct obd_device *dev); |
140 | void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars); | |
d7e09d03 PT |
141 | |
142 | extern struct lu_device_type osc_device_type; | |
143 | ||
144 | static inline int osc_recoverable_error(int rc) | |
145 | { | |
146 | return (rc == -EIO || rc == -EROFS || rc == -ENOMEM || | |
147 | rc == -EAGAIN || rc == -EINPROGRESS); | |
148 | } | |
149 | ||
150 | static inline unsigned long rpcs_in_flight(struct client_obd *cli) | |
151 | { | |
152 | return cli->cl_r_in_flight + cli->cl_w_in_flight; | |
153 | } | |
154 | ||
d7e09d03 PT |
155 | struct osc_device { |
156 | struct cl_device od_cl; | |
157 | struct obd_export *od_exp; | |
158 | ||
159 | /* Write stats is actually protected by client_obd's lock. */ | |
160 | struct osc_stats { | |
161 | uint64_t os_lockless_writes; /* by bytes */ | |
162 | uint64_t os_lockless_reads; /* by bytes */ | |
163 | uint64_t os_lockless_truncates; /* by times */ | |
164 | } od_stats; | |
165 | ||
166 | /* configuration item(s) */ | |
167 | int od_contention_time; | |
168 | int od_lockless_truncate; | |
169 | }; | |
170 | ||
171 | static inline struct osc_device *obd2osc_dev(const struct obd_device *d) | |
172 | { | |
173 | return container_of0(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev); | |
174 | } | |
175 | ||
176 | int osc_dlm_lock_pageref(struct ldlm_lock *dlm); | |
177 | ||
178 | extern struct kmem_cache *osc_quota_kmem; | |
179 | struct osc_quota_info { | |
180 | /** linkage for quota hash table */ | |
181 | struct hlist_node oqi_hash; | |
21aef7d9 | 182 | u32 oqi_id; |
d7e09d03 | 183 | }; |
c9f6bb96 | 184 | |
d7e09d03 PT |
185 | int osc_quota_setup(struct obd_device *obd); |
186 | int osc_quota_cleanup(struct obd_device *obd); | |
187 | int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], | |
21aef7d9 | 188 | u32 valid, u32 flags); |
d7e09d03 PT |
189 | int osc_quota_chkdq(struct client_obd *cli, const unsigned int qid[]); |
190 | int osc_quotactl(struct obd_device *unused, struct obd_export *exp, | |
191 | struct obd_quotactl *oqctl); | |
192 | int osc_quotacheck(struct obd_device *unused, struct obd_export *exp, | |
193 | struct obd_quotactl *oqctl); | |
194 | int osc_quota_poll_check(struct obd_export *exp, struct if_quotacheck *qchk); | |
195 | ||
d7e09d03 | 196 | #endif /* OSC_INTERNAL_H */ |