]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/staging/lustre/lustre/osc/osc_internal.h
iio: imu: inv_mpu6050: test whoami first and against all known values
[mirror_ubuntu-artful-kernel.git] / drivers / staging / lustre / lustre / osc / osc_internal.h
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.gnu.org/licenses/gpl-2.0.html
19 *
20 * GPL HEADER END
21 */
22 /*
23 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
25 *
26 * Copyright (c) 2011, 2015, Intel Corporation.
27 */
28 /*
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
31 */
32
33 #ifndef OSC_INTERNAL_H
34 #define OSC_INTERNAL_H
35
36 #define OAP_MAGIC 8675309
37
38 extern atomic_t osc_pool_req_count;
39 extern unsigned int osc_reqpool_maxreqcount;
40 extern struct ptlrpc_request_pool *osc_rq_pool;
41
42 struct lu_env;
43
44 enum async_flags {
45 ASYNC_READY = 0x1, /* ap_make_ready will not be called before this
46 * page is added to an rpc
47 */
48 ASYNC_URGENT = 0x2, /* page must be put into an RPC before return */
49 ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called
50 * to give the caller a chance to update
51 * or cancel the size of the io
52 */
53 ASYNC_HP = 0x10,
54 };
55
56 struct osc_async_page {
57 int oap_magic;
58 unsigned short oap_cmd;
59 unsigned short oap_interrupted:1;
60
61 struct list_head oap_pending_item;
62 struct list_head oap_rpc_item;
63
64 u64 oap_obj_off;
65 unsigned oap_page_off;
66 enum async_flags oap_async_flags;
67
68 struct brw_page oap_brw_page;
69
70 struct ptlrpc_request *oap_request;
71 struct client_obd *oap_cli;
72 struct osc_object *oap_obj;
73
74 spinlock_t oap_lock;
75 };
76
77 #define oap_page oap_brw_page.pg
78 #define oap_count oap_brw_page.count
79 #define oap_brw_flags oap_brw_page.flag
80
81 static inline struct osc_async_page *brw_page2oap(struct brw_page *pga)
82 {
83 return (struct osc_async_page *)container_of(pga, struct osc_async_page,
84 oap_brw_page);
85 }
86
87 struct osc_cache_waiter {
88 struct list_head ocw_entry;
89 wait_queue_head_t ocw_waitq;
90 struct osc_async_page *ocw_oap;
91 int ocw_grant;
92 int ocw_rc;
93 };
94
95 void osc_wake_cache_waiters(struct client_obd *cli);
96 int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes);
97 void osc_update_next_shrink(struct client_obd *cli);
98
99 /*
100 * cl integration.
101 */
102 #include "../include/cl_object.h"
103
104 extern struct ptlrpc_request_set *PTLRPCD_SET;
105
106 typedef int (*osc_enqueue_upcall_f)(void *cookie, struct lustre_handle *lockh,
107 int rc);
108
109 int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
110 __u64 *flags, union ldlm_policy_data *policy,
111 struct ost_lvb *lvb, int kms_valid,
112 osc_enqueue_upcall_f upcall,
113 void *cookie, struct ldlm_enqueue_info *einfo,
114 struct ptlrpc_request_set *rqset, int async, int agl);
115
116 int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id,
117 enum ldlm_type type, union ldlm_policy_data *policy,
118 enum ldlm_mode mode, __u64 *flags, void *data,
119 struct lustre_handle *lockh, int unref);
120
121 int osc_setattr_async(struct obd_export *exp, struct obdo *oa,
122 obd_enqueue_update_f upcall, void *cookie,
123 struct ptlrpc_request_set *rqset);
124 int osc_punch_base(struct obd_export *exp, struct obdo *oa,
125 obd_enqueue_update_f upcall, void *cookie,
126 struct ptlrpc_request_set *rqset);
127 int osc_sync_base(struct osc_object *exp, struct obdo *oa,
128 obd_enqueue_update_f upcall, void *cookie,
129 struct ptlrpc_request_set *rqset);
130
131 int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *cfg);
132 int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
133 struct list_head *ext_list, int cmd);
134 long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli,
135 long target, bool force);
136 unsigned long osc_lru_reserve(struct client_obd *cli, unsigned long npages);
137 void osc_lru_unreserve(struct client_obd *cli, unsigned long npages);
138
139 unsigned long osc_ldlm_weigh_ast(struct ldlm_lock *dlmlock);
140
141 int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
142
143 int lproc_osc_attach_seqstat(struct obd_device *dev);
144 void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars);
145
146 extern struct lu_device_type osc_device_type;
147
148 static inline int osc_recoverable_error(int rc)
149 {
150 return (rc == -EIO || rc == -EROFS || rc == -ENOMEM ||
151 rc == -EAGAIN || rc == -EINPROGRESS);
152 }
153
154 static inline unsigned long rpcs_in_flight(struct client_obd *cli)
155 {
156 return cli->cl_r_in_flight + cli->cl_w_in_flight;
157 }
158
159 static inline char *cli_name(struct client_obd *cli)
160 {
161 return cli->cl_import->imp_obd->obd_name;
162 }
163
164 struct osc_device {
165 struct cl_device od_cl;
166 struct obd_export *od_exp;
167
168 /* Write stats is actually protected by client_obd's lock. */
169 struct osc_stats {
170 uint64_t os_lockless_writes; /* by bytes */
171 uint64_t os_lockless_reads; /* by bytes */
172 uint64_t os_lockless_truncates; /* by times */
173 } od_stats;
174
175 /* configuration item(s) */
176 int od_contention_time;
177 int od_lockless_truncate;
178 };
179
180 static inline struct osc_device *obd2osc_dev(const struct obd_device *d)
181 {
182 return container_of0(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev);
183 }
184
185 extern struct lu_kmem_descr osc_caches[];
186
187 extern struct kmem_cache *osc_quota_kmem;
188 struct osc_quota_info {
189 /** linkage for quota hash table */
190 struct hlist_node oqi_hash;
191 u32 oqi_id;
192 };
193
194 int osc_quota_setup(struct obd_device *obd);
195 int osc_quota_cleanup(struct obd_device *obd);
196 int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[],
197 u32 valid, u32 flags);
198 int osc_quota_chkdq(struct client_obd *cli, const unsigned int qid[]);
199 int osc_quotactl(struct obd_device *unused, struct obd_export *exp,
200 struct obd_quotactl *oqctl);
201 void osc_inc_unstable_pages(struct ptlrpc_request *req);
202 void osc_dec_unstable_pages(struct ptlrpc_request *req);
203 bool osc_over_unstable_soft_limit(struct client_obd *cli);
204
205 /**
206 * Bit flags for osc_dlm_lock_at_pageoff().
207 */
208 enum osc_dap_flags {
209 /**
210 * Just check if the desired lock exists, it won't hold reference
211 * count on lock.
212 */
213 OSC_DAP_FL_TEST_LOCK = BIT(0),
214 /**
215 * Return the lock even if it is being canceled.
216 */
217 OSC_DAP_FL_CANCELING = BIT(1),
218 };
219
220 struct ldlm_lock *osc_dlmlock_at_pgoff(const struct lu_env *env,
221 struct osc_object *obj, pgoff_t index,
222 enum osc_dap_flags flags);
223
224 int osc_object_invalidate(const struct lu_env *env, struct osc_object *osc);
225
226 /** osc shrink list to link all osc client obd */
227 extern struct list_head osc_shrink_list;
228 /** spin lock to protect osc_shrink_list */
229 extern spinlock_t osc_shrink_lock;
230 unsigned long osc_cache_shrink_count(struct shrinker *sk,
231 struct shrink_control *sc);
232 unsigned long osc_cache_shrink_scan(struct shrinker *sk,
233 struct shrink_control *sc);
234
235 #endif /* OSC_INTERNAL_H */