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) 2007, 2010, Oracle and/or its affiliates. All rights reserved. | |
28 | * Use is subject to license terms. | |
29 | * | |
30 | * Copyright (c) 2011, 2012, Intel Corporation. | |
31 | */ | |
32 | /* | |
33 | * This file is part of Lustre, http://www.lustre.org/ | |
34 | * Lustre is a trademark of Sun Microsystems, Inc. | |
35 | */ | |
36 | #ifndef __CLASS_OBD_H | |
37 | #define __CLASS_OBD_H | |
38 | ||
39 | ||
1accaadf GKH |
40 | #include "obd_support.h" |
41 | #include "lustre_import.h" | |
42 | #include "lustre_net.h" | |
43 | #include "obd.h" | |
44 | #include "lustre_lib.h" | |
45 | #include "lustre/lustre_idl.h" | |
46 | #include "lprocfs_status.h" | |
d7e09d03 | 47 | |
d7e09d03 PT |
48 | #define OBD_STATFS_NODELAY 0x0001 /* requests should be send without delay |
49 | * and resends for avoid deadlocks */ | |
50 | #define OBD_STATFS_FROM_CACHE 0x0002 /* the statfs callback should not update | |
51 | * obd_osfs_age */ | |
52 | #define OBD_STATFS_PTLRPCD 0x0004 /* requests will be sent via ptlrpcd | |
53 | * instead of a specific set. This | |
54 | * means that we cannot rely on the set | |
55 | * interpret routine to be called. | |
56 | * lov_statfs_fini() must thus be called | |
57 | * by the request interpret routine */ | |
58 | #define OBD_STATFS_FOR_MDT0 0x0008 /* The statfs is only for retrieving | |
59 | * information from MDT0. */ | |
60 | #define OBD_FL_PUNCH 0x00000001 /* To indicate it is punch operation */ | |
61 | ||
62 | /* OBD Device Declarations */ | |
63 | extern struct obd_device *obd_devs[MAX_OBD_DEVICES]; | |
64 | extern rwlock_t obd_dev_lock; | |
65 | ||
66 | /* OBD Operations Declarations */ | |
8150a97f JP |
67 | struct obd_device *class_conn2obd(struct lustre_handle *); |
68 | struct obd_device *class_exp2obd(struct obd_export *); | |
69 | int class_handle_ioctl(unsigned int cmd, unsigned long arg); | |
70 | int lustre_get_jobid(char *jobid); | |
d7e09d03 PT |
71 | |
72 | struct lu_device_type; | |
73 | ||
74 | /* genops.c */ | |
826ad46d | 75 | extern struct list_head obd_types; |
d7e09d03 PT |
76 | struct obd_export *class_conn2export(struct lustre_handle *); |
77 | int class_register_type(struct obd_ops *, struct md_ops *, | |
2962b440 | 78 | const char *nm, struct lu_device_type *ldt); |
d7e09d03 PT |
79 | int class_unregister_type(const char *nm); |
80 | ||
81 | struct obd_device *class_newdev(const char *type_name, const char *name); | |
82 | void class_release_dev(struct obd_device *obd); | |
83 | ||
84 | int class_name2dev(const char *name); | |
85 | struct obd_device *class_name2obd(const char *name); | |
86 | int class_uuid2dev(struct obd_uuid *uuid); | |
87 | struct obd_device *class_uuid2obd(struct obd_uuid *uuid); | |
88 | void class_obd_list(void); | |
aff9d8e8 GD |
89 | struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid, |
90 | const char *typ_name, | |
d7e09d03 | 91 | struct obd_uuid *grp_uuid); |
aff9d8e8 | 92 | struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid, |
d7e09d03 | 93 | int *next); |
aff9d8e8 | 94 | struct obd_device *class_num2obd(int num); |
d7e09d03 PT |
95 | int get_devices_count(void); |
96 | ||
97 | int class_notify_sptlrpc_conf(const char *fsname, int namelen); | |
98 | ||
99 | char *obd_export_nid2str(struct obd_export *exp); | |
100 | ||
101 | int obd_export_evict_by_nid(struct obd_device *obd, const char *nid); | |
102 | int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid); | |
103 | int obd_connect_flags2str(char *page, int count, __u64 flags, char *sep); | |
104 | ||
105 | int obd_zombie_impexp_init(void); | |
106 | void obd_zombie_impexp_stop(void); | |
107 | void obd_zombie_impexp_cull(void); | |
108 | void obd_zombie_barrier(void); | |
109 | void obd_exports_barrier(struct obd_device *obd); | |
110 | int kuc_len(int payload_len); | |
aff9d8e8 | 111 | struct kuc_hdr *kuc_ptr(void *p); |
d7e09d03 PT |
112 | int kuc_ispayload(void *p); |
113 | void *kuc_alloc(int payload_len, int transport, int type); | |
114 | void kuc_free(void *p, int payload_len); | |
115 | ||
116 | struct llog_handle; | |
117 | struct llog_rec_hdr; | |
118 | typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *, | |
119 | struct llog_rec_hdr *, void *); | |
120 | /* obd_config.c */ | |
121 | struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, | |
122 | const char *new_name); | |
123 | int class_process_config(struct lustre_cfg *lcfg); | |
124 | int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, | |
125 | struct lustre_cfg *lcfg, void *data); | |
126 | int class_attach(struct lustre_cfg *lcfg); | |
127 | int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg); | |
128 | int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg); | |
129 | int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg); | |
130 | struct obd_device *class_incref(struct obd_device *obd, | |
131 | const char *scope, const void *source); | |
132 | void class_decref(struct obd_device *obd, | |
133 | const char *scope, const void *source); | |
134 | void dump_exports(struct obd_device *obd, int locks); | |
135 | int class_config_llog_handler(const struct lu_env *env, | |
136 | struct llog_handle *handle, | |
137 | struct llog_rec_hdr *rec, void *data); | |
138 | int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg); | |
139 | int class_add_uuid(const char *uuid, __u64 nid); | |
140 | ||
141 | /*obdecho*/ | |
8150a97f | 142 | void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars); |
d7e09d03 PT |
143 | |
144 | #define CFG_F_START 0x01 /* Set when we start updating from a log */ | |
145 | #define CFG_F_MARKER 0x02 /* We are within a maker */ | |
146 | #define CFG_F_SKIP 0x04 /* We should ignore this cfg command */ | |
147 | #define CFG_F_COMPAT146 0x08 /* Allow old-style logs */ | |
148 | #define CFG_F_EXCLUDE 0x10 /* OST exclusion list */ | |
149 | ||
150 | /* Passed as data param to class_config_parse_llog */ | |
151 | struct config_llog_instance { | |
152 | char *cfg_obdname; | |
153 | void *cfg_instance; | |
154 | struct super_block *cfg_sb; | |
155 | struct obd_uuid cfg_uuid; | |
156 | llog_cb_t cfg_callback; | |
157 | int cfg_last_idx; /* for partial llog processing */ | |
158 | int cfg_flags; | |
159 | }; | |
160 | int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt, | |
161 | char *name, struct config_llog_instance *cfg); | |
162 | int class_config_dump_llog(const struct lu_env *env, struct llog_ctxt *ctxt, | |
163 | char *name, struct config_llog_instance *cfg); | |
164 | ||
165 | enum { | |
166 | CONFIG_T_CONFIG = 0, | |
167 | CONFIG_T_SPTLRPC = 1, | |
168 | CONFIG_T_RECOVER = 2, | |
7d4bae45 AB |
169 | CONFIG_T_PARAMS = 3, |
170 | CONFIG_T_MAX = 4 | |
d7e09d03 PT |
171 | }; |
172 | ||
7d4bae45 AB |
173 | #define PARAMS_FILENAME "params" |
174 | #define LCTL_UPCALL "lctl" | |
175 | ||
d7e09d03 PT |
176 | /* list of active configuration logs */ |
177 | struct config_llog_data { | |
178 | struct ldlm_res_id cld_resid; | |
179 | struct config_llog_instance cld_cfg; | |
180 | struct list_head cld_list_chain; | |
181 | atomic_t cld_refcount; | |
182 | struct config_llog_data *cld_sptlrpc;/* depended sptlrpc log */ | |
7d4bae45 AB |
183 | struct config_llog_data *cld_params; /* common parameters log */ |
184 | struct config_llog_data *cld_recover;/* imperative recover log */ | |
d7e09d03 PT |
185 | struct obd_export *cld_mgcexp; |
186 | struct mutex cld_lock; | |
187 | int cld_type; | |
188 | unsigned int cld_stopping:1, /* we were told to stop | |
189 | * watching */ | |
190 | cld_lostlock:1; /* lock not requeued */ | |
191 | char cld_logname[0]; | |
192 | }; | |
193 | ||
194 | struct lustre_profile { | |
195 | struct list_head lp_list; | |
196 | char *lp_profile; | |
197 | char *lp_dt; | |
198 | char *lp_md; | |
199 | }; | |
200 | ||
aff9d8e8 | 201 | struct lustre_profile *class_get_profile(const char *prof); |
d7e09d03 PT |
202 | void class_del_profile(const char *prof); |
203 | void class_del_profiles(void); | |
204 | ||
205 | #if LUSTRE_TRACKS_LOCK_EXP_REFS | |
206 | ||
207 | void __class_export_add_lock_ref(struct obd_export *, struct ldlm_lock *); | |
208 | void __class_export_del_lock_ref(struct obd_export *, struct ldlm_lock *); | |
209 | extern void (*class_export_dump_hook)(struct obd_export *); | |
210 | ||
211 | #else | |
212 | ||
a58a38ac GD |
213 | #define __class_export_add_lock_ref(exp, lock) do {} while (0) |
214 | #define __class_export_del_lock_ref(exp, lock) do {} while (0) | |
d7e09d03 PT |
215 | |
216 | #endif | |
217 | ||
28b9d6f1 SA |
218 | static inline void class_export_rpc_inc(struct obd_export *exp) |
219 | { | |
220 | atomic_inc(&(exp)->exp_rpc_count); | |
221 | CDEBUG(D_INFO, "RPC GETting export %p : new rpc_count %d\n", | |
222 | (exp), atomic_read(&(exp)->exp_rpc_count)); | |
223 | } | |
d7e09d03 | 224 | |
5fb0acb4 SA |
225 | static inline void class_export_rpc_dec(struct obd_export *exp) |
226 | { | |
227 | LASSERT_ATOMIC_POS(&exp->exp_rpc_count); | |
228 | atomic_dec(&(exp)->exp_rpc_count); | |
229 | CDEBUG(D_INFO, "RPC PUTting export %p : new rpc_count %d\n", | |
230 | (exp), atomic_read(&(exp)->exp_rpc_count)); | |
231 | } | |
d7e09d03 PT |
232 | |
233 | #define class_export_lock_get(exp, lock) \ | |
234 | ({ \ | |
235 | atomic_inc(&(exp)->exp_locks_count); \ | |
236 | __class_export_add_lock_ref(exp, lock); \ | |
237 | CDEBUG(D_INFO, "lock GETting export %p : new locks_count %d\n", \ | |
238 | (exp), atomic_read(&(exp)->exp_locks_count)); \ | |
239 | class_export_get(exp); \ | |
240 | }) | |
241 | ||
242 | #define class_export_lock_put(exp, lock) \ | |
243 | ({ \ | |
244 | LASSERT_ATOMIC_POS(&exp->exp_locks_count); \ | |
245 | atomic_dec(&(exp)->exp_locks_count); \ | |
246 | __class_export_del_lock_ref(exp, lock); \ | |
247 | CDEBUG(D_INFO, "lock PUTting export %p : new locks_count %d\n", \ | |
248 | (exp), atomic_read(&(exp)->exp_locks_count)); \ | |
249 | class_export_put(exp); \ | |
250 | }) | |
251 | ||
252 | #define class_export_cb_get(exp) \ | |
253 | ({ \ | |
254 | atomic_inc(&(exp)->exp_cb_count); \ | |
255 | CDEBUG(D_INFO, "callback GETting export %p : new cb_count %d\n",\ | |
256 | (exp), atomic_read(&(exp)->exp_cb_count)); \ | |
257 | class_export_get(exp); \ | |
258 | }) | |
259 | ||
260 | #define class_export_cb_put(exp) \ | |
261 | ({ \ | |
262 | LASSERT_ATOMIC_POS(&exp->exp_cb_count); \ | |
263 | atomic_dec(&(exp)->exp_cb_count); \ | |
264 | CDEBUG(D_INFO, "callback PUTting export %p : new cb_count %d\n",\ | |
265 | (exp), atomic_read(&(exp)->exp_cb_count)); \ | |
266 | class_export_put(exp); \ | |
267 | }) | |
268 | ||
269 | /* genops.c */ | |
270 | struct obd_export *class_export_get(struct obd_export *exp); | |
271 | void class_export_put(struct obd_export *exp); | |
272 | struct obd_export *class_new_export(struct obd_device *obddev, | |
273 | struct obd_uuid *cluuid); | |
274 | void class_unlink_export(struct obd_export *exp); | |
275 | ||
276 | struct obd_import *class_import_get(struct obd_import *); | |
277 | void class_import_put(struct obd_import *); | |
278 | struct obd_import *class_new_import(struct obd_device *obd); | |
279 | void class_destroy_import(struct obd_import *exp); | |
280 | ||
281 | struct obd_type *class_search_type(const char *name); | |
282 | struct obd_type *class_get_type(const char *name); | |
283 | void class_put_type(struct obd_type *type); | |
284 | int class_connect(struct lustre_handle *conn, struct obd_device *obd, | |
285 | struct obd_uuid *cluuid); | |
286 | int class_disconnect(struct obd_export *exp); | |
287 | void class_fail_export(struct obd_export *exp); | |
288 | int class_connected_export(struct obd_export *exp); | |
289 | void class_disconnect_exports(struct obd_device *obddev); | |
290 | int class_manual_cleanup(struct obd_device *obd); | |
291 | void class_disconnect_stale_exports(struct obd_device *, | |
292 | int (*test_export)(struct obd_export *)); | |
293 | static inline enum obd_option exp_flags_from_obd(struct obd_device *obd) | |
294 | { | |
295 | return ((obd->obd_fail ? OBD_OPT_FAILOVER : 0) | | |
296 | (obd->obd_force ? OBD_OPT_FORCE : 0) | | |
297 | (obd->obd_abort_recovery ? OBD_OPT_ABORT_RECOV : 0) | | |
298 | 0); | |
299 | } | |
300 | ||
616331c3 JH |
301 | struct inode; |
302 | struct lu_attr; | |
303 | struct obdo; | |
304 | void obdo_from_la(struct obdo *dst, struct lu_attr *la, __u64 valid); | |
305 | void la_from_obdo(struct lu_attr *la, struct obdo *dst, u32 valid); | |
306 | void obdo_refresh_inode(struct inode *dst, struct obdo *src, u32 valid); | |
307 | void obdo_to_inode(struct inode *dst, struct obdo *src, u32 valid); | |
d7e09d03 | 308 | |
21aef7d9 | 309 | void obdo_cpy_md(struct obdo *dst, struct obdo *src, u32 valid); |
d7e09d03 PT |
310 | void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj); |
311 | void obdo_from_iattr(struct obdo *oa, struct iattr *attr, | |
312 | unsigned int ia_valid); | |
21aef7d9 OD |
313 | void iattr_from_obdo(struct iattr *attr, struct obdo *oa, u32 valid); |
314 | void md_from_obdo(struct md_op_data *op_data, struct obdo *oa, u32 valid); | |
d7e09d03 PT |
315 | void obdo_from_md(struct obdo *oa, struct md_op_data *op_data, |
316 | unsigned int valid); | |
317 | ||
318 | void obdo_cpu_to_le(struct obdo *dobdo, struct obdo *sobdo); | |
319 | void obdo_le_to_cpu(struct obdo *dobdo, struct obdo *sobdo); | |
320 | ||
321 | #define OBT(dev) (dev)->obd_type | |
322 | #define OBP(dev, op) (dev)->obd_type->typ_dt_ops->o_ ## op | |
323 | #define MDP(dev, op) (dev)->obd_type->typ_md_ops->m_ ## op | |
324 | #define CTXTP(ctxt, op) (ctxt)->loc_logops->lop_##op | |
325 | ||
326 | /* Ensure obd_setup: used for cleanup which must be called | |
327 | while obd is stopping */ | |
4ca1b8fb AM |
328 | static inline int obd_check_dev(struct obd_device *obd) |
329 | { | |
330 | if (!obd) { | |
331 | CERROR("NULL device\n"); | |
332 | return -ENODEV; | |
333 | } | |
334 | return 0; | |
335 | } | |
336 | ||
d7e09d03 | 337 | /* ensure obd_setup and !obd_stopping */ |
f36b6553 AM |
338 | static inline int obd_check_dev_active(struct obd_device *obd) |
339 | { | |
340 | int rc; | |
341 | ||
342 | rc = obd_check_dev(obd); | |
343 | if (rc) | |
344 | return rc; | |
345 | if (!obd->obd_set_up || obd->obd_stopping) { | |
346 | CERROR("Device %d not setup\n", obd->obd_minor); | |
347 | return -ENODEV; | |
348 | } | |
349 | return rc; | |
350 | } | |
d7e09d03 | 351 | |
d7e09d03 PT |
352 | #define OBD_COUNTER_OFFSET(op) \ |
353 | ((offsetof(struct obd_ops, o_ ## op) - \ | |
354 | offsetof(struct obd_ops, o_iocontrol)) \ | |
355 | / sizeof(((struct obd_ops *)(0))->o_iocontrol)) | |
356 | ||
357 | #define OBD_COUNTER_INCREMENT(obdx, op) \ | |
358 | if ((obdx)->obd_stats != NULL) { \ | |
359 | unsigned int coffset; \ | |
360 | coffset = (unsigned int)((obdx)->obd_cntr_base) + \ | |
361 | OBD_COUNTER_OFFSET(op); \ | |
362 | LASSERT(coffset < (obdx)->obd_stats->ls_num); \ | |
363 | lprocfs_counter_incr((obdx)->obd_stats, coffset); \ | |
364 | } | |
365 | ||
366 | #define EXP_COUNTER_INCREMENT(export, op) \ | |
367 | if ((export)->exp_obd->obd_stats != NULL) { \ | |
368 | unsigned int coffset; \ | |
369 | coffset = (unsigned int)((export)->exp_obd->obd_cntr_base) + \ | |
370 | OBD_COUNTER_OFFSET(op); \ | |
371 | LASSERT(coffset < (export)->exp_obd->obd_stats->ls_num); \ | |
372 | lprocfs_counter_incr((export)->exp_obd->obd_stats, coffset); \ | |
d7e09d03 PT |
373 | } |
374 | ||
375 | #define MD_COUNTER_OFFSET(op) \ | |
376 | ((offsetof(struct md_ops, m_ ## op) - \ | |
377 | offsetof(struct md_ops, m_getstatus)) \ | |
378 | / sizeof(((struct md_ops *)(0))->m_getstatus)) | |
379 | ||
380 | #define MD_COUNTER_INCREMENT(obdx, op) \ | |
381 | if ((obd)->md_stats != NULL) { \ | |
382 | unsigned int coffset; \ | |
383 | coffset = (unsigned int)((obdx)->md_cntr_base) + \ | |
384 | MD_COUNTER_OFFSET(op); \ | |
385 | LASSERT(coffset < (obdx)->md_stats->ls_num); \ | |
386 | lprocfs_counter_incr((obdx)->md_stats, coffset); \ | |
387 | } | |
388 | ||
389 | #define EXP_MD_COUNTER_INCREMENT(export, op) \ | |
390 | if ((export)->exp_obd->obd_stats != NULL) { \ | |
391 | unsigned int coffset; \ | |
392 | coffset = (unsigned int)((export)->exp_obd->md_cntr_base) + \ | |
393 | MD_COUNTER_OFFSET(op); \ | |
394 | LASSERT(coffset < (export)->exp_obd->md_stats->ls_num); \ | |
395 | lprocfs_counter_incr((export)->exp_obd->md_stats, coffset); \ | |
396 | if ((export)->exp_md_stats != NULL) \ | |
397 | lprocfs_counter_incr( \ | |
398 | (export)->exp_md_stats, coffset); \ | |
399 | } | |
400 | ||
d7e09d03 | 401 | |
d7e09d03 PT |
402 | #define OBD_CHECK_MD_OP(obd, op, err) \ |
403 | do { \ | |
404 | if (!OBT(obd) || !MDP((obd), op)) { \ | |
405 | if (err) \ | |
406 | CERROR("md_" #op ": dev %s/%d no operation\n", \ | |
407 | obd->obd_name, obd->obd_minor); \ | |
0a3bdb00 | 408 | return err; \ |
d7e09d03 PT |
409 | } \ |
410 | } while (0) | |
411 | ||
412 | #define EXP_CHECK_MD_OP(exp, op) \ | |
413 | do { \ | |
414 | if ((exp) == NULL) { \ | |
415 | CERROR("obd_" #op ": NULL export\n"); \ | |
0a3bdb00 | 416 | return -ENODEV; \ |
d7e09d03 PT |
417 | } \ |
418 | if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ | |
419 | CERROR("obd_" #op ": cleaned up obd\n"); \ | |
0a3bdb00 | 420 | return -EOPNOTSUPP; \ |
d7e09d03 PT |
421 | } \ |
422 | if (!OBT((exp)->exp_obd) || !MDP((exp)->exp_obd, op)) { \ | |
423 | CERROR("obd_" #op ": dev %s/%d no operation\n", \ | |
424 | (exp)->exp_obd->obd_name, \ | |
425 | (exp)->exp_obd->obd_minor); \ | |
0a3bdb00 | 426 | return -EOPNOTSUPP; \ |
d7e09d03 PT |
427 | } \ |
428 | } while (0) | |
429 | ||
430 | ||
431 | #define OBD_CHECK_DT_OP(obd, op, err) \ | |
432 | do { \ | |
433 | if (!OBT(obd) || !OBP((obd), op)) { \ | |
434 | if (err) \ | |
435 | CERROR("obd_" #op ": dev %d no operation\n", \ | |
436 | obd->obd_minor); \ | |
0a3bdb00 | 437 | return err; \ |
d7e09d03 PT |
438 | } \ |
439 | } while (0) | |
440 | ||
441 | #define EXP_CHECK_DT_OP(exp, op) \ | |
442 | do { \ | |
443 | if ((exp) == NULL) { \ | |
444 | CERROR("obd_" #op ": NULL export\n"); \ | |
0a3bdb00 | 445 | return -ENODEV; \ |
d7e09d03 PT |
446 | } \ |
447 | if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ | |
448 | CERROR("obd_" #op ": cleaned up obd\n"); \ | |
0a3bdb00 | 449 | return -EOPNOTSUPP; \ |
d7e09d03 PT |
450 | } \ |
451 | if (!OBT((exp)->exp_obd) || !OBP((exp)->exp_obd, op)) { \ | |
452 | CERROR("obd_" #op ": dev %d no operation\n", \ | |
453 | (exp)->exp_obd->obd_minor); \ | |
0a3bdb00 | 454 | return -EOPNOTSUPP; \ |
d7e09d03 PT |
455 | } \ |
456 | } while (0) | |
457 | ||
458 | #define CTXT_CHECK_OP(ctxt, op, err) \ | |
459 | do { \ | |
460 | if (!OBT(ctxt->loc_obd) || !CTXTP((ctxt), op)) { \ | |
461 | if (err) \ | |
462 | CERROR("lop_" #op ": dev %d no operation\n", \ | |
463 | ctxt->loc_obd->obd_minor); \ | |
0a3bdb00 | 464 | return err; \ |
d7e09d03 PT |
465 | } \ |
466 | } while (0) | |
467 | ||
468 | static inline int class_devno_max(void) | |
469 | { | |
470 | return MAX_OBD_DEVICES; | |
471 | } | |
472 | ||
473 | static inline int obd_get_info(const struct lu_env *env, | |
474 | struct obd_export *exp, __u32 keylen, | |
475 | void *key, __u32 *vallen, void *val, | |
476 | struct lov_stripe_md *lsm) | |
477 | { | |
478 | int rc; | |
d7e09d03 PT |
479 | |
480 | EXP_CHECK_DT_OP(exp, get_info); | |
481 | EXP_COUNTER_INCREMENT(exp, get_info); | |
482 | ||
483 | rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val, | |
484 | lsm); | |
0a3bdb00 | 485 | return rc; |
d7e09d03 PT |
486 | } |
487 | ||
488 | static inline int obd_set_info_async(const struct lu_env *env, | |
21aef7d9 OD |
489 | struct obd_export *exp, u32 keylen, |
490 | void *key, u32 vallen, void *val, | |
d7e09d03 PT |
491 | struct ptlrpc_request_set *set) |
492 | { | |
493 | int rc; | |
d7e09d03 PT |
494 | |
495 | EXP_CHECK_DT_OP(exp, set_info_async); | |
496 | EXP_COUNTER_INCREMENT(exp, set_info_async); | |
497 | ||
498 | rc = OBP(exp->exp_obd, set_info_async)(env, exp, keylen, key, vallen, | |
499 | val, set); | |
0a3bdb00 | 500 | return rc; |
d7e09d03 PT |
501 | } |
502 | ||
503 | /* | |
504 | * obd-lu integration. | |
505 | * | |
506 | * Functionality is being moved into new lu_device-based layering, but some | |
507 | * pieces of configuration process are still based on obd devices. | |
508 | * | |
509 | * Specifically, lu_device_type_operations::ldto_device_alloc() methods fully | |
510 | * subsume ->o_setup() methods of obd devices they replace. The same for | |
511 | * lu_device_operations::ldo_process_config() and ->o_process_config(). As a | |
512 | * result, obd_setup() and obd_process_config() branch and call one XOR | |
513 | * another. | |
514 | * | |
515 | * Yet neither lu_device_type_operations::ldto_device_fini() nor | |
516 | * lu_device_type_operations::ldto_device_free() fully implement the | |
517 | * functionality of ->o_precleanup() and ->o_cleanup() they override. Hence, | |
518 | * obd_precleanup() and obd_cleanup() call both lu_device and obd operations. | |
519 | */ | |
520 | ||
521 | #define DECLARE_LU_VARS(ldt, d) \ | |
522 | struct lu_device_type *ldt; \ | |
523 | struct lu_device *d | |
524 | ||
525 | static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) | |
526 | { | |
527 | int rc; | |
528 | DECLARE_LU_VARS(ldt, d); | |
d7e09d03 PT |
529 | |
530 | ldt = obd->obd_type->typ_lu; | |
531 | if (ldt != NULL) { | |
532 | struct lu_context session_ctx; | |
533 | struct lu_env env; | |
534 | lu_context_init(&session_ctx, LCT_SESSION); | |
535 | session_ctx.lc_thread = NULL; | |
536 | lu_context_enter(&session_ctx); | |
537 | ||
538 | rc = lu_env_init(&env, ldt->ldt_ctx_tags); | |
539 | if (rc == 0) { | |
540 | env.le_ses = &session_ctx; | |
541 | d = ldt->ldt_ops->ldto_device_alloc(&env, ldt, cfg); | |
542 | lu_env_fini(&env); | |
543 | if (!IS_ERR(d)) { | |
544 | obd->obd_lu_dev = d; | |
545 | d->ld_obd = obd; | |
546 | rc = 0; | |
547 | } else | |
548 | rc = PTR_ERR(d); | |
549 | } | |
550 | lu_context_exit(&session_ctx); | |
551 | lu_context_fini(&session_ctx); | |
552 | ||
553 | } else { | |
554 | OBD_CHECK_DT_OP(obd, setup, -EOPNOTSUPP); | |
555 | OBD_COUNTER_INCREMENT(obd, setup); | |
556 | rc = OBP(obd, setup)(obd, cfg); | |
557 | } | |
0a3bdb00 | 558 | return rc; |
d7e09d03 PT |
559 | } |
560 | ||
561 | static inline int obd_precleanup(struct obd_device *obd, | |
562 | enum obd_cleanup_stage cleanup_stage) | |
563 | { | |
564 | int rc; | |
565 | DECLARE_LU_VARS(ldt, d); | |
d7e09d03 | 566 | |
4ca1b8fb AM |
567 | rc = obd_check_dev(obd); |
568 | if (rc) | |
569 | return rc; | |
d7e09d03 PT |
570 | ldt = obd->obd_type->typ_lu; |
571 | d = obd->obd_lu_dev; | |
572 | if (ldt != NULL && d != NULL) { | |
573 | if (cleanup_stage == OBD_CLEANUP_EXPORTS) { | |
574 | struct lu_env env; | |
575 | ||
576 | rc = lu_env_init(&env, ldt->ldt_ctx_tags); | |
577 | if (rc == 0) { | |
578 | ldt->ldt_ops->ldto_device_fini(&env, d); | |
579 | lu_env_fini(&env); | |
580 | } | |
581 | } | |
582 | } | |
583 | OBD_CHECK_DT_OP(obd, precleanup, 0); | |
584 | OBD_COUNTER_INCREMENT(obd, precleanup); | |
585 | ||
586 | rc = OBP(obd, precleanup)(obd, cleanup_stage); | |
0a3bdb00 | 587 | return rc; |
d7e09d03 PT |
588 | } |
589 | ||
590 | static inline int obd_cleanup(struct obd_device *obd) | |
591 | { | |
592 | int rc; | |
593 | DECLARE_LU_VARS(ldt, d); | |
d7e09d03 | 594 | |
4ca1b8fb AM |
595 | rc = obd_check_dev(obd); |
596 | if (rc) | |
597 | return rc; | |
d7e09d03 PT |
598 | |
599 | ldt = obd->obd_type->typ_lu; | |
600 | d = obd->obd_lu_dev; | |
601 | if (ldt != NULL && d != NULL) { | |
602 | struct lu_env env; | |
603 | ||
604 | rc = lu_env_init(&env, ldt->ldt_ctx_tags); | |
605 | if (rc == 0) { | |
606 | ldt->ldt_ops->ldto_device_free(&env, d); | |
607 | lu_env_fini(&env); | |
608 | obd->obd_lu_dev = NULL; | |
609 | } | |
610 | } | |
611 | OBD_CHECK_DT_OP(obd, cleanup, 0); | |
612 | OBD_COUNTER_INCREMENT(obd, cleanup); | |
613 | ||
614 | rc = OBP(obd, cleanup)(obd); | |
0a3bdb00 | 615 | return rc; |
d7e09d03 PT |
616 | } |
617 | ||
618 | static inline void obd_cleanup_client_import(struct obd_device *obd) | |
619 | { | |
d7e09d03 PT |
620 | /* If we set up but never connected, the |
621 | client import will not have been cleaned. */ | |
622 | down_write(&obd->u.cli.cl_sem); | |
623 | if (obd->u.cli.cl_import) { | |
624 | struct obd_import *imp; | |
625 | imp = obd->u.cli.cl_import; | |
626 | CDEBUG(D_CONFIG, "%s: client import never connected\n", | |
627 | obd->obd_name); | |
628 | ptlrpc_invalidate_import(imp); | |
629 | if (imp->imp_rq_pool) { | |
630 | ptlrpc_free_rq_pool(imp->imp_rq_pool); | |
631 | imp->imp_rq_pool = NULL; | |
632 | } | |
633 | client_destroy_import(imp); | |
634 | obd->u.cli.cl_import = NULL; | |
635 | } | |
636 | up_write(&obd->u.cli.cl_sem); | |
d7e09d03 PT |
637 | } |
638 | ||
639 | static inline int | |
640 | obd_process_config(struct obd_device *obd, int datalen, void *data) | |
641 | { | |
642 | int rc; | |
643 | DECLARE_LU_VARS(ldt, d); | |
d7e09d03 | 644 | |
4ca1b8fb AM |
645 | rc = obd_check_dev(obd); |
646 | if (rc) | |
647 | return rc; | |
d7e09d03 PT |
648 | |
649 | obd->obd_process_conf = 1; | |
650 | ldt = obd->obd_type->typ_lu; | |
651 | d = obd->obd_lu_dev; | |
652 | if (ldt != NULL && d != NULL) { | |
653 | struct lu_env env; | |
654 | ||
655 | rc = lu_env_init(&env, ldt->ldt_ctx_tags); | |
656 | if (rc == 0) { | |
657 | rc = d->ld_ops->ldo_process_config(&env, d, data); | |
658 | lu_env_fini(&env); | |
659 | } | |
660 | } else { | |
661 | OBD_CHECK_DT_OP(obd, process_config, -EOPNOTSUPP); | |
662 | rc = OBP(obd, process_config)(obd, datalen, data); | |
663 | } | |
664 | OBD_COUNTER_INCREMENT(obd, process_config); | |
665 | obd->obd_process_conf = 0; | |
666 | ||
0a3bdb00 | 667 | return rc; |
d7e09d03 PT |
668 | } |
669 | ||
670 | /* Pack an in-memory MD struct for storage on disk. | |
671 | * Returns +ve size of packed MD (0 for free), or -ve error. | |
672 | * | |
673 | * If @disk_tgt == NULL, MD size is returned (max size if @mem_src == NULL). | |
674 | * If @*disk_tgt != NULL and @mem_src == NULL, @*disk_tgt will be freed. | |
675 | * If @*disk_tgt == NULL, it will be allocated | |
676 | */ | |
677 | static inline int obd_packmd(struct obd_export *exp, | |
678 | struct lov_mds_md **disk_tgt, | |
679 | struct lov_stripe_md *mem_src) | |
680 | { | |
681 | int rc; | |
d7e09d03 PT |
682 | |
683 | EXP_CHECK_DT_OP(exp, packmd); | |
684 | EXP_COUNTER_INCREMENT(exp, packmd); | |
685 | ||
686 | rc = OBP(exp->exp_obd, packmd)(exp, disk_tgt, mem_src); | |
0a3bdb00 | 687 | return rc; |
d7e09d03 PT |
688 | } |
689 | ||
690 | static inline int obd_size_diskmd(struct obd_export *exp, | |
691 | struct lov_stripe_md *mem_src) | |
692 | { | |
693 | return obd_packmd(exp, NULL, mem_src); | |
694 | } | |
695 | ||
d7e09d03 PT |
696 | static inline int obd_free_diskmd(struct obd_export *exp, |
697 | struct lov_mds_md **disk_tgt) | |
698 | { | |
699 | LASSERT(disk_tgt); | |
700 | LASSERT(*disk_tgt); | |
701 | /* | |
702 | * LU-2590, for caller's convenience, *disk_tgt could be host | |
703 | * endianness, it needs swab to LE if necessary, while just | |
704 | * lov_mds_md header needs it for figuring out how much memory | |
705 | * needs to be freed. | |
706 | */ | |
707 | if ((cpu_to_le32(LOV_MAGIC) != LOV_MAGIC) && | |
708 | (((*disk_tgt)->lmm_magic == LOV_MAGIC_V1) || | |
709 | ((*disk_tgt)->lmm_magic == LOV_MAGIC_V3))) | |
710 | lustre_swab_lov_mds_md(*disk_tgt); | |
711 | return obd_packmd(exp, disk_tgt, NULL); | |
712 | } | |
713 | ||
714 | /* Unpack an MD struct from disk to in-memory format. | |
715 | * Returns +ve size of unpacked MD (0 for free), or -ve error. | |
716 | * | |
717 | * If @mem_tgt == NULL, MD size is returned (max size if @disk_src == NULL). | |
718 | * If @*mem_tgt != NULL and @disk_src == NULL, @*mem_tgt will be freed. | |
719 | * If @*mem_tgt == NULL, it will be allocated | |
720 | */ | |
721 | static inline int obd_unpackmd(struct obd_export *exp, | |
722 | struct lov_stripe_md **mem_tgt, | |
723 | struct lov_mds_md *disk_src, | |
724 | int disk_len) | |
725 | { | |
726 | int rc; | |
d7e09d03 PT |
727 | |
728 | EXP_CHECK_DT_OP(exp, unpackmd); | |
729 | EXP_COUNTER_INCREMENT(exp, unpackmd); | |
730 | ||
731 | rc = OBP(exp->exp_obd, unpackmd)(exp, mem_tgt, disk_src, disk_len); | |
0a3bdb00 | 732 | return rc; |
d7e09d03 PT |
733 | } |
734 | ||
735 | /* helper functions */ | |
736 | static inline int obd_alloc_memmd(struct obd_export *exp, | |
737 | struct lov_stripe_md **mem_tgt) | |
738 | { | |
739 | LASSERT(mem_tgt); | |
740 | LASSERT(*mem_tgt == NULL); | |
741 | return obd_unpackmd(exp, mem_tgt, NULL, 0); | |
742 | } | |
743 | ||
744 | static inline int obd_free_memmd(struct obd_export *exp, | |
745 | struct lov_stripe_md **mem_tgt) | |
746 | { | |
747 | int rc; | |
748 | ||
749 | LASSERT(mem_tgt); | |
750 | LASSERT(*mem_tgt); | |
751 | rc = obd_unpackmd(exp, mem_tgt, NULL, 0); | |
752 | *mem_tgt = NULL; | |
753 | return rc; | |
754 | } | |
755 | ||
d7e09d03 PT |
756 | static inline int obd_create(const struct lu_env *env, struct obd_export *exp, |
757 | struct obdo *obdo, struct lov_stripe_md **ea, | |
758 | struct obd_trans_info *oti) | |
759 | { | |
760 | int rc; | |
d7e09d03 PT |
761 | |
762 | EXP_CHECK_DT_OP(exp, create); | |
763 | EXP_COUNTER_INCREMENT(exp, create); | |
764 | ||
765 | rc = OBP(exp->exp_obd, create)(env, exp, obdo, ea, oti); | |
0a3bdb00 | 766 | return rc; |
d7e09d03 PT |
767 | } |
768 | ||
769 | static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp, | |
770 | struct obdo *obdo, struct lov_stripe_md *ea, | |
771 | struct obd_trans_info *oti, | |
772 | struct obd_export *md_exp, void *capa) | |
773 | { | |
774 | int rc; | |
d7e09d03 PT |
775 | |
776 | EXP_CHECK_DT_OP(exp, destroy); | |
777 | EXP_COUNTER_INCREMENT(exp, destroy); | |
778 | ||
779 | rc = OBP(exp->exp_obd, destroy)(env, exp, obdo, ea, oti, md_exp, capa); | |
0a3bdb00 | 780 | return rc; |
d7e09d03 PT |
781 | } |
782 | ||
783 | static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp, | |
784 | struct obd_info *oinfo) | |
785 | { | |
786 | int rc; | |
d7e09d03 PT |
787 | |
788 | EXP_CHECK_DT_OP(exp, getattr); | |
789 | EXP_COUNTER_INCREMENT(exp, getattr); | |
790 | ||
791 | rc = OBP(exp->exp_obd, getattr)(env, exp, oinfo); | |
0a3bdb00 | 792 | return rc; |
d7e09d03 PT |
793 | } |
794 | ||
795 | static inline int obd_getattr_async(struct obd_export *exp, | |
796 | struct obd_info *oinfo, | |
797 | struct ptlrpc_request_set *set) | |
798 | { | |
799 | int rc; | |
d7e09d03 PT |
800 | |
801 | EXP_CHECK_DT_OP(exp, getattr_async); | |
802 | EXP_COUNTER_INCREMENT(exp, getattr_async); | |
803 | ||
804 | rc = OBP(exp->exp_obd, getattr_async)(exp, oinfo, set); | |
0a3bdb00 | 805 | return rc; |
d7e09d03 PT |
806 | } |
807 | ||
808 | static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp, | |
809 | struct obd_info *oinfo, | |
810 | struct obd_trans_info *oti) | |
811 | { | |
812 | int rc; | |
d7e09d03 PT |
813 | |
814 | EXP_CHECK_DT_OP(exp, setattr); | |
815 | EXP_COUNTER_INCREMENT(exp, setattr); | |
816 | ||
817 | rc = OBP(exp->exp_obd, setattr)(env, exp, oinfo, oti); | |
0a3bdb00 | 818 | return rc; |
d7e09d03 PT |
819 | } |
820 | ||
821 | /* This performs all the requests set init/wait/destroy actions. */ | |
822 | static inline int obd_setattr_rqset(struct obd_export *exp, | |
823 | struct obd_info *oinfo, | |
824 | struct obd_trans_info *oti) | |
825 | { | |
826 | struct ptlrpc_request_set *set = NULL; | |
827 | int rc; | |
d7e09d03 PT |
828 | |
829 | EXP_CHECK_DT_OP(exp, setattr_async); | |
830 | EXP_COUNTER_INCREMENT(exp, setattr_async); | |
831 | ||
832 | set = ptlrpc_prep_set(); | |
833 | if (set == NULL) | |
0a3bdb00 | 834 | return -ENOMEM; |
d7e09d03 PT |
835 | |
836 | rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set); | |
837 | if (rc == 0) | |
838 | rc = ptlrpc_set_wait(set); | |
839 | ptlrpc_set_destroy(set); | |
0a3bdb00 | 840 | return rc; |
d7e09d03 PT |
841 | } |
842 | ||
843 | /* This adds all the requests into @set if @set != NULL, otherwise | |
844 | all requests are sent asynchronously without waiting for response. */ | |
845 | static inline int obd_setattr_async(struct obd_export *exp, | |
846 | struct obd_info *oinfo, | |
847 | struct obd_trans_info *oti, | |
848 | struct ptlrpc_request_set *set) | |
849 | { | |
850 | int rc; | |
d7e09d03 PT |
851 | |
852 | EXP_CHECK_DT_OP(exp, setattr_async); | |
853 | EXP_COUNTER_INCREMENT(exp, setattr_async); | |
854 | ||
855 | rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set); | |
0a3bdb00 | 856 | return rc; |
d7e09d03 PT |
857 | } |
858 | ||
859 | static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid, | |
860 | int priority) | |
861 | { | |
862 | struct obd_device *obd = imp->imp_obd; | |
863 | int rc; | |
d7e09d03 | 864 | |
f36b6553 AM |
865 | rc = obd_check_dev_active(obd); |
866 | if (rc) | |
867 | return rc; | |
d7e09d03 PT |
868 | OBD_CHECK_DT_OP(obd, add_conn, -EOPNOTSUPP); |
869 | OBD_COUNTER_INCREMENT(obd, add_conn); | |
870 | ||
871 | rc = OBP(obd, add_conn)(imp, uuid, priority); | |
0a3bdb00 | 872 | return rc; |
d7e09d03 PT |
873 | } |
874 | ||
875 | static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid) | |
876 | { | |
877 | struct obd_device *obd = imp->imp_obd; | |
878 | int rc; | |
d7e09d03 | 879 | |
f36b6553 AM |
880 | rc = obd_check_dev_active(obd); |
881 | if (rc) | |
882 | return rc; | |
d7e09d03 PT |
883 | OBD_CHECK_DT_OP(obd, del_conn, -EOPNOTSUPP); |
884 | OBD_COUNTER_INCREMENT(obd, del_conn); | |
885 | ||
886 | rc = OBP(obd, del_conn)(imp, uuid); | |
0a3bdb00 | 887 | return rc; |
d7e09d03 PT |
888 | } |
889 | ||
890 | static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp) | |
891 | { | |
892 | struct obd_uuid *uuid; | |
d7e09d03 PT |
893 | |
894 | OBD_CHECK_DT_OP(exp->exp_obd, get_uuid, NULL); | |
895 | EXP_COUNTER_INCREMENT(exp, get_uuid); | |
896 | ||
897 | uuid = OBP(exp->exp_obd, get_uuid)(exp); | |
0a3bdb00 | 898 | return uuid; |
d7e09d03 PT |
899 | } |
900 | ||
901 | /** Create a new /a exp on device /a obd for the uuid /a cluuid | |
902 | * @param exp New export handle | |
903 | * @param d Connect data, supported flags are set, flags also understood | |
904 | * by obd are returned. | |
905 | */ | |
906 | static inline int obd_connect(const struct lu_env *env, | |
1d8cb70c | 907 | struct obd_export **exp, struct obd_device *obd, |
d7e09d03 PT |
908 | struct obd_uuid *cluuid, |
909 | struct obd_connect_data *data, | |
910 | void *localdata) | |
911 | { | |
912 | int rc; | |
913 | __u64 ocf = data ? data->ocd_connect_flags : 0; /* for post-condition | |
914 | * check */ | |
d7e09d03 | 915 | |
f36b6553 AM |
916 | rc = obd_check_dev_active(obd); |
917 | if (rc) | |
918 | return rc; | |
d7e09d03 PT |
919 | OBD_CHECK_DT_OP(obd, connect, -EOPNOTSUPP); |
920 | OBD_COUNTER_INCREMENT(obd, connect); | |
921 | ||
922 | rc = OBP(obd, connect)(env, exp, obd, cluuid, data, localdata); | |
923 | /* check that only subset is granted */ | |
924 | LASSERT(ergo(data != NULL, (data->ocd_connect_flags & ocf) == | |
925 | data->ocd_connect_flags)); | |
0a3bdb00 | 926 | return rc; |
d7e09d03 PT |
927 | } |
928 | ||
929 | static inline int obd_reconnect(const struct lu_env *env, | |
930 | struct obd_export *exp, | |
931 | struct obd_device *obd, | |
932 | struct obd_uuid *cluuid, | |
933 | struct obd_connect_data *d, | |
934 | void *localdata) | |
935 | { | |
936 | int rc; | |
937 | __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition | |
938 | * check */ | |
939 | ||
f36b6553 AM |
940 | rc = obd_check_dev_active(obd); |
941 | if (rc) | |
942 | return rc; | |
d7e09d03 PT |
943 | OBD_CHECK_DT_OP(obd, reconnect, 0); |
944 | OBD_COUNTER_INCREMENT(obd, reconnect); | |
945 | ||
946 | rc = OBP(obd, reconnect)(env, exp, obd, cluuid, d, localdata); | |
947 | /* check that only subset is granted */ | |
948 | LASSERT(ergo(d != NULL, | |
949 | (d->ocd_connect_flags & ocf) == d->ocd_connect_flags)); | |
0a3bdb00 | 950 | return rc; |
d7e09d03 PT |
951 | } |
952 | ||
953 | static inline int obd_disconnect(struct obd_export *exp) | |
954 | { | |
955 | int rc; | |
d7e09d03 PT |
956 | |
957 | EXP_CHECK_DT_OP(exp, disconnect); | |
958 | EXP_COUNTER_INCREMENT(exp, disconnect); | |
959 | ||
960 | rc = OBP(exp->exp_obd, disconnect)(exp); | |
0a3bdb00 | 961 | return rc; |
d7e09d03 PT |
962 | } |
963 | ||
964 | static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp, | |
965 | enum lu_cli_type type) | |
966 | { | |
967 | int rc; | |
d7e09d03 PT |
968 | |
969 | OBD_CHECK_DT_OP(obd, fid_init, 0); | |
970 | OBD_COUNTER_INCREMENT(obd, fid_init); | |
971 | ||
972 | rc = OBP(obd, fid_init)(obd, exp, type); | |
0a3bdb00 | 973 | return rc; |
d7e09d03 PT |
974 | } |
975 | ||
976 | static inline int obd_fid_fini(struct obd_device *obd) | |
977 | { | |
978 | int rc; | |
d7e09d03 PT |
979 | |
980 | OBD_CHECK_DT_OP(obd, fid_fini, 0); | |
981 | OBD_COUNTER_INCREMENT(obd, fid_fini); | |
982 | ||
983 | rc = OBP(obd, fid_fini)(obd); | |
0a3bdb00 | 984 | return rc; |
d7e09d03 PT |
985 | } |
986 | ||
987 | static inline int obd_fid_alloc(struct obd_export *exp, | |
988 | struct lu_fid *fid, | |
989 | struct md_op_data *op_data) | |
990 | { | |
991 | int rc; | |
d7e09d03 PT |
992 | |
993 | EXP_CHECK_DT_OP(exp, fid_alloc); | |
994 | EXP_COUNTER_INCREMENT(exp, fid_alloc); | |
995 | ||
996 | rc = OBP(exp->exp_obd, fid_alloc)(exp, fid, op_data); | |
0a3bdb00 | 997 | return rc; |
d7e09d03 PT |
998 | } |
999 | ||
d7e09d03 PT |
1000 | static inline int obd_pool_new(struct obd_device *obd, char *poolname) |
1001 | { | |
1002 | int rc; | |
d7e09d03 PT |
1003 | |
1004 | OBD_CHECK_DT_OP(obd, pool_new, -EOPNOTSUPP); | |
1005 | OBD_COUNTER_INCREMENT(obd, pool_new); | |
1006 | ||
1007 | rc = OBP(obd, pool_new)(obd, poolname); | |
0a3bdb00 | 1008 | return rc; |
d7e09d03 PT |
1009 | } |
1010 | ||
1011 | static inline int obd_pool_del(struct obd_device *obd, char *poolname) | |
1012 | { | |
1013 | int rc; | |
d7e09d03 PT |
1014 | |
1015 | OBD_CHECK_DT_OP(obd, pool_del, -EOPNOTSUPP); | |
1016 | OBD_COUNTER_INCREMENT(obd, pool_del); | |
1017 | ||
1018 | rc = OBP(obd, pool_del)(obd, poolname); | |
0a3bdb00 | 1019 | return rc; |
d7e09d03 PT |
1020 | } |
1021 | ||
1022 | static inline int obd_pool_add(struct obd_device *obd, char *poolname, char *ostname) | |
1023 | { | |
1024 | int rc; | |
d7e09d03 PT |
1025 | |
1026 | OBD_CHECK_DT_OP(obd, pool_add, -EOPNOTSUPP); | |
1027 | OBD_COUNTER_INCREMENT(obd, pool_add); | |
1028 | ||
1029 | rc = OBP(obd, pool_add)(obd, poolname, ostname); | |
0a3bdb00 | 1030 | return rc; |
d7e09d03 PT |
1031 | } |
1032 | ||
1033 | static inline int obd_pool_rem(struct obd_device *obd, char *poolname, char *ostname) | |
1034 | { | |
1035 | int rc; | |
d7e09d03 PT |
1036 | |
1037 | OBD_CHECK_DT_OP(obd, pool_rem, -EOPNOTSUPP); | |
1038 | OBD_COUNTER_INCREMENT(obd, pool_rem); | |
1039 | ||
1040 | rc = OBP(obd, pool_rem)(obd, poolname, ostname); | |
0a3bdb00 | 1041 | return rc; |
d7e09d03 PT |
1042 | } |
1043 | ||
1044 | static inline void obd_getref(struct obd_device *obd) | |
1045 | { | |
d7e09d03 PT |
1046 | if (OBT(obd) && OBP(obd, getref)) { |
1047 | OBD_COUNTER_INCREMENT(obd, getref); | |
1048 | OBP(obd, getref)(obd); | |
1049 | } | |
d7e09d03 PT |
1050 | } |
1051 | ||
1052 | static inline void obd_putref(struct obd_device *obd) | |
1053 | { | |
d7e09d03 PT |
1054 | if (OBT(obd) && OBP(obd, putref)) { |
1055 | OBD_COUNTER_INCREMENT(obd, putref); | |
1056 | OBP(obd, putref)(obd); | |
1057 | } | |
d7e09d03 PT |
1058 | } |
1059 | ||
1060 | static inline int obd_init_export(struct obd_export *exp) | |
1061 | { | |
1062 | int rc = 0; | |
1063 | ||
d7e09d03 PT |
1064 | if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && |
1065 | OBP((exp)->exp_obd, init_export)) | |
1066 | rc = OBP(exp->exp_obd, init_export)(exp); | |
0a3bdb00 | 1067 | return rc; |
d7e09d03 PT |
1068 | } |
1069 | ||
1070 | static inline int obd_destroy_export(struct obd_export *exp) | |
1071 | { | |
d7e09d03 PT |
1072 | if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && |
1073 | OBP((exp)->exp_obd, destroy_export)) | |
1074 | OBP(exp->exp_obd, destroy_export)(exp); | |
0a3bdb00 | 1075 | return 0; |
d7e09d03 PT |
1076 | } |
1077 | ||
d7e09d03 PT |
1078 | /* @max_age is the oldest time in jiffies that we accept using a cached data. |
1079 | * If the cache is older than @max_age we will get a new value from the | |
1080 | * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. */ | |
1081 | static inline int obd_statfs_async(struct obd_export *exp, | |
1082 | struct obd_info *oinfo, | |
1083 | __u64 max_age, | |
1084 | struct ptlrpc_request_set *rqset) | |
1085 | { | |
1086 | int rc = 0; | |
1087 | struct obd_device *obd; | |
d7e09d03 PT |
1088 | |
1089 | if (exp == NULL || exp->exp_obd == NULL) | |
0a3bdb00 | 1090 | return -EINVAL; |
d7e09d03 PT |
1091 | |
1092 | obd = exp->exp_obd; | |
1093 | OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); | |
1094 | OBD_COUNTER_INCREMENT(obd, statfs); | |
1095 | ||
b0f5aad5 | 1096 | CDEBUG(D_SUPER, "%s: osfs %p age %llu, max_age %llu\n", |
d7e09d03 PT |
1097 | obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age); |
1098 | if (cfs_time_before_64(obd->obd_osfs_age, max_age)) { | |
1099 | rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset); | |
1100 | } else { | |
1d8cb70c GD |
1101 | CDEBUG(D_SUPER, |
1102 | "%s: use %p cache blocks %llu/%llu objects %llu/%llu\n", | |
d7e09d03 PT |
1103 | obd->obd_name, &obd->obd_osfs, |
1104 | obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks, | |
1105 | obd->obd_osfs.os_ffree, obd->obd_osfs.os_files); | |
1106 | spin_lock(&obd->obd_osfs_lock); | |
1107 | memcpy(oinfo->oi_osfs, &obd->obd_osfs, sizeof(*oinfo->oi_osfs)); | |
1108 | spin_unlock(&obd->obd_osfs_lock); | |
1109 | oinfo->oi_flags |= OBD_STATFS_FROM_CACHE; | |
1110 | if (oinfo->oi_cb_up) | |
1111 | oinfo->oi_cb_up(oinfo, 0); | |
1112 | } | |
0a3bdb00 | 1113 | return rc; |
d7e09d03 PT |
1114 | } |
1115 | ||
1116 | static inline int obd_statfs_rqset(struct obd_export *exp, | |
1117 | struct obd_statfs *osfs, __u64 max_age, | |
1118 | __u32 flags) | |
1119 | { | |
1120 | struct ptlrpc_request_set *set = NULL; | |
1121 | struct obd_info oinfo = { { { 0 } } }; | |
1122 | int rc = 0; | |
d7e09d03 PT |
1123 | |
1124 | set = ptlrpc_prep_set(); | |
1125 | if (set == NULL) | |
0a3bdb00 | 1126 | return -ENOMEM; |
d7e09d03 PT |
1127 | |
1128 | oinfo.oi_osfs = osfs; | |
1129 | oinfo.oi_flags = flags; | |
1130 | rc = obd_statfs_async(exp, &oinfo, max_age, set); | |
1131 | if (rc == 0) | |
1132 | rc = ptlrpc_set_wait(set); | |
1133 | ptlrpc_set_destroy(set); | |
0a3bdb00 | 1134 | return rc; |
d7e09d03 PT |
1135 | } |
1136 | ||
1137 | /* @max_age is the oldest time in jiffies that we accept using a cached data. | |
1138 | * If the cache is older than @max_age we will get a new value from the | |
1139 | * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. */ | |
1140 | static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, | |
1141 | struct obd_statfs *osfs, __u64 max_age, | |
1142 | __u32 flags) | |
1143 | { | |
1144 | int rc = 0; | |
1145 | struct obd_device *obd = exp->exp_obd; | |
d7e09d03 PT |
1146 | |
1147 | if (obd == NULL) | |
0a3bdb00 | 1148 | return -EINVAL; |
d7e09d03 PT |
1149 | |
1150 | OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); | |
1151 | OBD_COUNTER_INCREMENT(obd, statfs); | |
1152 | ||
b0f5aad5 | 1153 | CDEBUG(D_SUPER, "osfs %llu, max_age %llu\n", |
d7e09d03 PT |
1154 | obd->obd_osfs_age, max_age); |
1155 | if (cfs_time_before_64(obd->obd_osfs_age, max_age)) { | |
1156 | rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags); | |
1157 | if (rc == 0) { | |
1158 | spin_lock(&obd->obd_osfs_lock); | |
1159 | memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs)); | |
1160 | obd->obd_osfs_age = cfs_time_current_64(); | |
1161 | spin_unlock(&obd->obd_osfs_lock); | |
1162 | } | |
1163 | } else { | |
b0f5aad5 | 1164 | CDEBUG(D_SUPER, "%s: use %p cache blocks %llu/%llu objects %llu/%llu\n", |
d7e09d03 PT |
1165 | obd->obd_name, &obd->obd_osfs, |
1166 | obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks, | |
1167 | obd->obd_osfs.os_ffree, obd->obd_osfs.os_files); | |
1168 | spin_lock(&obd->obd_osfs_lock); | |
1169 | memcpy(osfs, &obd->obd_osfs, sizeof(*osfs)); | |
1170 | spin_unlock(&obd->obd_osfs_lock); | |
1171 | } | |
0a3bdb00 | 1172 | return rc; |
d7e09d03 PT |
1173 | } |
1174 | ||
d7e09d03 PT |
1175 | static inline int obd_preprw(const struct lu_env *env, int cmd, |
1176 | struct obd_export *exp, struct obdo *oa, | |
1177 | int objcount, struct obd_ioobj *obj, | |
1178 | struct niobuf_remote *remote, int *pages, | |
1179 | struct niobuf_local *local, | |
1180 | struct obd_trans_info *oti, | |
1181 | struct lustre_capa *capa) | |
1182 | { | |
1183 | int rc; | |
d7e09d03 PT |
1184 | |
1185 | EXP_CHECK_DT_OP(exp, preprw); | |
1186 | EXP_COUNTER_INCREMENT(exp, preprw); | |
1187 | ||
1188 | rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote, | |
1189 | pages, local, oti, capa); | |
0a3bdb00 | 1190 | return rc; |
d7e09d03 PT |
1191 | } |
1192 | ||
1193 | static inline int obd_commitrw(const struct lu_env *env, int cmd, | |
1194 | struct obd_export *exp, struct obdo *oa, | |
1195 | int objcount, struct obd_ioobj *obj, | |
1196 | struct niobuf_remote *rnb, int pages, | |
1197 | struct niobuf_local *local, | |
1198 | struct obd_trans_info *oti, int rc) | |
1199 | { | |
d7e09d03 PT |
1200 | EXP_CHECK_DT_OP(exp, commitrw); |
1201 | EXP_COUNTER_INCREMENT(exp, commitrw); | |
1202 | ||
1203 | rc = OBP(exp->exp_obd, commitrw)(env, cmd, exp, oa, objcount, obj, | |
1204 | rnb, pages, local, oti, rc); | |
0a3bdb00 | 1205 | return rc; |
d7e09d03 PT |
1206 | } |
1207 | ||
d7e09d03 | 1208 | static inline int obd_adjust_kms(struct obd_export *exp, |
21aef7d9 | 1209 | struct lov_stripe_md *lsm, u64 size, |
d7e09d03 PT |
1210 | int shrink) |
1211 | { | |
1212 | int rc; | |
d7e09d03 PT |
1213 | |
1214 | EXP_CHECK_DT_OP(exp, adjust_kms); | |
1215 | EXP_COUNTER_INCREMENT(exp, adjust_kms); | |
1216 | ||
1217 | rc = OBP(exp->exp_obd, adjust_kms)(exp, lsm, size, shrink); | |
0a3bdb00 | 1218 | return rc; |
d7e09d03 PT |
1219 | } |
1220 | ||
1221 | static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, | |
1222 | int len, void *karg, void *uarg) | |
1223 | { | |
1224 | int rc; | |
d7e09d03 PT |
1225 | |
1226 | EXP_CHECK_DT_OP(exp, iocontrol); | |
1227 | EXP_COUNTER_INCREMENT(exp, iocontrol); | |
1228 | ||
1229 | rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg); | |
0a3bdb00 | 1230 | return rc; |
d7e09d03 PT |
1231 | } |
1232 | ||
d7e09d03 PT |
1233 | static inline int obd_find_cbdata(struct obd_export *exp, |
1234 | struct lov_stripe_md *lsm, | |
1235 | ldlm_iterator_t it, void *data) | |
1236 | { | |
1237 | int rc; | |
d7e09d03 PT |
1238 | |
1239 | EXP_CHECK_DT_OP(exp, find_cbdata); | |
1240 | EXP_COUNTER_INCREMENT(exp, find_cbdata); | |
1241 | ||
1242 | rc = OBP(exp->exp_obd, find_cbdata)(exp, lsm, it, data); | |
0a3bdb00 | 1243 | return rc; |
d7e09d03 PT |
1244 | } |
1245 | ||
d7e09d03 PT |
1246 | static inline void obd_import_event(struct obd_device *obd, |
1247 | struct obd_import *imp, | |
1248 | enum obd_import_event event) | |
1249 | { | |
d7e09d03 PT |
1250 | if (!obd) { |
1251 | CERROR("NULL device\n"); | |
d7e09d03 PT |
1252 | return; |
1253 | } | |
1254 | if (obd->obd_set_up && OBP(obd, import_event)) { | |
1255 | OBD_COUNTER_INCREMENT(obd, import_event); | |
1256 | OBP(obd, import_event)(obd, imp, event); | |
1257 | } | |
d7e09d03 PT |
1258 | } |
1259 | ||
d7e09d03 PT |
1260 | static inline int obd_notify(struct obd_device *obd, |
1261 | struct obd_device *watched, | |
1262 | enum obd_notify_event ev, | |
1263 | void *data) | |
1264 | { | |
1265 | int rc; | |
29aaf496 | 1266 | |
4ca1b8fb AM |
1267 | rc = obd_check_dev(obd); |
1268 | if (rc) | |
1269 | return rc; | |
d7e09d03 PT |
1270 | |
1271 | /* the check for async_recov is a complete hack - I'm hereby | |
1272 | overloading the meaning to also mean "this was called from | |
1273 | mds_postsetup". I know that my mds is able to handle notifies | |
1274 | by this point, and it needs to get them to execute mds_postrecov. */ | |
1275 | if (!obd->obd_set_up && !obd->obd_async_recov) { | |
1276 | CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name); | |
0a3bdb00 | 1277 | return -EINVAL; |
d7e09d03 PT |
1278 | } |
1279 | ||
1280 | if (!OBP(obd, notify)) { | |
1281 | CDEBUG(D_HA, "obd %s has no notify handler\n", obd->obd_name); | |
0a3bdb00 | 1282 | return -ENOSYS; |
d7e09d03 PT |
1283 | } |
1284 | ||
1285 | OBD_COUNTER_INCREMENT(obd, notify); | |
1286 | rc = OBP(obd, notify)(obd, watched, ev, data); | |
0a3bdb00 | 1287 | return rc; |
d7e09d03 PT |
1288 | } |
1289 | ||
1290 | static inline int obd_notify_observer(struct obd_device *observer, | |
1291 | struct obd_device *observed, | |
1292 | enum obd_notify_event ev, | |
1293 | void *data) | |
1294 | { | |
1295 | int rc1; | |
1296 | int rc2; | |
1297 | ||
1298 | struct obd_notify_upcall *onu; | |
1299 | ||
1300 | if (observer->obd_observer) | |
1301 | rc1 = obd_notify(observer->obd_observer, observed, ev, data); | |
1302 | else | |
1303 | rc1 = 0; | |
1304 | /* | |
1305 | * Also, call non-obd listener, if any | |
1306 | */ | |
1307 | onu = &observer->obd_upcall; | |
1308 | if (onu->onu_upcall != NULL) | |
1309 | rc2 = onu->onu_upcall(observer, observed, ev, | |
1310 | onu->onu_owner, NULL); | |
1311 | else | |
1312 | rc2 = 0; | |
1313 | ||
1314 | return rc1 ? rc1 : rc2; | |
1315 | } | |
1316 | ||
1317 | static inline int obd_quotacheck(struct obd_export *exp, | |
1318 | struct obd_quotactl *oqctl) | |
1319 | { | |
1320 | int rc; | |
d7e09d03 PT |
1321 | |
1322 | EXP_CHECK_DT_OP(exp, quotacheck); | |
1323 | EXP_COUNTER_INCREMENT(exp, quotacheck); | |
1324 | ||
1325 | rc = OBP(exp->exp_obd, quotacheck)(exp->exp_obd, exp, oqctl); | |
0a3bdb00 | 1326 | return rc; |
d7e09d03 PT |
1327 | } |
1328 | ||
1329 | static inline int obd_quotactl(struct obd_export *exp, | |
1330 | struct obd_quotactl *oqctl) | |
1331 | { | |
1332 | int rc; | |
d7e09d03 PT |
1333 | |
1334 | EXP_CHECK_DT_OP(exp, quotactl); | |
1335 | EXP_COUNTER_INCREMENT(exp, quotactl); | |
1336 | ||
1337 | rc = OBP(exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl); | |
0a3bdb00 | 1338 | return rc; |
d7e09d03 PT |
1339 | } |
1340 | ||
1341 | static inline int obd_health_check(const struct lu_env *env, | |
1342 | struct obd_device *obd) | |
1343 | { | |
1344 | /* returns: 0 on healthy | |
1345 | * >0 on unhealthy + reason code/flag | |
bd9070cb | 1346 | * however the only supported reason == 1 right now |
d7e09d03 PT |
1347 | * We'll need to define some better reasons |
1348 | * or flags in the future. | |
1349 | * <0 on error | |
1350 | */ | |
1351 | int rc; | |
d7e09d03 PT |
1352 | |
1353 | /* don't use EXP_CHECK_DT_OP, because NULL method is normal here */ | |
1354 | if (obd == NULL || !OBT(obd)) { | |
1355 | CERROR("cleaned up obd\n"); | |
0a3bdb00 | 1356 | return -EOPNOTSUPP; |
d7e09d03 PT |
1357 | } |
1358 | if (!obd->obd_set_up || obd->obd_stopping) | |
0a3bdb00 | 1359 | return 0; |
d7e09d03 | 1360 | if (!OBP(obd, health_check)) |
0a3bdb00 | 1361 | return 0; |
d7e09d03 PT |
1362 | |
1363 | rc = OBP(obd, health_check)(env, obd); | |
0a3bdb00 | 1364 | return rc; |
d7e09d03 PT |
1365 | } |
1366 | ||
1367 | static inline int obd_register_observer(struct obd_device *obd, | |
1368 | struct obd_device *observer) | |
1369 | { | |
4ca1b8fb AM |
1370 | int rc; |
1371 | ||
1372 | rc = obd_check_dev(obd); | |
1373 | if (rc) | |
1374 | return rc; | |
d7e09d03 PT |
1375 | down_write(&obd->obd_observer_link_sem); |
1376 | if (obd->obd_observer && observer) { | |
1377 | up_write(&obd->obd_observer_link_sem); | |
0a3bdb00 | 1378 | return -EALREADY; |
d7e09d03 PT |
1379 | } |
1380 | obd->obd_observer = observer; | |
1381 | up_write(&obd->obd_observer_link_sem); | |
0a3bdb00 | 1382 | return 0; |
d7e09d03 PT |
1383 | } |
1384 | ||
d7e09d03 PT |
1385 | #if 0 |
1386 | static inline int obd_register_page_removal_cb(struct obd_export *exp, | |
1387 | obd_page_removal_cb_t cb, | |
1388 | obd_pin_extent_cb pin_cb) | |
1389 | { | |
1390 | int rc; | |
d7e09d03 PT |
1391 | |
1392 | OBD_CHECK_DT_OP(exp->exp_obd, register_page_removal_cb, 0); | |
1393 | OBD_COUNTER_INCREMENT(exp->exp_obd, register_page_removal_cb); | |
1394 | ||
1395 | rc = OBP(exp->exp_obd, register_page_removal_cb)(exp, cb, pin_cb); | |
0a3bdb00 | 1396 | return rc; |
d7e09d03 PT |
1397 | } |
1398 | ||
1399 | static inline int obd_unregister_page_removal_cb(struct obd_export *exp, | |
1400 | obd_page_removal_cb_t cb) | |
1401 | { | |
1402 | int rc; | |
d7e09d03 PT |
1403 | |
1404 | OBD_CHECK_DT_OP(exp->exp_obd, unregister_page_removal_cb, 0); | |
1405 | OBD_COUNTER_INCREMENT(exp->exp_obd, unregister_page_removal_cb); | |
1406 | ||
1407 | rc = OBP(exp->exp_obd, unregister_page_removal_cb)(exp, cb); | |
0a3bdb00 | 1408 | return rc; |
d7e09d03 PT |
1409 | } |
1410 | ||
1411 | static inline int obd_register_lock_cancel_cb(struct obd_export *exp, | |
1412 | obd_lock_cancel_cb cb) | |
1413 | { | |
1414 | int rc; | |
d7e09d03 PT |
1415 | |
1416 | OBD_CHECK_DT_OP(exp->exp_obd, register_lock_cancel_cb, 0); | |
1417 | OBD_COUNTER_INCREMENT(exp->exp_obd, register_lock_cancel_cb); | |
1418 | ||
1419 | rc = OBP(exp->exp_obd, register_lock_cancel_cb)(exp, cb); | |
0a3bdb00 | 1420 | return rc; |
d7e09d03 PT |
1421 | } |
1422 | ||
1423 | static inline int obd_unregister_lock_cancel_cb(struct obd_export *exp, | |
1424 | obd_lock_cancel_cb cb) | |
1425 | { | |
1426 | int rc; | |
d7e09d03 PT |
1427 | |
1428 | OBD_CHECK_DT_OP(exp->exp_obd, unregister_lock_cancel_cb, 0); | |
1429 | OBD_COUNTER_INCREMENT(exp->exp_obd, unregister_lock_cancel_cb); | |
1430 | ||
1431 | rc = OBP(exp->exp_obd, unregister_lock_cancel_cb)(exp, cb); | |
0a3bdb00 | 1432 | return rc; |
d7e09d03 PT |
1433 | } |
1434 | #endif | |
1435 | ||
1436 | /* metadata helpers */ | |
1437 | static inline int md_getstatus(struct obd_export *exp, | |
1438 | struct lu_fid *fid, struct obd_capa **pc) | |
1439 | { | |
1440 | int rc; | |
d7e09d03 PT |
1441 | |
1442 | EXP_CHECK_MD_OP(exp, getstatus); | |
1443 | EXP_MD_COUNTER_INCREMENT(exp, getstatus); | |
1444 | rc = MDP(exp->exp_obd, getstatus)(exp, fid, pc); | |
0a3bdb00 | 1445 | return rc; |
d7e09d03 PT |
1446 | } |
1447 | ||
1448 | static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data, | |
1449 | struct ptlrpc_request **request) | |
1450 | { | |
1451 | int rc; | |
29aaf496 | 1452 | |
d7e09d03 PT |
1453 | EXP_CHECK_MD_OP(exp, getattr); |
1454 | EXP_MD_COUNTER_INCREMENT(exp, getattr); | |
1455 | rc = MDP(exp->exp_obd, getattr)(exp, op_data, request); | |
0a3bdb00 | 1456 | return rc; |
d7e09d03 PT |
1457 | } |
1458 | ||
1459 | static inline int md_null_inode(struct obd_export *exp, | |
1460 | const struct lu_fid *fid) | |
1461 | { | |
1462 | int rc; | |
29aaf496 | 1463 | |
d7e09d03 PT |
1464 | EXP_CHECK_MD_OP(exp, null_inode); |
1465 | EXP_MD_COUNTER_INCREMENT(exp, null_inode); | |
1466 | rc = MDP(exp->exp_obd, null_inode)(exp, fid); | |
0a3bdb00 | 1467 | return rc; |
d7e09d03 PT |
1468 | } |
1469 | ||
1470 | static inline int md_find_cbdata(struct obd_export *exp, | |
1471 | const struct lu_fid *fid, | |
1472 | ldlm_iterator_t it, void *data) | |
1473 | { | |
1474 | int rc; | |
29aaf496 | 1475 | |
d7e09d03 PT |
1476 | EXP_CHECK_MD_OP(exp, find_cbdata); |
1477 | EXP_MD_COUNTER_INCREMENT(exp, find_cbdata); | |
1478 | rc = MDP(exp->exp_obd, find_cbdata)(exp, fid, it, data); | |
0a3bdb00 | 1479 | return rc; |
d7e09d03 PT |
1480 | } |
1481 | ||
1482 | static inline int md_close(struct obd_export *exp, struct md_op_data *op_data, | |
1483 | struct md_open_data *mod, | |
1484 | struct ptlrpc_request **request) | |
1485 | { | |
1486 | int rc; | |
29aaf496 | 1487 | |
d7e09d03 PT |
1488 | EXP_CHECK_MD_OP(exp, close); |
1489 | EXP_MD_COUNTER_INCREMENT(exp, close); | |
1490 | rc = MDP(exp->exp_obd, close)(exp, op_data, mod, request); | |
0a3bdb00 | 1491 | return rc; |
d7e09d03 PT |
1492 | } |
1493 | ||
1494 | static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, | |
1495 | const void *data, int datalen, int mode, __u32 uid, | |
1496 | __u32 gid, cfs_cap_t cap_effective, __u64 rdev, | |
1497 | struct ptlrpc_request **request) | |
1498 | { | |
1499 | int rc; | |
29aaf496 | 1500 | |
d7e09d03 PT |
1501 | EXP_CHECK_MD_OP(exp, create); |
1502 | EXP_MD_COUNTER_INCREMENT(exp, create); | |
1503 | rc = MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode, | |
1504 | uid, gid, cap_effective, rdev, request); | |
0a3bdb00 | 1505 | return rc; |
d7e09d03 PT |
1506 | } |
1507 | ||
1508 | static inline int md_done_writing(struct obd_export *exp, | |
1509 | struct md_op_data *op_data, | |
1510 | struct md_open_data *mod) | |
1511 | { | |
1512 | int rc; | |
29aaf496 | 1513 | |
d7e09d03 PT |
1514 | EXP_CHECK_MD_OP(exp, done_writing); |
1515 | EXP_MD_COUNTER_INCREMENT(exp, done_writing); | |
1516 | rc = MDP(exp->exp_obd, done_writing)(exp, op_data, mod); | |
0a3bdb00 | 1517 | return rc; |
d7e09d03 PT |
1518 | } |
1519 | ||
1520 | static inline int md_enqueue(struct obd_export *exp, | |
1521 | struct ldlm_enqueue_info *einfo, | |
1522 | struct lookup_intent *it, | |
1523 | struct md_op_data *op_data, | |
1524 | struct lustre_handle *lockh, | |
1525 | void *lmm, int lmmsize, | |
1526 | struct ptlrpc_request **req, | |
875332d4 | 1527 | __u64 extra_lock_flags) |
d7e09d03 PT |
1528 | { |
1529 | int rc; | |
29aaf496 | 1530 | |
d7e09d03 PT |
1531 | EXP_CHECK_MD_OP(exp, enqueue); |
1532 | EXP_MD_COUNTER_INCREMENT(exp, enqueue); | |
1533 | rc = MDP(exp->exp_obd, enqueue)(exp, einfo, it, op_data, lockh, | |
1534 | lmm, lmmsize, req, extra_lock_flags); | |
0a3bdb00 | 1535 | return rc; |
d7e09d03 PT |
1536 | } |
1537 | ||
1538 | static inline int md_getattr_name(struct obd_export *exp, | |
1539 | struct md_op_data *op_data, | |
1540 | struct ptlrpc_request **request) | |
1541 | { | |
1542 | int rc; | |
29aaf496 | 1543 | |
d7e09d03 PT |
1544 | EXP_CHECK_MD_OP(exp, getattr_name); |
1545 | EXP_MD_COUNTER_INCREMENT(exp, getattr_name); | |
1546 | rc = MDP(exp->exp_obd, getattr_name)(exp, op_data, request); | |
0a3bdb00 | 1547 | return rc; |
d7e09d03 PT |
1548 | } |
1549 | ||
1550 | static inline int md_intent_lock(struct obd_export *exp, | |
1551 | struct md_op_data *op_data, void *lmm, | |
1552 | int lmmsize, struct lookup_intent *it, | |
1553 | int lookup_flags, struct ptlrpc_request **reqp, | |
1554 | ldlm_blocking_callback cb_blocking, | |
1555 | __u64 extra_lock_flags) | |
1556 | { | |
1557 | int rc; | |
29aaf496 | 1558 | |
d7e09d03 PT |
1559 | EXP_CHECK_MD_OP(exp, intent_lock); |
1560 | EXP_MD_COUNTER_INCREMENT(exp, intent_lock); | |
1561 | rc = MDP(exp->exp_obd, intent_lock)(exp, op_data, lmm, lmmsize, | |
1562 | it, lookup_flags, reqp, cb_blocking, | |
1563 | extra_lock_flags); | |
0a3bdb00 | 1564 | return rc; |
d7e09d03 PT |
1565 | } |
1566 | ||
1567 | static inline int md_link(struct obd_export *exp, struct md_op_data *op_data, | |
1568 | struct ptlrpc_request **request) | |
1569 | { | |
1570 | int rc; | |
29aaf496 | 1571 | |
d7e09d03 PT |
1572 | EXP_CHECK_MD_OP(exp, link); |
1573 | EXP_MD_COUNTER_INCREMENT(exp, link); | |
1574 | rc = MDP(exp->exp_obd, link)(exp, op_data, request); | |
0a3bdb00 | 1575 | return rc; |
d7e09d03 PT |
1576 | } |
1577 | ||
1578 | static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data, | |
1579 | const char *old, int oldlen, const char *new, | |
1580 | int newlen, struct ptlrpc_request **request) | |
1581 | { | |
1582 | int rc; | |
29aaf496 | 1583 | |
d7e09d03 PT |
1584 | EXP_CHECK_MD_OP(exp, rename); |
1585 | EXP_MD_COUNTER_INCREMENT(exp, rename); | |
1586 | rc = MDP(exp->exp_obd, rename)(exp, op_data, old, oldlen, new, | |
1587 | newlen, request); | |
0a3bdb00 | 1588 | return rc; |
d7e09d03 PT |
1589 | } |
1590 | ||
1591 | static inline int md_is_subdir(struct obd_export *exp, | |
1592 | const struct lu_fid *pfid, | |
1593 | const struct lu_fid *cfid, | |
1594 | struct ptlrpc_request **request) | |
1595 | { | |
1596 | int rc; | |
29aaf496 | 1597 | |
d7e09d03 PT |
1598 | EXP_CHECK_MD_OP(exp, is_subdir); |
1599 | EXP_MD_COUNTER_INCREMENT(exp, is_subdir); | |
1600 | rc = MDP(exp->exp_obd, is_subdir)(exp, pfid, cfid, request); | |
0a3bdb00 | 1601 | return rc; |
d7e09d03 PT |
1602 | } |
1603 | ||
1604 | static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, | |
1605 | void *ea, int ealen, void *ea2, int ea2len, | |
1606 | struct ptlrpc_request **request, | |
1607 | struct md_open_data **mod) | |
1608 | { | |
1609 | int rc; | |
29aaf496 | 1610 | |
d7e09d03 PT |
1611 | EXP_CHECK_MD_OP(exp, setattr); |
1612 | EXP_MD_COUNTER_INCREMENT(exp, setattr); | |
1613 | rc = MDP(exp->exp_obd, setattr)(exp, op_data, ea, ealen, | |
1614 | ea2, ea2len, request, mod); | |
0a3bdb00 | 1615 | return rc; |
d7e09d03 PT |
1616 | } |
1617 | ||
1618 | static inline int md_sync(struct obd_export *exp, const struct lu_fid *fid, | |
1619 | struct obd_capa *oc, struct ptlrpc_request **request) | |
1620 | { | |
1621 | int rc; | |
29aaf496 | 1622 | |
d7e09d03 PT |
1623 | EXP_CHECK_MD_OP(exp, sync); |
1624 | EXP_MD_COUNTER_INCREMENT(exp, sync); | |
1625 | rc = MDP(exp->exp_obd, sync)(exp, fid, oc, request); | |
0a3bdb00 | 1626 | return rc; |
d7e09d03 PT |
1627 | } |
1628 | ||
1629 | static inline int md_readpage(struct obd_export *exp, struct md_op_data *opdata, | |
1630 | struct page **pages, | |
1631 | struct ptlrpc_request **request) | |
1632 | { | |
1633 | int rc; | |
29aaf496 | 1634 | |
d7e09d03 PT |
1635 | EXP_CHECK_MD_OP(exp, readpage); |
1636 | EXP_MD_COUNTER_INCREMENT(exp, readpage); | |
1637 | rc = MDP(exp->exp_obd, readpage)(exp, opdata, pages, request); | |
0a3bdb00 | 1638 | return rc; |
d7e09d03 PT |
1639 | } |
1640 | ||
1641 | static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data, | |
1642 | struct ptlrpc_request **request) | |
1643 | { | |
1644 | int rc; | |
29aaf496 | 1645 | |
d7e09d03 PT |
1646 | EXP_CHECK_MD_OP(exp, unlink); |
1647 | EXP_MD_COUNTER_INCREMENT(exp, unlink); | |
1648 | rc = MDP(exp->exp_obd, unlink)(exp, op_data, request); | |
0a3bdb00 | 1649 | return rc; |
d7e09d03 PT |
1650 | } |
1651 | ||
1652 | static inline int md_get_lustre_md(struct obd_export *exp, | |
1653 | struct ptlrpc_request *req, | |
1654 | struct obd_export *dt_exp, | |
1655 | struct obd_export *md_exp, | |
1656 | struct lustre_md *md) | |
1657 | { | |
d7e09d03 PT |
1658 | EXP_CHECK_MD_OP(exp, get_lustre_md); |
1659 | EXP_MD_COUNTER_INCREMENT(exp, get_lustre_md); | |
0a3bdb00 | 1660 | return MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md); |
d7e09d03 PT |
1661 | } |
1662 | ||
1663 | static inline int md_free_lustre_md(struct obd_export *exp, | |
1664 | struct lustre_md *md) | |
1665 | { | |
d7e09d03 PT |
1666 | EXP_CHECK_MD_OP(exp, free_lustre_md); |
1667 | EXP_MD_COUNTER_INCREMENT(exp, free_lustre_md); | |
0a3bdb00 | 1668 | return MDP(exp->exp_obd, free_lustre_md)(exp, md); |
d7e09d03 PT |
1669 | } |
1670 | ||
1671 | static inline int md_setxattr(struct obd_export *exp, | |
1672 | const struct lu_fid *fid, struct obd_capa *oc, | |
21aef7d9 | 1673 | u64 valid, const char *name, |
d7e09d03 PT |
1674 | const char *input, int input_size, |
1675 | int output_size, int flags, __u32 suppgid, | |
1676 | struct ptlrpc_request **request) | |
1677 | { | |
d7e09d03 PT |
1678 | EXP_CHECK_MD_OP(exp, setxattr); |
1679 | EXP_MD_COUNTER_INCREMENT(exp, setxattr); | |
0a3bdb00 | 1680 | return MDP(exp->exp_obd, setxattr)(exp, fid, oc, valid, name, input, |
d7e09d03 | 1681 | input_size, output_size, flags, |
0a3bdb00 | 1682 | suppgid, request); |
d7e09d03 PT |
1683 | } |
1684 | ||
1685 | static inline int md_getxattr(struct obd_export *exp, | |
1686 | const struct lu_fid *fid, struct obd_capa *oc, | |
21aef7d9 | 1687 | u64 valid, const char *name, |
d7e09d03 PT |
1688 | const char *input, int input_size, |
1689 | int output_size, int flags, | |
1690 | struct ptlrpc_request **request) | |
1691 | { | |
d7e09d03 PT |
1692 | EXP_CHECK_MD_OP(exp, getxattr); |
1693 | EXP_MD_COUNTER_INCREMENT(exp, getxattr); | |
0a3bdb00 | 1694 | return MDP(exp->exp_obd, getxattr)(exp, fid, oc, valid, name, input, |
d7e09d03 | 1695 | input_size, output_size, flags, |
0a3bdb00 | 1696 | request); |
d7e09d03 PT |
1697 | } |
1698 | ||
1699 | static inline int md_set_open_replay_data(struct obd_export *exp, | |
1700 | struct obd_client_handle *och, | |
63d42578 | 1701 | struct lookup_intent *it) |
d7e09d03 | 1702 | { |
d7e09d03 PT |
1703 | EXP_CHECK_MD_OP(exp, set_open_replay_data); |
1704 | EXP_MD_COUNTER_INCREMENT(exp, set_open_replay_data); | |
63d42578 | 1705 | return MDP(exp->exp_obd, set_open_replay_data)(exp, och, it); |
d7e09d03 PT |
1706 | } |
1707 | ||
1708 | static inline int md_clear_open_replay_data(struct obd_export *exp, | |
1709 | struct obd_client_handle *och) | |
1710 | { | |
d7e09d03 PT |
1711 | EXP_CHECK_MD_OP(exp, clear_open_replay_data); |
1712 | EXP_MD_COUNTER_INCREMENT(exp, clear_open_replay_data); | |
0a3bdb00 | 1713 | return MDP(exp->exp_obd, clear_open_replay_data)(exp, och); |
d7e09d03 PT |
1714 | } |
1715 | ||
1716 | static inline int md_set_lock_data(struct obd_export *exp, | |
1717 | __u64 *lockh, void *data, __u64 *bits) | |
1718 | { | |
d7e09d03 PT |
1719 | EXP_CHECK_MD_OP(exp, set_lock_data); |
1720 | EXP_MD_COUNTER_INCREMENT(exp, set_lock_data); | |
0a3bdb00 | 1721 | return MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits); |
d7e09d03 PT |
1722 | } |
1723 | ||
1724 | static inline int md_cancel_unused(struct obd_export *exp, | |
1725 | const struct lu_fid *fid, | |
1726 | ldlm_policy_data_t *policy, | |
1727 | ldlm_mode_t mode, | |
1728 | ldlm_cancel_flags_t flags, | |
1729 | void *opaque) | |
1730 | { | |
1731 | int rc; | |
d7e09d03 PT |
1732 | |
1733 | EXP_CHECK_MD_OP(exp, cancel_unused); | |
1734 | EXP_MD_COUNTER_INCREMENT(exp, cancel_unused); | |
1735 | ||
1736 | rc = MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode, | |
1737 | flags, opaque); | |
0a3bdb00 | 1738 | return rc; |
d7e09d03 PT |
1739 | } |
1740 | ||
1741 | static inline ldlm_mode_t md_lock_match(struct obd_export *exp, __u64 flags, | |
1742 | const struct lu_fid *fid, | |
1743 | ldlm_type_t type, | |
1744 | ldlm_policy_data_t *policy, | |
1745 | ldlm_mode_t mode, | |
1746 | struct lustre_handle *lockh) | |
1747 | { | |
d7e09d03 PT |
1748 | EXP_CHECK_MD_OP(exp, lock_match); |
1749 | EXP_MD_COUNTER_INCREMENT(exp, lock_match); | |
0a3bdb00 GKH |
1750 | return MDP(exp->exp_obd, lock_match)(exp, flags, fid, type, |
1751 | policy, mode, lockh); | |
d7e09d03 PT |
1752 | } |
1753 | ||
1754 | static inline int md_init_ea_size(struct obd_export *exp, int easize, | |
44779340 BB |
1755 | int def_asize, int cookiesize, |
1756 | int def_cookiesize) | |
d7e09d03 | 1757 | { |
d7e09d03 PT |
1758 | EXP_CHECK_MD_OP(exp, init_ea_size); |
1759 | EXP_MD_COUNTER_INCREMENT(exp, init_ea_size); | |
0a3bdb00 | 1760 | return MDP(exp->exp_obd, init_ea_size)(exp, easize, def_asize, |
44779340 | 1761 | cookiesize, def_cookiesize); |
d7e09d03 PT |
1762 | } |
1763 | ||
1764 | static inline int md_get_remote_perm(struct obd_export *exp, | |
1765 | const struct lu_fid *fid, | |
1766 | struct obd_capa *oc, __u32 suppgid, | |
1767 | struct ptlrpc_request **request) | |
1768 | { | |
d7e09d03 PT |
1769 | EXP_CHECK_MD_OP(exp, get_remote_perm); |
1770 | EXP_MD_COUNTER_INCREMENT(exp, get_remote_perm); | |
0a3bdb00 GKH |
1771 | return MDP(exp->exp_obd, get_remote_perm)(exp, fid, oc, suppgid, |
1772 | request); | |
d7e09d03 PT |
1773 | } |
1774 | ||
1775 | static inline int md_renew_capa(struct obd_export *exp, struct obd_capa *ocapa, | |
1776 | renew_capa_cb_t cb) | |
1777 | { | |
1778 | int rc; | |
29aaf496 | 1779 | |
d7e09d03 PT |
1780 | EXP_CHECK_MD_OP(exp, renew_capa); |
1781 | EXP_MD_COUNTER_INCREMENT(exp, renew_capa); | |
1782 | rc = MDP(exp->exp_obd, renew_capa)(exp, ocapa, cb); | |
0a3bdb00 | 1783 | return rc; |
d7e09d03 PT |
1784 | } |
1785 | ||
1786 | static inline int md_unpack_capa(struct obd_export *exp, | |
1787 | struct ptlrpc_request *req, | |
1788 | const struct req_msg_field *field, | |
1789 | struct obd_capa **oc) | |
1790 | { | |
1791 | int rc; | |
29aaf496 | 1792 | |
d7e09d03 PT |
1793 | EXP_CHECK_MD_OP(exp, unpack_capa); |
1794 | EXP_MD_COUNTER_INCREMENT(exp, unpack_capa); | |
1795 | rc = MDP(exp->exp_obd, unpack_capa)(exp, req, field, oc); | |
0a3bdb00 | 1796 | return rc; |
d7e09d03 PT |
1797 | } |
1798 | ||
1799 | static inline int md_intent_getattr_async(struct obd_export *exp, | |
1800 | struct md_enqueue_info *minfo, | |
1801 | struct ldlm_enqueue_info *einfo) | |
1802 | { | |
1803 | int rc; | |
29aaf496 | 1804 | |
d7e09d03 PT |
1805 | EXP_CHECK_MD_OP(exp, intent_getattr_async); |
1806 | EXP_MD_COUNTER_INCREMENT(exp, intent_getattr_async); | |
1807 | rc = MDP(exp->exp_obd, intent_getattr_async)(exp, minfo, einfo); | |
0a3bdb00 | 1808 | return rc; |
d7e09d03 PT |
1809 | } |
1810 | ||
1811 | static inline int md_revalidate_lock(struct obd_export *exp, | |
1812 | struct lookup_intent *it, | |
1813 | struct lu_fid *fid, __u64 *bits) | |
1814 | { | |
1815 | int rc; | |
29aaf496 | 1816 | |
d7e09d03 PT |
1817 | EXP_CHECK_MD_OP(exp, revalidate_lock); |
1818 | EXP_MD_COUNTER_INCREMENT(exp, revalidate_lock); | |
1819 | rc = MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits); | |
0a3bdb00 | 1820 | return rc; |
d7e09d03 PT |
1821 | } |
1822 | ||
1823 | ||
1824 | /* OBD Metadata Support */ | |
1825 | ||
8150a97f JP |
1826 | int obd_init_caches(void); |
1827 | void obd_cleanup_caches(void); | |
d7e09d03 PT |
1828 | |
1829 | /* support routines */ | |
1830 | extern struct kmem_cache *obdo_cachep; | |
1831 | ||
1832 | #define OBDO_ALLOC(ptr) \ | |
1833 | do { \ | |
0be19afa | 1834 | OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, GFP_NOFS); \ |
a58a38ac | 1835 | } while (0) |
d7e09d03 PT |
1836 | |
1837 | #define OBDO_FREE(ptr) \ | |
1838 | do { \ | |
1839 | OBD_SLAB_FREE_PTR((ptr), obdo_cachep); \ | |
a58a38ac | 1840 | } while (0) |
d7e09d03 PT |
1841 | |
1842 | ||
1843 | static inline void obdo2fid(struct obdo *oa, struct lu_fid *fid) | |
1844 | { | |
1845 | /* something here */ | |
1846 | } | |
1847 | ||
1848 | static inline void fid2obdo(struct lu_fid *fid, struct obdo *oa) | |
1849 | { | |
1850 | /* something here */ | |
1851 | } | |
1852 | ||
1853 | typedef int (*register_lwp_cb)(void *data); | |
1854 | ||
1855 | struct lwp_register_item { | |
1856 | struct obd_export **lri_exp; | |
1857 | register_lwp_cb lri_cb_func; | |
1858 | void *lri_cb_data; | |
1859 | struct list_head lri_list; | |
1860 | char lri_name[MTI_NAME_MAXLEN]; | |
1861 | }; | |
1862 | ||
1863 | /* I'm as embarrassed about this as you are. | |
1864 | * | |
1865 | * <shaver> // XXX do not look into _superhack with remaining eye | |
1866 | * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */ | |
1867 | extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c); | |
1868 | ||
1869 | /* obd_mount.c */ | |
1870 | ||
1871 | /* sysctl.c */ | |
8150a97f | 1872 | int obd_sysctl_init(void); |
d7e09d03 PT |
1873 | |
1874 | /* uuid.c */ | |
1875 | typedef __u8 class_uuid_t[16]; | |
1876 | void class_uuid_unparse(class_uuid_t in, struct obd_uuid *out); | |
1877 | ||
1878 | /* lustre_peer.c */ | |
1879 | int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index); | |
1880 | int class_add_uuid(const char *uuid, __u64 nid); | |
1881 | int class_del_uuid (const char *uuid); | |
1882 | int class_check_uuid(struct obd_uuid *uuid, __u64 nid); | |
1883 | void class_init_uuidlist(void); | |
1884 | void class_exit_uuidlist(void); | |
1885 | ||
76133e66 OD |
1886 | /* class_obd.c */ |
1887 | extern char obd_jobid_node[]; | |
9ee941df HM |
1888 | extern struct miscdevice obd_psdev; |
1889 | extern spinlock_t obd_types_lock; | |
76133e66 | 1890 | |
d7e09d03 PT |
1891 | /* prng.c */ |
1892 | #define ll_generate_random_uuid(uuid_out) cfs_get_random_bytes(uuid_out, sizeof(class_uuid_t)) | |
1893 | ||
1894 | #endif /* __LINUX_OBD_CLASS_H */ |