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 | ||
37 | #ifndef __OBD_H | |
38 | #define __OBD_H | |
39 | ||
1accaadf | 40 | #include "linux/obd.h" |
d7e09d03 PT |
41 | |
42 | #define IOC_OSC_TYPE 'h' | |
43 | #define IOC_OSC_MIN_NR 20 | |
44 | #define IOC_OSC_SET_ACTIVE _IOWR(IOC_OSC_TYPE, 21, struct obd_device *) | |
45 | #define IOC_OSC_MAX_NR 50 | |
46 | ||
47 | #define IOC_MDC_TYPE 'i' | |
48 | #define IOC_MDC_MIN_NR 20 | |
49 | #define IOC_MDC_MAX_NR 50 | |
50 | ||
1accaadf GKH |
51 | #include "lustre/lustre_idl.h" |
52 | #include "lustre_lib.h" | |
1accaadf GKH |
53 | #include "lu_ref.h" |
54 | #include "lustre_export.h" | |
55 | #include "lustre_fid.h" | |
56 | #include "lustre_fld.h" | |
57 | #include "lustre_capa.h" | |
d7e09d03 | 58 | |
d7e09d03 PT |
59 | #define MAX_OBD_DEVICES 8192 |
60 | ||
61 | struct osc_async_rc { | |
62 | int ar_rc; | |
63 | int ar_force_sync; | |
64 | __u64 ar_min_xid; | |
65 | }; | |
66 | ||
67 | struct lov_oinfo { /* per-stripe data structure */ | |
68 | struct ost_id loi_oi; /* object ID/Sequence on the target OST */ | |
69 | int loi_ost_idx; /* OST stripe index in lov_tgt_desc->tgts */ | |
70 | int loi_ost_gen; /* generation of this loi_ost_idx */ | |
71 | ||
72 | unsigned long loi_kms_valid:1; | |
73 | __u64 loi_kms; /* known minimum size */ | |
74 | struct ost_lvb loi_lvb; | |
75 | struct osc_async_rc loi_ar; | |
76 | }; | |
77 | ||
78 | static inline void loi_kms_set(struct lov_oinfo *oinfo, __u64 kms) | |
79 | { | |
80 | oinfo->loi_kms = kms; | |
81 | oinfo->loi_kms_valid = 1; | |
82 | } | |
83 | ||
84 | static inline void loi_init(struct lov_oinfo *loi) | |
85 | { | |
86 | } | |
87 | ||
88 | struct lov_stripe_md { | |
89 | atomic_t lsm_refc; | |
90 | spinlock_t lsm_lock; | |
91 | pid_t lsm_lock_owner; /* debugging */ | |
92 | ||
93 | /* maximum possible file size, might change as OSTs status changes, | |
94 | * e.g. disconnected, deactivated */ | |
95 | __u64 lsm_maxbytes; | |
96 | struct { | |
97 | /* Public members. */ | |
98 | struct ost_id lw_object_oi; /* lov object id/seq */ | |
99 | ||
100 | /* LOV-private members start here -- only for use in lov/. */ | |
101 | __u32 lw_magic; | |
102 | __u32 lw_stripe_size; /* size of the stripe */ | |
103 | __u32 lw_pattern; /* striping pattern (RAID0, RAID1) */ | |
104 | __u16 lw_stripe_count; /* number of objects being striped over */ | |
105 | __u16 lw_layout_gen; /* generation of the layout */ | |
106 | char lw_pool_name[LOV_MAXPOOLNAME]; /* pool name */ | |
107 | } lsm_wire; | |
108 | ||
109 | struct lov_oinfo *lsm_oinfo[0]; | |
110 | }; | |
111 | ||
112 | #define lsm_oi lsm_wire.lw_object_oi | |
113 | #define lsm_magic lsm_wire.lw_magic | |
114 | #define lsm_layout_gen lsm_wire.lw_layout_gen | |
115 | #define lsm_stripe_size lsm_wire.lw_stripe_size | |
116 | #define lsm_pattern lsm_wire.lw_pattern | |
117 | #define lsm_stripe_count lsm_wire.lw_stripe_count | |
118 | #define lsm_pool_name lsm_wire.lw_pool_name | |
119 | ||
5dd16419 JX |
120 | static inline bool lsm_is_released(struct lov_stripe_md *lsm) |
121 | { | |
122 | return !!(lsm->lsm_pattern & LOV_PATTERN_F_RELEASED); | |
123 | } | |
124 | ||
125 | static inline bool lsm_has_objects(struct lov_stripe_md *lsm) | |
126 | { | |
127 | if (lsm == NULL) | |
128 | return false; | |
129 | if (lsm_is_released(lsm)) | |
130 | return false; | |
131 | return true; | |
132 | } | |
133 | ||
081b7265 JH |
134 | static inline int lov_stripe_md_size(unsigned int stripe_count) |
135 | { | |
136 | struct lov_stripe_md lsm; | |
137 | ||
138 | return sizeof(lsm) + stripe_count * sizeof(lsm.lsm_oinfo[0]); | |
139 | } | |
140 | ||
d7e09d03 PT |
141 | struct obd_info; |
142 | ||
143 | typedef int (*obd_enqueue_update_f)(void *cookie, int rc); | |
144 | ||
145 | /* obd info for a particular level (lov, osc). */ | |
146 | struct obd_info { | |
147 | /* Lock policy. It keeps an extent which is specific for a particular | |
148 | * OSC. (e.g. lov_prep_enqueue_set initialises extent of the policy, | |
149 | * and osc_enqueue passes it into ldlm_lock_match & ldlm_cli_enqueue. */ | |
150 | ldlm_policy_data_t oi_policy; | |
151 | /* Flags used for set request specific flags: | |
152 | - while lock handling, the flags obtained on the enqueue | |
153 | request are set here. | |
154 | - while stats, the flags used for control delay/resend. | |
155 | - while setattr, the flags used for distinguish punch operation | |
156 | */ | |
157 | __u64 oi_flags; | |
158 | /* Lock handle specific for every OSC lock. */ | |
159 | struct lustre_handle *oi_lockh; | |
160 | /* lsm data specific for every OSC. */ | |
161 | struct lov_stripe_md *oi_md; | |
162 | /* obdo data specific for every OSC, if needed at all. */ | |
163 | struct obdo *oi_oa; | |
164 | /* statfs data specific for every OSC, if needed at all. */ | |
165 | struct obd_statfs *oi_osfs; | |
166 | /* An update callback which is called to update some data on upper | |
17891183 | 167 | * level. E.g. it is used for update lsm->lsm_oinfo at every received |
d7e09d03 PT |
168 | * request in osc level for enqueue requests. It is also possible to |
169 | * update some caller data from LOV layer if needed. */ | |
170 | obd_enqueue_update_f oi_cb_up; | |
171 | /* oss capability, its type is obd_capa in client to avoid copy. | |
172 | * in contrary its type is lustre_capa in OSS. */ | |
173 | void *oi_capa; | |
174 | /* transfer jobid from ost_sync() to filter_sync()... */ | |
175 | char *oi_jobid; | |
176 | }; | |
177 | ||
178 | /* compare all relevant fields. */ | |
179 | static inline int lov_stripe_md_cmp(struct lov_stripe_md *m1, | |
180 | struct lov_stripe_md *m2) | |
181 | { | |
182 | /* | |
183 | * ->lsm_wire contains padding, but it should be zeroed out during | |
184 | * allocation. | |
185 | */ | |
ec83e611 | 186 | return memcmp(&m1->lsm_wire, &m2->lsm_wire, sizeof(m1->lsm_wire)); |
d7e09d03 PT |
187 | } |
188 | ||
189 | static inline int lov_lum_lsm_cmp(struct lov_user_md *lum, | |
190 | struct lov_stripe_md *lsm) | |
191 | { | |
192 | if (lsm->lsm_magic != lum->lmm_magic) | |
193 | return 1; | |
194 | if ((lsm->lsm_stripe_count != 0) && (lum->lmm_stripe_count != 0) && | |
195 | (lsm->lsm_stripe_count != lum->lmm_stripe_count)) | |
196 | return 2; | |
197 | if ((lsm->lsm_stripe_size != 0) && (lum->lmm_stripe_size != 0) && | |
198 | (lsm->lsm_stripe_size != lum->lmm_stripe_size)) | |
199 | return 3; | |
200 | if ((lsm->lsm_pattern != 0) && (lum->lmm_pattern != 0) && | |
201 | (lsm->lsm_pattern != lum->lmm_pattern)) | |
202 | return 4; | |
203 | if ((lsm->lsm_magic == LOV_MAGIC_V3) && | |
204 | (strncmp(lsm->lsm_pool_name, | |
205 | ((struct lov_user_md_v3 *)lum)->lmm_pool_name, | |
206 | LOV_MAXPOOLNAME) != 0)) | |
207 | return 5; | |
208 | return 0; | |
209 | } | |
210 | ||
211 | static inline int lov_lum_swab_if_needed(struct lov_user_md_v3 *lumv3, | |
212 | int *lmm_magic, | |
213 | struct lov_user_md *lum) | |
214 | { | |
215 | if (lum && copy_from_user(lumv3, lum,sizeof(struct lov_user_md_v1))) | |
216 | return -EFAULT; | |
217 | ||
218 | *lmm_magic = lumv3->lmm_magic; | |
219 | ||
220 | if (*lmm_magic == __swab32(LOV_USER_MAGIC_V1)) { | |
221 | lustre_swab_lov_user_md_v1((struct lov_user_md_v1 *)lumv3); | |
222 | *lmm_magic = LOV_USER_MAGIC_V1; | |
223 | } else if (*lmm_magic == LOV_USER_MAGIC_V3) { | |
224 | if (lum && copy_from_user(lumv3, lum, sizeof(*lumv3))) | |
225 | return -EFAULT; | |
226 | } else if (*lmm_magic == __swab32(LOV_USER_MAGIC_V3)) { | |
227 | if (lum && copy_from_user(lumv3, lum, sizeof(*lumv3))) | |
228 | return -EFAULT; | |
229 | lustre_swab_lov_user_md_v3(lumv3); | |
230 | *lmm_magic = LOV_USER_MAGIC_V3; | |
231 | } else if (*lmm_magic != LOV_USER_MAGIC_V1) { | |
232 | CDEBUG(D_IOCTL, | |
233 | "bad userland LOV MAGIC: %#08x != %#08x nor %#08x\n", | |
234 | *lmm_magic, LOV_USER_MAGIC_V1, LOV_USER_MAGIC_V3); | |
235 | return -EINVAL; | |
236 | } | |
237 | return 0; | |
238 | } | |
239 | ||
240 | void lov_stripe_lock(struct lov_stripe_md *md); | |
241 | void lov_stripe_unlock(struct lov_stripe_md *md); | |
242 | ||
243 | struct obd_type { | |
244 | struct list_head typ_chain; | |
245 | struct obd_ops *typ_dt_ops; | |
246 | struct md_ops *typ_md_ops; | |
b59fe845 | 247 | struct proc_dir_entry *typ_procroot; |
d7e09d03 PT |
248 | char *typ_name; |
249 | int typ_refcnt; | |
250 | struct lu_device_type *typ_lu; | |
251 | spinlock_t obd_type_lock; | |
252 | }; | |
253 | ||
254 | struct brw_page { | |
255 | obd_off off; | |
256 | struct page *pg; | |
257 | int count; | |
258 | obd_flag flag; | |
259 | }; | |
260 | ||
d7e09d03 PT |
261 | /* llog contexts */ |
262 | enum llog_ctxt_id { | |
263 | LLOG_CONFIG_ORIG_CTXT = 0, | |
264 | LLOG_CONFIG_REPL_CTXT, | |
265 | LLOG_MDS_OST_ORIG_CTXT, | |
266 | LLOG_MDS_OST_REPL_CTXT, | |
267 | LLOG_SIZE_ORIG_CTXT, | |
268 | LLOG_SIZE_REPL_CTXT, | |
269 | LLOG_RD1_ORIG_CTXT, | |
270 | LLOG_RD1_REPL_CTXT, | |
271 | LLOG_TEST_ORIG_CTXT, | |
272 | LLOG_TEST_REPL_CTXT, | |
273 | LLOG_LOVEA_ORIG_CTXT, | |
274 | LLOG_LOVEA_REPL_CTXT, | |
99a92265 | 275 | LLOG_CHANGELOG_ORIG_CTXT, /**< changelog generation on mdd */ |
276 | LLOG_CHANGELOG_REPL_CTXT, /**< changelog access on clients */ | |
277 | LLOG_CHANGELOG_USER_ORIG_CTXT, /**< for multiple changelog consumers */ | |
278 | LLOG_AGENT_ORIG_CTXT, /**< agent requests generation on cdt */ | |
d7e09d03 PT |
279 | LLOG_MAX_CTXTS |
280 | }; | |
281 | ||
d7e09d03 PT |
282 | struct timeout_item { |
283 | enum timeout_event ti_event; | |
a649ad1d | 284 | unsigned long ti_timeout; |
d7e09d03 PT |
285 | timeout_cb_t ti_cb; |
286 | void *ti_cb_data; | |
287 | struct list_head ti_obd_list; | |
288 | struct list_head ti_chain; | |
289 | }; | |
290 | ||
291 | #define OSC_MAX_RIF_DEFAULT 8 | |
292 | #define MDS_OSC_MAX_RIF_DEFAULT 50 | |
293 | #define OSC_MAX_RIF_MAX 256 | |
294 | #define OSC_MAX_DIRTY_DEFAULT (OSC_MAX_RIF_DEFAULT * 4) | |
295 | #define OSC_MAX_DIRTY_MB_MAX 2048 /* arbitrary, but < MAX_LONG bytes */ | |
296 | #define OSC_DEFAULT_RESENDS 10 | |
297 | ||
298 | /* possible values for fo_sync_lock_cancel */ | |
299 | enum { | |
300 | NEVER_SYNC_ON_CANCEL = 0, | |
301 | BLOCKING_SYNC_ON_CANCEL = 1, | |
302 | ALWAYS_SYNC_ON_CANCEL = 2, | |
303 | NUM_SYNC_ON_CANCEL_STATES | |
304 | }; | |
305 | ||
306 | #define MDC_MAX_RIF_DEFAULT 8 | |
307 | #define MDC_MAX_RIF_MAX 512 | |
308 | ||
309 | struct mdc_rpc_lock; | |
310 | struct obd_import; | |
311 | struct client_obd { | |
312 | struct rw_semaphore cl_sem; | |
313 | struct obd_uuid cl_target_uuid; | |
314 | struct obd_import *cl_import; /* ptlrpc connection state */ | |
315 | int cl_conn_count; | |
316 | /* max_mds_easize is purely a performance thing so we don't have to | |
317 | * call obd_size_diskmd() all the time. */ | |
44779340 BB |
318 | int cl_default_mds_easize; |
319 | int cl_max_mds_easize; | |
320 | int cl_default_mds_cookiesize; | |
321 | int cl_max_mds_cookiesize; | |
d7e09d03 PT |
322 | |
323 | enum lustre_sec_part cl_sp_me; | |
324 | enum lustre_sec_part cl_sp_to; | |
325 | struct sptlrpc_flavor cl_flvr_mgc; /* fixed flavor of mgc->mgs */ | |
326 | ||
327 | /* the grant values are protected by loi_list_lock below */ | |
328 | long cl_dirty; /* all _dirty_ in bytes */ | |
329 | long cl_dirty_max; /* allowed w/o rpc */ | |
330 | long cl_dirty_transit; /* dirty synchronous */ | |
331 | long cl_avail_grant; /* bytes of credit for ost */ | |
332 | long cl_lost_grant; /* lost credits (trunc) */ | |
333 | ||
334 | /* since we allocate grant by blocks, we don't know how many grant will | |
335 | * be used to add a page into cache. As a solution, we reserve maximum | |
336 | * grant before trying to dirty a page and unreserve the rest. | |
337 | * See osc_{reserve|unreserve}_grant for details. */ | |
338 | long cl_reserved_grant; | |
339 | struct list_head cl_cache_waiters; /* waiting for cache/grant */ | |
a649ad1d | 340 | unsigned long cl_next_shrink_grant; /* jiffies */ |
d7e09d03 PT |
341 | struct list_head cl_grant_shrink_list; /* Timeout event list */ |
342 | int cl_grant_shrink_interval; /* seconds */ | |
343 | ||
344 | /* A chunk is an optimal size used by osc_extent to determine | |
345 | * the extent size. A chunk is max(PAGE_CACHE_SIZE, OST block size) */ | |
346 | int cl_chunkbits; | |
347 | int cl_chunk; | |
348 | int cl_extent_tax; /* extent overhead, by bytes */ | |
349 | ||
350 | /* keep track of objects that have lois that contain pages which | |
351 | * have been queued for async brw. this lock also protects the | |
352 | * lists of osc_client_pages that hang off of the loi */ | |
353 | /* | |
354 | * ->cl_loi_list_lock protects consistency of | |
355 | * ->cl_loi_{ready,read,write}_list. ->ap_make_ready() and | |
356 | * ->ap_completion() call-backs are executed under this lock. As we | |
357 | * cannot guarantee that these call-backs never block on all platforms | |
358 | * (as a matter of fact they do block on Mac OS X), type of | |
359 | * ->cl_loi_list_lock is platform dependent: it's a spin-lock on Linux | |
360 | * and blocking mutex on Mac OS X. (Alternative is to make this lock | |
361 | * blocking everywhere, but we don't want to slow down fast-path of | |
362 | * our main platform.) | |
363 | * | |
364 | * Exact type of ->cl_loi_list_lock is defined in arch/obd.h together | |
365 | * with client_obd_list_{un,}lock() and | |
366 | * client_obd_list_lock_{init,done}() functions. | |
367 | * | |
368 | * NB by Jinshan: though field names are still _loi_, but actually | |
369 | * osc_object{}s are in the list. | |
370 | */ | |
371 | client_obd_lock_t cl_loi_list_lock; | |
372 | struct list_head cl_loi_ready_list; | |
373 | struct list_head cl_loi_hp_ready_list; | |
374 | struct list_head cl_loi_write_list; | |
375 | struct list_head cl_loi_read_list; | |
376 | int cl_r_in_flight; | |
377 | int cl_w_in_flight; | |
378 | /* just a sum of the loi/lop pending numbers to be exported by /proc */ | |
379 | atomic_t cl_pending_w_pages; | |
380 | atomic_t cl_pending_r_pages; | |
381 | __u32 cl_max_pages_per_rpc; | |
382 | int cl_max_rpcs_in_flight; | |
383 | struct obd_histogram cl_read_rpc_hist; | |
384 | struct obd_histogram cl_write_rpc_hist; | |
385 | struct obd_histogram cl_read_page_hist; | |
386 | struct obd_histogram cl_write_page_hist; | |
387 | struct obd_histogram cl_read_offset_hist; | |
388 | struct obd_histogram cl_write_offset_hist; | |
389 | ||
390 | /* lru for osc caching pages */ | |
391 | struct cl_client_cache *cl_cache; | |
392 | struct list_head cl_lru_osc; /* member of cl_cache->ccc_lru */ | |
393 | atomic_t *cl_lru_left; | |
394 | atomic_t cl_lru_busy; | |
395 | atomic_t cl_lru_shrinkers; | |
396 | atomic_t cl_lru_in_list; | |
397 | struct list_head cl_lru_list; /* lru page list */ | |
398 | client_obd_lock_t cl_lru_list_lock; /* page list protector */ | |
399 | ||
400 | /* number of in flight destroy rpcs is limited to max_rpcs_in_flight */ | |
401 | atomic_t cl_destroy_in_flight; | |
402 | wait_queue_head_t cl_destroy_waitq; | |
403 | ||
404 | struct mdc_rpc_lock *cl_rpc_lock; | |
405 | struct mdc_rpc_lock *cl_close_lock; | |
406 | ||
407 | /* mgc datastruct */ | |
6246dab1 | 408 | struct mutex cl_mgc_mutex; |
aa4e3c8a MP |
409 | struct local_oid_storage *cl_mgc_los; |
410 | struct dt_object *cl_mgc_configs_dir; | |
d7e09d03 PT |
411 | atomic_t cl_mgc_refcount; |
412 | struct obd_export *cl_mgc_mgsexp; | |
413 | ||
414 | /* checksumming for data sent over the network */ | |
415 | unsigned int cl_checksum:1; /* 0 = disabled, 1 = enabled */ | |
416 | /* supported checksum types that are worked out at connect time */ | |
417 | __u32 cl_supp_cksum_types; | |
418 | /* checksum algorithm to be used */ | |
419 | cksum_type_t cl_cksum_type; | |
420 | ||
421 | /* also protected by the poorly named _loi_list_lock lock above */ | |
422 | struct osc_async_rc cl_ar; | |
423 | ||
424 | /* used by quotacheck when the servers are older than 2.4 */ | |
425 | int cl_qchk_stat; /* quotacheck stat of the peer */ | |
426 | #define CL_NOT_QUOTACHECKED 1 /* client->cl_qchk_stat init value */ | |
427 | #if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 7, 50, 0) | |
428 | #warning "please consider removing quotacheck compatibility code" | |
429 | #endif | |
430 | ||
431 | /* sequence manager */ | |
432 | struct lu_client_seq *cl_seq; | |
433 | ||
434 | atomic_t cl_resends; /* resend count */ | |
435 | ||
436 | /* ptlrpc work for writeback in ptlrpcd context */ | |
437 | void *cl_writeback_work; | |
438 | /* hash tables for osc_quota_info */ | |
6da6eabe | 439 | struct cfs_hash *cl_quota_hash[MAXQUOTAS]; |
d7e09d03 PT |
440 | }; |
441 | #define obd2cli_tgt(obd) ((char *)(obd)->u.cli.cl_target_uuid.uuid) | |
442 | ||
443 | struct obd_id_info { | |
444 | __u32 idx; | |
445 | obd_id *data; | |
446 | }; | |
447 | ||
d7e09d03 PT |
448 | struct echo_client_obd { |
449 | struct obd_export *ec_exp; /* the local connection to osc/lov */ | |
450 | spinlock_t ec_lock; | |
451 | struct list_head ec_objects; | |
452 | struct list_head ec_locks; | |
453 | int ec_nstripes; | |
454 | __u64 ec_unique; | |
455 | }; | |
456 | ||
457 | struct lov_qos_oss { | |
458 | struct obd_uuid lqo_uuid; /* ptlrpc's c_remote_uuid */ | |
459 | struct list_head lqo_oss_list; /* link to lov_qos */ | |
460 | __u64 lqo_bavail; /* total bytes avail on OSS */ | |
461 | __u64 lqo_penalty; /* current penalty */ | |
462 | __u64 lqo_penalty_per_obj;/* penalty decrease every obj*/ | |
463 | time_t lqo_used; /* last used time, seconds */ | |
464 | __u32 lqo_ost_count; /* number of osts on this oss */ | |
465 | }; | |
466 | ||
467 | struct ltd_qos { | |
468 | struct lov_qos_oss *ltq_oss; /* oss info */ | |
469 | __u64 ltq_penalty; /* current penalty */ | |
470 | __u64 ltq_penalty_per_obj; /* penalty decrease every obj*/ | |
471 | __u64 ltq_weight; /* net weighting */ | |
472 | time_t ltq_used; /* last used time, seconds */ | |
473 | unsigned int ltq_usable:1; /* usable for striping */ | |
474 | }; | |
475 | ||
476 | /* Generic subset of OSTs */ | |
477 | struct ost_pool { | |
478 | __u32 *op_array; /* array of index of | |
479 | lov_obd->lov_tgts */ | |
480 | unsigned int op_count; /* number of OSTs in the array */ | |
481 | unsigned int op_size; /* allocated size of lp_array */ | |
482 | struct rw_semaphore op_rw_sem; /* to protect ost_pool use */ | |
483 | }; | |
484 | ||
485 | /* Round-robin allocator data */ | |
486 | struct lov_qos_rr { | |
487 | __u32 lqr_start_idx; /* start index of new inode */ | |
488 | __u32 lqr_offset_idx; /* aliasing for start_idx */ | |
489 | int lqr_start_count; /* reseed counter */ | |
490 | struct ost_pool lqr_pool; /* round-robin optimized list */ | |
491 | unsigned long lqr_dirty:1; /* recalc round-robin list */ | |
492 | }; | |
493 | ||
494 | /* allow statfs data caching for 1 second */ | |
495 | #define OBD_STATFS_CACHE_SECONDS 1 | |
496 | ||
497 | struct lov_statfs_data { | |
498 | struct obd_info lsd_oi; | |
499 | struct obd_statfs lsd_statfs; | |
500 | }; | |
501 | /* Stripe placement optimization */ | |
502 | struct lov_qos { | |
503 | struct list_head lq_oss_list; /* list of OSSs that targets use */ | |
504 | struct rw_semaphore lq_rw_sem; | |
505 | __u32 lq_active_oss_count; | |
506 | unsigned int lq_prio_free; /* priority for free space */ | |
507 | unsigned int lq_threshold_rr;/* priority for rr */ | |
508 | struct lov_qos_rr lq_rr; /* round robin qos data */ | |
509 | unsigned long lq_dirty:1, /* recalc qos data */ | |
510 | lq_same_space:1,/* the ost's all have approx. | |
511 | the same space avail */ | |
512 | lq_reset:1, /* zero current penalties */ | |
513 | lq_statfs_in_progress:1; /* statfs op in | |
514 | progress */ | |
515 | /* qos statfs data */ | |
516 | struct lov_statfs_data *lq_statfs_data; | |
517 | wait_queue_head_t lq_statfs_waitq; /* waitqueue to notify statfs | |
518 | * requests completion */ | |
519 | }; | |
520 | ||
521 | struct lov_tgt_desc { | |
522 | struct list_head ltd_kill; | |
523 | struct obd_uuid ltd_uuid; | |
524 | struct obd_device *ltd_obd; | |
525 | struct obd_export *ltd_exp; | |
526 | struct ltd_qos ltd_qos; /* qos info per target */ | |
527 | __u32 ltd_gen; | |
528 | __u32 ltd_index; /* index in lov_obd->tgts */ | |
529 | unsigned long ltd_active:1,/* is this target up for requests */ | |
530 | ltd_activate:1,/* should target be activated */ | |
531 | ltd_reap:1; /* should this target be deleted */ | |
532 | }; | |
533 | ||
534 | /* Pool metadata */ | |
535 | #define pool_tgt_size(_p) _p->pool_obds.op_size | |
536 | #define pool_tgt_count(_p) _p->pool_obds.op_count | |
537 | #define pool_tgt_array(_p) _p->pool_obds.op_array | |
538 | #define pool_tgt_rw_sem(_p) _p->pool_obds.op_rw_sem | |
539 | ||
540 | struct pool_desc { | |
541 | char pool_name[LOV_MAXPOOLNAME + 1]; /* name of pool */ | |
542 | struct ost_pool pool_obds; /* pool members */ | |
543 | atomic_t pool_refcount; /* pool ref. counter */ | |
544 | struct lov_qos_rr pool_rr; /* round robin qos */ | |
545 | struct hlist_node pool_hash; /* access by poolname */ | |
546 | struct list_head pool_list; /* serial access */ | |
b59fe845 | 547 | struct proc_dir_entry *pool_proc_entry; /* file in /proc */ |
d7e09d03 PT |
548 | struct obd_device *pool_lobd; /* obd of the lov/lod to which |
549 | * this pool belongs */ | |
550 | }; | |
551 | ||
552 | struct lov_obd { | |
553 | struct lov_desc desc; | |
554 | struct lov_tgt_desc **lov_tgts; /* sparse array */ | |
555 | struct ost_pool lov_packed; /* all OSTs in a packed | |
556 | array */ | |
557 | struct mutex lov_lock; | |
558 | struct obd_connect_data lov_ocd; | |
559 | atomic_t lov_refcount; | |
560 | __u32 lov_tgt_count; /* how many OBD's */ | |
561 | __u32 lov_active_tgt_count; /* how many active */ | |
562 | __u32 lov_death_row;/* tgts scheduled to be deleted */ | |
563 | __u32 lov_tgt_size; /* size of tgts array */ | |
564 | int lov_connects; | |
565 | int lov_pool_count; | |
6da6eabe | 566 | struct cfs_hash *lov_pools_hash_body; /* used for key access */ |
d7e09d03 | 567 | struct list_head lov_pool_list; /* used for sequential access */ |
b59fe845 | 568 | struct proc_dir_entry *lov_pool_proc_entry; |
d7e09d03 PT |
569 | enum lustre_sec_part lov_sp_me; |
570 | ||
c52f69c5 | 571 | /* Cached LRU pages from upper layer */ |
d7e09d03 PT |
572 | void *lov_cache; |
573 | ||
574 | struct rw_semaphore lov_notify_lock; | |
575 | }; | |
576 | ||
577 | struct lmv_tgt_desc { | |
578 | struct obd_uuid ltd_uuid; | |
579 | struct obd_export *ltd_exp; | |
580 | int ltd_idx; | |
581 | struct mutex ltd_fid_mutex; | |
582 | unsigned long ltd_active:1; /* target up for requests */ | |
583 | }; | |
584 | ||
585 | enum placement_policy { | |
586 | PLACEMENT_CHAR_POLICY = 0, | |
587 | PLACEMENT_NID_POLICY = 1, | |
588 | PLACEMENT_INVAL_POLICY = 2, | |
589 | PLACEMENT_MAX_POLICY | |
590 | }; | |
591 | ||
592 | typedef enum placement_policy placement_policy_t; | |
593 | ||
594 | struct lmv_obd { | |
595 | int refcount; | |
596 | struct lu_client_fld lmv_fld; | |
597 | spinlock_t lmv_lock; | |
598 | placement_policy_t lmv_placement; | |
599 | struct lmv_desc desc; | |
600 | struct obd_uuid cluuid; | |
601 | struct obd_export *exp; | |
602 | ||
603 | struct mutex init_mutex; | |
604 | int connected; | |
605 | int max_easize; | |
606 | int max_def_easize; | |
607 | int max_cookiesize; | |
44779340 | 608 | int max_def_cookiesize; |
d7e09d03 PT |
609 | int server_timeout; |
610 | ||
611 | int tgts_size; /* size of tgts array */ | |
612 | struct lmv_tgt_desc **tgts; | |
613 | ||
614 | struct obd_connect_data conn_data; | |
615 | }; | |
616 | ||
617 | struct niobuf_local { | |
618 | __u64 lnb_file_offset; | |
619 | __u32 lnb_page_offset; | |
620 | __u32 len; | |
621 | __u32 flags; | |
622 | struct page *page; | |
623 | struct dentry *dentry; | |
624 | int lnb_grant_used; | |
625 | int rc; | |
626 | }; | |
627 | ||
628 | #define LUSTRE_FLD_NAME "fld" | |
629 | #define LUSTRE_SEQ_NAME "seq" | |
630 | ||
631 | #define LUSTRE_MDD_NAME "mdd" | |
632 | #define LUSTRE_OSD_LDISKFS_NAME "osd-ldiskfs" | |
633 | #define LUSTRE_OSD_ZFS_NAME "osd-zfs" | |
634 | #define LUSTRE_VVP_NAME "vvp" | |
635 | #define LUSTRE_LMV_NAME "lmv" | |
636 | #define LUSTRE_SLP_NAME "slp" | |
637 | #define LUSTRE_LOD_NAME "lod" | |
638 | #define LUSTRE_OSP_NAME "osp" | |
639 | #define LUSTRE_LWP_NAME "lwp" | |
640 | ||
641 | /* obd device type names */ | |
642 | /* FIXME all the references to LUSTRE_MDS_NAME should be swapped with LUSTRE_MDT_NAME */ | |
643 | #define LUSTRE_MDS_NAME "mds" | |
644 | #define LUSTRE_MDT_NAME "mdt" | |
645 | #define LUSTRE_MDC_NAME "mdc" | |
646 | #define LUSTRE_OSS_NAME "ost" /* FIXME change name to oss */ | |
647 | #define LUSTRE_OST_NAME "obdfilter" /* FIXME change name to ost */ | |
648 | #define LUSTRE_OSC_NAME "osc" | |
649 | #define LUSTRE_LOV_NAME "lov" | |
650 | #define LUSTRE_MGS_NAME "mgs" | |
651 | #define LUSTRE_MGC_NAME "mgc" | |
652 | ||
653 | #define LUSTRE_ECHO_NAME "obdecho" | |
654 | #define LUSTRE_ECHO_CLIENT_NAME "echo_client" | |
655 | #define LUSTRE_QMT_NAME "qmt" | |
656 | ||
657 | /* Constant obd names (post-rename) */ | |
658 | #define LUSTRE_MDS_OBDNAME "MDS" | |
659 | #define LUSTRE_OSS_OBDNAME "OSS" | |
660 | #define LUSTRE_MGS_OBDNAME "MGS" | |
661 | #define LUSTRE_MGC_OBDNAME "MGC" | |
662 | ||
663 | static inline int is_osp_on_mdt(char *name) | |
664 | { | |
665 | char *ptr; | |
666 | ||
667 | ptr = strrchr(name, '-'); | |
668 | if (ptr == NULL) { | |
669 | CERROR("%s is not a obdname\n", name); | |
670 | return 0; | |
671 | } | |
672 | ||
673 | /* 1.8 OSC/OSP name on MDT is fsname-OSTxxxx-osc */ | |
674 | if (strncmp(ptr + 1, "osc", 3) == 0) | |
675 | return 1; | |
676 | ||
677 | if (strncmp(ptr + 1, "MDT", 3) != 0) | |
678 | return 0; | |
679 | ||
680 | while (*(--ptr) != '-' && ptr != name); | |
681 | ||
682 | if (ptr == name) | |
683 | return 0; | |
684 | ||
685 | if (strncmp(ptr + 1, LUSTRE_OSP_NAME, strlen(LUSTRE_OSP_NAME)) != 0 && | |
686 | strncmp(ptr + 1, LUSTRE_OSC_NAME, strlen(LUSTRE_OSC_NAME)) != 0) | |
687 | return 0; | |
688 | ||
689 | return 1; | |
690 | } | |
691 | ||
692 | /* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */ | |
693 | #define N_LOCAL_TEMP_PAGE 0x10000000 | |
694 | ||
695 | struct obd_trans_info { | |
696 | __u64 oti_transno; | |
697 | __u64 oti_xid; | |
698 | /* Only used on the server side for tracking acks. */ | |
699 | struct oti_req_ack_lock { | |
700 | struct lustre_handle lock; | |
701 | __u32 mode; | |
702 | } oti_ack_locks[4]; | |
703 | void *oti_handle; | |
704 | struct llog_cookie oti_onecookie; | |
705 | struct llog_cookie *oti_logcookies; | |
706 | int oti_numcookies; | |
707 | /** synchronous write is needed */ | |
708 | unsigned long oti_sync_write:1; | |
709 | ||
710 | /* initial thread handling transaction */ | |
711 | struct ptlrpc_thread * oti_thread; | |
712 | __u32 oti_conn_cnt; | |
713 | /** VBR: versions */ | |
714 | __u64 oti_pre_version; | |
715 | /** JobID */ | |
716 | char *oti_jobid; | |
717 | ||
718 | struct obd_uuid *oti_ost_uuid; | |
719 | }; | |
720 | ||
721 | static inline void oti_init(struct obd_trans_info *oti, | |
722 | struct ptlrpc_request *req) | |
723 | { | |
724 | if (oti == NULL) | |
725 | return; | |
726 | memset(oti, 0, sizeof(*oti)); | |
727 | ||
728 | if (req == NULL) | |
729 | return; | |
730 | ||
731 | oti->oti_xid = req->rq_xid; | |
732 | /** VBR: take versions from request */ | |
733 | if (req->rq_reqmsg != NULL && | |
734 | lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) { | |
735 | __u64 *pre_version = lustre_msg_get_versions(req->rq_reqmsg); | |
736 | oti->oti_pre_version = pre_version ? pre_version[0] : 0; | |
737 | oti->oti_transno = lustre_msg_get_transno(req->rq_reqmsg); | |
738 | } | |
739 | ||
740 | /** called from mds_create_objects */ | |
741 | if (req->rq_repmsg != NULL) | |
742 | oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg); | |
743 | oti->oti_thread = req->rq_svc_thread; | |
744 | if (req->rq_reqmsg != NULL) | |
745 | oti->oti_conn_cnt = lustre_msg_get_conn_cnt(req->rq_reqmsg); | |
746 | } | |
747 | ||
748 | static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies) | |
749 | { | |
750 | if (!oti) | |
751 | return; | |
752 | ||
753 | if (num_cookies == 1) | |
754 | oti->oti_logcookies = &oti->oti_onecookie; | |
755 | else | |
756 | OBD_ALLOC_LARGE(oti->oti_logcookies, | |
757 | num_cookies * sizeof(oti->oti_onecookie)); | |
758 | ||
759 | oti->oti_numcookies = num_cookies; | |
760 | } | |
761 | ||
762 | static inline void oti_free_cookies(struct obd_trans_info *oti) | |
763 | { | |
764 | if (!oti || !oti->oti_logcookies) | |
765 | return; | |
766 | ||
767 | if (oti->oti_logcookies == &oti->oti_onecookie) | |
768 | LASSERT(oti->oti_numcookies == 1); | |
769 | else | |
770 | OBD_FREE_LARGE(oti->oti_logcookies, | |
771 | oti->oti_numcookies*sizeof(oti->oti_onecookie)); | |
772 | oti->oti_logcookies = NULL; | |
773 | oti->oti_numcookies = 0; | |
774 | } | |
775 | ||
776 | /* | |
777 | * Events signalled through obd_notify() upcall-chain. | |
778 | */ | |
779 | enum obd_notify_event { | |
780 | /* target added */ | |
781 | OBD_NOTIFY_CREATE, | |
782 | /* Device connect start */ | |
783 | OBD_NOTIFY_CONNECT, | |
784 | /* Device activated */ | |
785 | OBD_NOTIFY_ACTIVE, | |
786 | /* Device deactivated */ | |
787 | OBD_NOTIFY_INACTIVE, | |
788 | /* Device disconnected */ | |
789 | OBD_NOTIFY_DISCON, | |
790 | /* Connect data for import were changed */ | |
791 | OBD_NOTIFY_OCD, | |
792 | /* Sync request */ | |
793 | OBD_NOTIFY_SYNC_NONBLOCK, | |
794 | OBD_NOTIFY_SYNC, | |
795 | /* Configuration event */ | |
796 | OBD_NOTIFY_CONFIG, | |
797 | /* Administratively deactivate/activate event */ | |
798 | OBD_NOTIFY_DEACTIVATE, | |
799 | OBD_NOTIFY_ACTIVATE | |
800 | }; | |
801 | ||
d7e09d03 PT |
802 | /* |
803 | * Data structure used to pass obd_notify()-event to non-obd listeners (llite | |
804 | * and liblustre being main examples). | |
805 | */ | |
806 | struct obd_notify_upcall { | |
807 | int (*onu_upcall)(struct obd_device *host, struct obd_device *watched, | |
808 | enum obd_notify_event ev, void *owner, void *data); | |
809 | /* Opaque datum supplied by upper layer listener */ | |
810 | void *onu_owner; | |
811 | }; | |
812 | ||
813 | struct target_recovery_data { | |
814 | svc_handler_t trd_recovery_handler; | |
815 | pid_t trd_processing_task; | |
816 | struct completion trd_starting; | |
817 | struct completion trd_finishing; | |
818 | }; | |
819 | ||
820 | struct obd_llog_group { | |
821 | int olg_seq; | |
822 | struct llog_ctxt *olg_ctxts[LLOG_MAX_CTXTS]; | |
823 | wait_queue_head_t olg_waitq; | |
824 | spinlock_t olg_lock; | |
825 | struct mutex olg_cat_processing; | |
826 | }; | |
827 | ||
828 | /* corresponds to one of the obd's */ | |
829 | #define OBD_DEVICE_MAGIC 0XAB5CD6EF | |
830 | #define OBD_DEV_BY_DEVNAME 0xffffd0de | |
831 | ||
832 | struct obd_device { | |
833 | struct obd_type *obd_type; | |
834 | __u32 obd_magic; | |
835 | ||
836 | /* common and UUID name of this device */ | |
837 | char obd_name[MAX_OBD_NAME]; | |
838 | struct obd_uuid obd_uuid; | |
839 | ||
840 | struct lu_device *obd_lu_dev; | |
841 | ||
842 | int obd_minor; | |
843 | /* bitfield modification is protected by obd_dev_lock */ | |
844 | unsigned long obd_attached:1, /* finished attach */ | |
845 | obd_set_up:1, /* finished setup */ | |
846 | obd_recovering:1, /* there are recoverable clients */ | |
847 | obd_abort_recovery:1,/* recovery expired */ | |
848 | obd_version_recov:1, /* obd uses version checking */ | |
849 | obd_replayable:1, /* recovery is enabled; inform clients */ | |
850 | obd_no_transno:1, /* no committed-transno notification */ | |
851 | obd_no_recov:1, /* fail instead of retry messages */ | |
852 | obd_stopping:1, /* started cleanup */ | |
853 | obd_starting:1, /* started setup */ | |
854 | obd_force:1, /* cleanup with > 0 obd refcount */ | |
855 | obd_fail:1, /* cleanup with failover */ | |
856 | obd_async_recov:1, /* allow asynchronous orphan cleanup */ | |
857 | obd_no_conn:1, /* deny new connections */ | |
858 | obd_inactive:1, /* device active/inactive | |
859 | * (for /proc/status only!!) */ | |
860 | obd_no_ir:1, /* no imperative recovery. */ | |
861 | obd_process_conf:1; /* device is processing mgs config */ | |
862 | /* use separate field as it is set in interrupt to don't mess with | |
863 | * protection of other bits using _bh lock */ | |
864 | unsigned long obd_recovery_expired:1; | |
865 | /* uuid-export hash body */ | |
6da6eabe | 866 | struct cfs_hash *obd_uuid_hash; |
d7e09d03 | 867 | /* nid-export hash body */ |
6da6eabe | 868 | struct cfs_hash *obd_nid_hash; |
d7e09d03 | 869 | /* nid stats body */ |
6da6eabe | 870 | struct cfs_hash *obd_nid_stats_hash; |
d7e09d03 PT |
871 | struct list_head obd_nid_stats; |
872 | atomic_t obd_refcount; | |
873 | wait_queue_head_t obd_refcount_waitq; | |
874 | struct list_head obd_exports; | |
875 | struct list_head obd_unlinked_exports; | |
876 | struct list_head obd_delayed_exports; | |
877 | int obd_num_exports; | |
878 | spinlock_t obd_nid_lock; | |
879 | struct ldlm_namespace *obd_namespace; | |
880 | struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */ | |
881 | /* a spinlock is OK for what we do now, may need a semaphore later */ | |
882 | spinlock_t obd_dev_lock; /* protect OBD bitfield above */ | |
883 | struct mutex obd_dev_mutex; | |
884 | __u64 obd_last_committed; | |
885 | struct fsfilt_operations *obd_fsops; | |
886 | spinlock_t obd_osfs_lock; | |
887 | struct obd_statfs obd_osfs; /* locked by obd_osfs_lock */ | |
888 | __u64 obd_osfs_age; | |
889 | struct lvfs_run_ctxt obd_lvfs_ctxt; | |
890 | struct obd_llog_group obd_olg; /* default llog group */ | |
891 | struct obd_device *obd_observer; | |
892 | struct rw_semaphore obd_observer_link_sem; | |
893 | struct obd_notify_upcall obd_upcall; | |
894 | struct obd_export *obd_self_export; | |
895 | /* list of exports in LRU order, for ping evictor, with obd_dev_lock */ | |
896 | struct list_head obd_exports_timed; | |
897 | time_t obd_eviction_timer; /* for ping evictor */ | |
898 | ||
899 | int obd_max_recoverable_clients; | |
900 | atomic_t obd_connected_clients; | |
901 | int obd_stale_clients; | |
902 | int obd_delayed_clients; | |
903 | /* this lock protects all recovery list_heads, timer and | |
904 | * obd_next_recovery_transno value */ | |
905 | spinlock_t obd_recovery_task_lock; | |
906 | __u64 obd_next_recovery_transno; | |
907 | int obd_replayed_requests; | |
908 | int obd_requests_queued_for_recovery; | |
909 | wait_queue_head_t obd_next_transno_waitq; | |
910 | /* protected by obd_recovery_task_lock */ | |
54319351 | 911 | struct timer_list obd_recovery_timer; |
d7e09d03 PT |
912 | time_t obd_recovery_start; /* seconds */ |
913 | time_t obd_recovery_end; /* seconds, for lprocfs_status */ | |
914 | int obd_recovery_time_hard; | |
915 | int obd_recovery_timeout; | |
916 | int obd_recovery_ir_factor; | |
917 | ||
918 | /* new recovery stuff from CMD2 */ | |
919 | struct target_recovery_data obd_recovery_data; | |
920 | int obd_replayed_locks; | |
921 | atomic_t obd_req_replay_clients; | |
922 | atomic_t obd_lock_replay_clients; | |
923 | /* all lists are protected by obd_recovery_task_lock */ | |
924 | struct list_head obd_req_replay_queue; | |
925 | struct list_head obd_lock_replay_queue; | |
926 | struct list_head obd_final_req_queue; | |
927 | int obd_recovery_stage; | |
928 | ||
929 | union { | |
d7e09d03 | 930 | struct client_obd cli; |
d7e09d03 | 931 | struct echo_client_obd echo_client; |
d7e09d03 PT |
932 | struct lov_obd lov; |
933 | struct lmv_obd lmv; | |
934 | } u; | |
935 | /* Fields used by LProcFS */ | |
936 | unsigned int obd_cntr_base; | |
937 | struct lprocfs_stats *obd_stats; | |
938 | ||
939 | unsigned int md_cntr_base; | |
940 | struct lprocfs_stats *md_stats; | |
941 | ||
b59fe845 | 942 | struct proc_dir_entry *obd_proc_entry; |
73bb1da6 | 943 | void *obd_proc_private; /* type private PDEs */ |
b59fe845 GKH |
944 | struct proc_dir_entry *obd_proc_exports_entry; |
945 | struct proc_dir_entry *obd_svc_procroot; | |
d7e09d03 PT |
946 | struct lprocfs_stats *obd_svc_stats; |
947 | atomic_t obd_evict_inprogress; | |
948 | wait_queue_head_t obd_evict_inprogress_waitq; | |
949 | struct list_head obd_evict_list; /* protected with pet_lock */ | |
950 | ||
951 | /** | |
952 | * Ldlm pool part. Save last calculated SLV and Limit. | |
953 | */ | |
954 | rwlock_t obd_pool_lock; | |
955 | int obd_pool_limit; | |
956 | __u64 obd_pool_slv; | |
957 | ||
958 | /** | |
959 | * A list of outstanding class_incref()'s against this obd. For | |
960 | * debugging. | |
961 | */ | |
962 | struct lu_ref obd_reference; | |
963 | ||
964 | int obd_conn_inprogress; | |
965 | }; | |
966 | ||
967 | #define OBD_LLOG_FL_SENDNOW 0x0001 | |
968 | #define OBD_LLOG_FL_EXIT 0x0002 | |
969 | ||
970 | enum obd_cleanup_stage { | |
971 | /* Special case hack for MDS LOVs */ | |
972 | OBD_CLEANUP_EARLY, | |
973 | /* can be directly mapped to .ldto_device_fini() */ | |
974 | OBD_CLEANUP_EXPORTS, | |
975 | }; | |
976 | ||
977 | /* get/set_info keys */ | |
978 | #define KEY_ASYNC "async" | |
979 | #define KEY_BLOCKSIZE_BITS "blocksize_bits" | |
980 | #define KEY_BLOCKSIZE "blocksize" | |
981 | #define KEY_CAPA_KEY "capa_key" | |
982 | #define KEY_CHANGELOG_CLEAR "changelog_clear" | |
983 | #define KEY_FID2PATH "fid2path" | |
984 | #define KEY_CHECKSUM "checksum" | |
985 | #define KEY_CLEAR_FS "clear_fs" | |
986 | #define KEY_CONN_DATA "conn_data" | |
987 | #define KEY_EVICT_BY_NID "evict_by_nid" | |
988 | #define KEY_FIEMAP "fiemap" | |
989 | #define KEY_FLUSH_CTX "flush_ctx" | |
990 | #define KEY_GRANT_SHRINK "grant_shrink" | |
991 | #define KEY_HSM_COPYTOOL_SEND "hsm_send" | |
992 | #define KEY_INIT_RECOV_BACKUP "init_recov_bk" | |
993 | #define KEY_INIT_RECOV "initial_recov" | |
994 | #define KEY_INTERMDS "inter_mds" | |
995 | #define KEY_LAST_ID "last_id" | |
996 | #define KEY_LAST_FID "last_fid" | |
997 | #define KEY_LOCK_TO_STRIPE "lock_to_stripe" | |
998 | #define KEY_LOVDESC "lovdesc" | |
999 | #define KEY_LOV_IDX "lov_idx" | |
44779340 BB |
1000 | #define KEY_MAX_EASIZE "max_easize" |
1001 | #define KEY_DEFAULT_EASIZE "default_easize" | |
1002 | #define KEY_MAX_COOKIESIZE "max_cookiesize" | |
1003 | #define KEY_DEFAULT_COOKIESIZE "default_cookiesize" | |
d7e09d03 PT |
1004 | #define KEY_MDS_CONN "mds_conn" |
1005 | #define KEY_MGSSEC "mgssec" | |
1006 | #define KEY_NEXT_ID "next_id" | |
1007 | #define KEY_READ_ONLY "read-only" | |
1008 | #define KEY_REGISTER_TARGET "register_target" | |
1009 | #define KEY_SET_FS "set_fs" | |
1010 | #define KEY_TGT_COUNT "tgt_count" | |
1011 | /* KEY_SET_INFO in lustre_idl.h */ | |
1012 | #define KEY_SPTLRPC_CONF "sptlrpc_conf" | |
1013 | #define KEY_CONNECT_FLAG "connect_flags" | |
1014 | #define KEY_SYNC_LOCK_CANCEL "sync_lock_cancel" | |
1015 | ||
1016 | #define KEY_CACHE_SET "cache_set" | |
1017 | #define KEY_CACHE_LRU_SHRINK "cache_lru_shrink" | |
1018 | #define KEY_CHANGELOG_INDEX "changelog_index" | |
1019 | ||
1020 | struct lu_context; | |
1021 | ||
1022 | /* /!\ must be coherent with include/linux/namei.h on patched kernel */ | |
1023 | #define IT_OPEN (1 << 0) | |
1024 | #define IT_CREAT (1 << 1) | |
1025 | #define IT_READDIR (1 << 2) | |
1026 | #define IT_GETATTR (1 << 3) | |
1027 | #define IT_LOOKUP (1 << 4) | |
1028 | #define IT_UNLINK (1 << 5) | |
1029 | #define IT_TRUNC (1 << 6) | |
1030 | #define IT_GETXATTR (1 << 7) | |
1031 | #define IT_EXEC (1 << 8) | |
1032 | #define IT_PIN (1 << 9) | |
1033 | #define IT_LAYOUT (1 << 10) | |
1034 | #define IT_QUOTA_DQACQ (1 << 11) | |
1035 | #define IT_QUOTA_CONN (1 << 12) | |
7fc1f831 | 1036 | #define IT_SETXATTR (1 << 13) |
d7e09d03 PT |
1037 | |
1038 | static inline int it_to_lock_mode(struct lookup_intent *it) | |
1039 | { | |
1040 | /* CREAT needs to be tested before open (both could be set) */ | |
1041 | if (it->it_op & IT_CREAT) | |
1042 | return LCK_CW; | |
1043 | else if (it->it_op & (IT_READDIR | IT_GETATTR | IT_OPEN | IT_LOOKUP | | |
1044 | IT_LAYOUT)) | |
1045 | return LCK_CR; | |
7fc1f831 AP |
1046 | else if (it->it_op & IT_GETXATTR) |
1047 | return LCK_PR; | |
1048 | else if (it->it_op & IT_SETXATTR) | |
1049 | return LCK_PW; | |
d7e09d03 PT |
1050 | |
1051 | LASSERTF(0, "Invalid it_op: %d\n", it->it_op); | |
1052 | return -EINVAL; | |
1053 | } | |
1054 | ||
1055 | struct md_op_data { | |
17891183 MI |
1056 | struct lu_fid op_fid1; /* operation fid1 (usually parent) */ |
1057 | struct lu_fid op_fid2; /* operation fid2 (usually child) */ | |
d7e09d03 PT |
1058 | struct lu_fid op_fid3; /* 2 extra fids to find conflicting */ |
1059 | struct lu_fid op_fid4; /* to the operation locks. */ | |
114acca8 | 1060 | u32 op_mds; /* what mds server open will go to */ |
d7e09d03 PT |
1061 | struct lustre_handle op_handle; |
1062 | obd_time op_mod_time; | |
1063 | const char *op_name; | |
1064 | int op_namelen; | |
1065 | __u32 op_mode; | |
1066 | struct lmv_stripe_md *op_mea1; | |
1067 | struct lmv_stripe_md *op_mea2; | |
1068 | __u32 op_suppgids[2]; | |
1069 | __u32 op_fsuid; | |
1070 | __u32 op_fsgid; | |
1071 | cfs_cap_t op_cap; | |
1072 | void *op_data; | |
1073 | ||
1074 | /* iattr fields and blocks. */ | |
1075 | struct iattr op_attr; | |
1076 | unsigned int op_attr_flags; | |
1077 | __u64 op_valid; | |
1078 | loff_t op_attr_blocks; | |
1079 | ||
1080 | /* Size-on-MDS epoch and flags. */ | |
1081 | __u64 op_ioepoch; | |
1082 | __u32 op_flags; | |
1083 | ||
1084 | /* Capa fields */ | |
1085 | struct obd_capa *op_capa1; | |
1086 | struct obd_capa *op_capa2; | |
1087 | ||
1088 | /* Various operation flags. */ | |
48d23e61 | 1089 | enum mds_op_bias op_bias; |
d7e09d03 PT |
1090 | |
1091 | /* Operation type */ | |
1092 | __u32 op_opc; | |
1093 | ||
1094 | /* Used by readdir */ | |
1095 | __u64 op_offset; | |
1096 | ||
1097 | /* Used by readdir */ | |
1098 | __u32 op_npages; | |
1099 | ||
1100 | /* used to transfer info between the stacks of MD client | |
1101 | * see enum op_cli_flags */ | |
1102 | __u32 op_cli_flags; | |
48d23e61 JX |
1103 | |
1104 | /* File object data version for HSM release, on client */ | |
1105 | __u64 op_data_version; | |
1106 | struct lustre_handle op_lease_handle; | |
d7e09d03 PT |
1107 | }; |
1108 | ||
1109 | enum op_cli_flags { | |
1110 | CLI_SET_MEA = 1 << 0, | |
1111 | CLI_RM_ENTRY = 1 << 1, | |
1112 | }; | |
1113 | ||
1114 | struct md_enqueue_info; | |
1115 | /* metadata stat-ahead */ | |
1116 | typedef int (* md_enqueue_cb_t)(struct ptlrpc_request *req, | |
1117 | struct md_enqueue_info *minfo, | |
1118 | int rc); | |
1119 | ||
d7e09d03 PT |
1120 | struct md_enqueue_info { |
1121 | struct md_op_data mi_data; | |
1122 | struct lookup_intent mi_it; | |
1123 | struct lustre_handle mi_lockh; | |
1124 | struct inode *mi_dir; | |
1125 | md_enqueue_cb_t mi_cb; | |
1126 | __u64 mi_cbdata; | |
1127 | unsigned int mi_generation; | |
1128 | }; | |
1129 | ||
1130 | struct obd_ops { | |
c34d9cd8 | 1131 | struct module *o_owner; |
d7e09d03 PT |
1132 | int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len, |
1133 | void *karg, void *uarg); | |
1134 | int (*o_get_info)(const struct lu_env *env, struct obd_export *, | |
1135 | __u32 keylen, void *key, __u32 *vallen, void *val, | |
1136 | struct lov_stripe_md *lsm); | |
1137 | int (*o_set_info_async)(const struct lu_env *, struct obd_export *, | |
1138 | __u32 keylen, void *key, | |
1139 | __u32 vallen, void *val, | |
1140 | struct ptlrpc_request_set *set); | |
1141 | int (*o_attach)(struct obd_device *dev, obd_count len, void *data); | |
1142 | int (*o_detach)(struct obd_device *dev); | |
1143 | int (*o_setup) (struct obd_device *dev, struct lustre_cfg *cfg); | |
1144 | int (*o_precleanup)(struct obd_device *dev, | |
1145 | enum obd_cleanup_stage cleanup_stage); | |
1146 | int (*o_cleanup)(struct obd_device *dev); | |
1147 | int (*o_process_config)(struct obd_device *dev, obd_count len, | |
1148 | void *data); | |
1149 | int (*o_postrecov)(struct obd_device *dev); | |
1150 | int (*o_add_conn)(struct obd_import *imp, struct obd_uuid *uuid, | |
1151 | int priority); | |
1152 | int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid); | |
1153 | /* connect to the target device with given connection | |
1154 | * data. @ocd->ocd_connect_flags is modified to reflect flags actually | |
1155 | * granted by the target, which are guaranteed to be a subset of flags | |
1156 | * asked for. If @ocd == NULL, use default parameters. */ | |
1157 | int (*o_connect)(const struct lu_env *env, | |
1158 | struct obd_export **exp, struct obd_device *src, | |
1159 | struct obd_uuid *cluuid, struct obd_connect_data *ocd, | |
1160 | void *localdata); | |
1161 | int (*o_reconnect)(const struct lu_env *env, | |
1162 | struct obd_export *exp, struct obd_device *src, | |
1163 | struct obd_uuid *cluuid, | |
1164 | struct obd_connect_data *ocd, | |
1165 | void *localdata); | |
1166 | int (*o_disconnect)(struct obd_export *exp); | |
1167 | ||
1168 | /* Initialize/finalize fids infrastructure. */ | |
1169 | int (*o_fid_init)(struct obd_device *obd, | |
1170 | struct obd_export *exp, enum lu_cli_type type); | |
1171 | int (*o_fid_fini)(struct obd_device *obd); | |
1172 | ||
1173 | /* Allocate new fid according to passed @hint. */ | |
1174 | int (*o_fid_alloc)(struct obd_export *exp, struct lu_fid *fid, | |
1175 | struct md_op_data *op_data); | |
1176 | ||
1177 | /* | |
1178 | * Object with @fid is getting deleted, we may want to do something | |
1179 | * about this. | |
1180 | */ | |
1181 | int (*o_statfs)(const struct lu_env *, struct obd_export *exp, | |
1182 | struct obd_statfs *osfs, __u64 max_age, __u32 flags); | |
1183 | int (*o_statfs_async)(struct obd_export *exp, struct obd_info *oinfo, | |
1184 | __u64 max_age, struct ptlrpc_request_set *set); | |
1185 | int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt, | |
1186 | struct lov_stripe_md *mem_src); | |
1187 | int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt, | |
1188 | struct lov_mds_md *disk_src, int disk_len); | |
1189 | int (*o_preallocate)(struct lustre_handle *, obd_count *req, | |
1190 | obd_id *ids); | |
1191 | /* FIXME: add fid capability support for create & destroy! */ | |
1192 | int (*o_precreate)(struct obd_export *exp); | |
1193 | int (*o_create)(const struct lu_env *env, struct obd_export *exp, | |
1194 | struct obdo *oa, struct lov_stripe_md **ea, | |
1195 | struct obd_trans_info *oti); | |
1196 | int (*o_create_async)(struct obd_export *exp, struct obd_info *oinfo, | |
1197 | struct lov_stripe_md **ea, | |
1198 | struct obd_trans_info *oti); | |
1199 | int (*o_destroy)(const struct lu_env *env, struct obd_export *exp, | |
1200 | struct obdo *oa, struct lov_stripe_md *ea, | |
1201 | struct obd_trans_info *oti, struct obd_export *md_exp, | |
1202 | void *capa); | |
1203 | int (*o_setattr)(const struct lu_env *, struct obd_export *exp, | |
1204 | struct obd_info *oinfo, struct obd_trans_info *oti); | |
1205 | int (*o_setattr_async)(struct obd_export *exp, struct obd_info *oinfo, | |
1206 | struct obd_trans_info *oti, | |
1207 | struct ptlrpc_request_set *rqset); | |
1208 | int (*o_getattr)(const struct lu_env *env, struct obd_export *exp, | |
1209 | struct obd_info *oinfo); | |
1210 | int (*o_getattr_async)(struct obd_export *exp, struct obd_info *oinfo, | |
1211 | struct ptlrpc_request_set *set); | |
1212 | int (*o_brw)(int rw, struct obd_export *exp, struct obd_info *oinfo, | |
1213 | obd_count oa_bufs, struct brw_page *pgarr, | |
1214 | struct obd_trans_info *oti); | |
1215 | int (*o_merge_lvb)(struct obd_export *exp, struct lov_stripe_md *lsm, | |
1216 | struct ost_lvb *lvb, int kms_only); | |
1217 | int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm, | |
1218 | obd_off size, int shrink); | |
1219 | int (*o_punch)(const struct lu_env *, struct obd_export *exp, | |
1220 | struct obd_info *oinfo, struct obd_trans_info *oti, | |
1221 | struct ptlrpc_request_set *rqset); | |
1222 | int (*o_sync)(const struct lu_env *env, struct obd_export *exp, | |
1223 | struct obd_info *oinfo, obd_size start, obd_size end, | |
1224 | struct ptlrpc_request_set *set); | |
1225 | int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst, | |
1226 | struct lov_stripe_md *src, obd_size start, | |
1227 | obd_size end, struct obd_trans_info *oti); | |
1228 | int (*o_copy)(struct lustre_handle *dstconn, struct lov_stripe_md *dst, | |
1229 | struct lustre_handle *srconn, struct lov_stripe_md *src, | |
1230 | obd_size start, obd_size end, struct obd_trans_info *); | |
1231 | int (*o_iterate)(struct lustre_handle *conn, | |
1232 | int (*)(obd_id, obd_seq, void *), | |
1233 | obd_id *startid, obd_seq seq, void *data); | |
1234 | int (*o_preprw)(const struct lu_env *env, int cmd, | |
1235 | struct obd_export *exp, struct obdo *oa, int objcount, | |
1236 | struct obd_ioobj *obj, struct niobuf_remote *remote, | |
1237 | int *nr_pages, struct niobuf_local *local, | |
1238 | struct obd_trans_info *oti, struct lustre_capa *capa); | |
1239 | int (*o_commitrw)(const struct lu_env *env, int cmd, | |
1240 | struct obd_export *exp, struct obdo *oa, | |
1241 | int objcount, struct obd_ioobj *obj, | |
1242 | struct niobuf_remote *remote, int pages, | |
1243 | struct niobuf_local *local, | |
1244 | struct obd_trans_info *oti, int rc); | |
1245 | int (*o_enqueue)(struct obd_export *, struct obd_info *oinfo, | |
1246 | struct ldlm_enqueue_info *einfo, | |
1247 | struct ptlrpc_request_set *rqset); | |
1248 | int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *, | |
1249 | ldlm_iterator_t it, void *data); | |
1250 | int (*o_find_cbdata)(struct obd_export *, struct lov_stripe_md *, | |
1251 | ldlm_iterator_t it, void *data); | |
1252 | int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md, | |
1253 | __u32 mode, struct lustre_handle *); | |
1254 | int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *, | |
1255 | ldlm_cancel_flags_t flags, void *opaque); | |
1256 | int (*o_init_export)(struct obd_export *exp); | |
1257 | int (*o_destroy_export)(struct obd_export *exp); | |
1258 | int (*o_extent_calc)(struct obd_export *, struct lov_stripe_md *, | |
1259 | int cmd, obd_off *); | |
1260 | ||
1261 | /* llog related obd_methods */ | |
1262 | int (*o_llog_init)(struct obd_device *obd, struct obd_llog_group *grp, | |
1263 | struct obd_device *disk_obd, int *idx); | |
1264 | int (*o_llog_finish)(struct obd_device *obd, int count); | |
1265 | int (*o_llog_connect)(struct obd_export *, struct llogd_conn_body *); | |
1266 | ||
1267 | /* metadata-only methods */ | |
1268 | int (*o_pin)(struct obd_export *, const struct lu_fid *fid, | |
1269 | struct obd_capa *, struct obd_client_handle *, int flag); | |
1270 | int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int); | |
1271 | ||
1272 | int (*o_import_event)(struct obd_device *, struct obd_import *, | |
1273 | enum obd_import_event); | |
1274 | ||
1275 | int (*o_notify)(struct obd_device *obd, struct obd_device *watched, | |
1276 | enum obd_notify_event ev, void *data); | |
1277 | ||
1278 | int (*o_health_check)(const struct lu_env *env, struct obd_device *); | |
1279 | struct obd_uuid *(*o_get_uuid) (struct obd_export *exp); | |
1280 | ||
1281 | /* quota methods */ | |
1282 | int (*o_quotacheck)(struct obd_device *, struct obd_export *, | |
1283 | struct obd_quotactl *); | |
1284 | int (*o_quotactl)(struct obd_device *, struct obd_export *, | |
1285 | struct obd_quotactl *); | |
1286 | ||
1287 | int (*o_ping)(const struct lu_env *, struct obd_export *exp); | |
1288 | ||
1289 | /* pools methods */ | |
1290 | int (*o_pool_new)(struct obd_device *obd, char *poolname); | |
1291 | int (*o_pool_del)(struct obd_device *obd, char *poolname); | |
1292 | int (*o_pool_add)(struct obd_device *obd, char *poolname, | |
1293 | char *ostname); | |
1294 | int (*o_pool_rem)(struct obd_device *obd, char *poolname, | |
1295 | char *ostname); | |
1296 | void (*o_getref)(struct obd_device *obd); | |
1297 | void (*o_putref)(struct obd_device *obd); | |
1298 | /* | |
1299 | * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line | |
1300 | * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c. | |
1301 | * Also, add a wrapper function in include/linux/obd_class.h. */ | |
1302 | }; | |
1303 | ||
1304 | enum { | |
1305 | LUSTRE_OPC_MKDIR = (1 << 0), | |
1306 | LUSTRE_OPC_SYMLINK = (1 << 1), | |
1307 | LUSTRE_OPC_MKNOD = (1 << 2), | |
1308 | LUSTRE_OPC_CREATE = (1 << 3), | |
1309 | LUSTRE_OPC_ANY = (1 << 4) | |
1310 | }; | |
1311 | ||
1312 | /* lmv structures */ | |
1313 | #define MEA_MAGIC_LAST_CHAR 0xb2221ca1 | |
1314 | #define MEA_MAGIC_ALL_CHARS 0xb222a11c | |
1315 | #define MEA_MAGIC_HASH_SEGMENT 0xb222a11b | |
1316 | ||
1317 | #define MAX_HASH_SIZE_32 0x7fffffffUL | |
1318 | #define MAX_HASH_SIZE 0x7fffffffffffffffULL | |
1319 | #define MAX_HASH_HIGHEST_BIT 0x1000000000000000ULL | |
1320 | ||
1321 | struct lustre_md { | |
1322 | struct mdt_body *body; | |
1323 | struct lov_stripe_md *lsm; | |
1324 | struct lmv_stripe_md *mea; | |
1325 | #ifdef CONFIG_FS_POSIX_ACL | |
1326 | struct posix_acl *posix_acl; | |
1327 | #endif | |
1328 | struct mdt_remote_perm *remote_perm; | |
1329 | struct obd_capa *mds_capa; | |
1330 | struct obd_capa *oss_capa; | |
1331 | }; | |
1332 | ||
1333 | struct md_open_data { | |
1334 | struct obd_client_handle *mod_och; | |
1335 | struct ptlrpc_request *mod_open_req; | |
1336 | struct ptlrpc_request *mod_close_req; | |
63d42578 HZ |
1337 | atomic_t mod_refcount; |
1338 | bool mod_is_create; | |
d7e09d03 PT |
1339 | }; |
1340 | ||
1341 | struct lookup_intent; | |
1342 | ||
1343 | struct md_ops { | |
1344 | int (*m_getstatus)(struct obd_export *, struct lu_fid *, | |
1345 | struct obd_capa **); | |
1346 | int (*m_null_inode)(struct obd_export *, const struct lu_fid *); | |
1347 | int (*m_find_cbdata)(struct obd_export *, const struct lu_fid *, | |
1348 | ldlm_iterator_t, void *); | |
1349 | int (*m_close)(struct obd_export *, struct md_op_data *, | |
1350 | struct md_open_data *, struct ptlrpc_request **); | |
1351 | int (*m_create)(struct obd_export *, struct md_op_data *, | |
1352 | const void *, int, int, __u32, __u32, cfs_cap_t, | |
1353 | __u64, struct ptlrpc_request **); | |
1354 | int (*m_done_writing)(struct obd_export *, struct md_op_data *, | |
1355 | struct md_open_data *); | |
1356 | int (*m_enqueue)(struct obd_export *, struct ldlm_enqueue_info *, | |
1357 | struct lookup_intent *, struct md_op_data *, | |
1358 | struct lustre_handle *, void *, int, | |
1359 | struct ptlrpc_request **, __u64); | |
1360 | int (*m_getattr)(struct obd_export *, struct md_op_data *, | |
1361 | struct ptlrpc_request **); | |
1362 | int (*m_getattr_name)(struct obd_export *, struct md_op_data *, | |
1363 | struct ptlrpc_request **); | |
1364 | int (*m_intent_lock)(struct obd_export *, struct md_op_data *, | |
1365 | void *, int, struct lookup_intent *, int, | |
1366 | struct ptlrpc_request **, | |
1367 | ldlm_blocking_callback, __u64); | |
1368 | int (*m_link)(struct obd_export *, struct md_op_data *, | |
1369 | struct ptlrpc_request **); | |
1370 | int (*m_rename)(struct obd_export *, struct md_op_data *, | |
1371 | const char *, int, const char *, int, | |
1372 | struct ptlrpc_request **); | |
1373 | int (*m_is_subdir)(struct obd_export *, const struct lu_fid *, | |
1374 | const struct lu_fid *, | |
1375 | struct ptlrpc_request **); | |
1376 | int (*m_setattr)(struct obd_export *, struct md_op_data *, void *, | |
1377 | int , void *, int, struct ptlrpc_request **, | |
1378 | struct md_open_data **mod); | |
1379 | int (*m_sync)(struct obd_export *, const struct lu_fid *, | |
1380 | struct obd_capa *, struct ptlrpc_request **); | |
1381 | int (*m_readpage)(struct obd_export *, struct md_op_data *, | |
1382 | struct page **, struct ptlrpc_request **); | |
1383 | ||
1384 | int (*m_unlink)(struct obd_export *, struct md_op_data *, | |
1385 | struct ptlrpc_request **); | |
1386 | ||
1387 | int (*m_setxattr)(struct obd_export *, const struct lu_fid *, | |
1388 | struct obd_capa *, obd_valid, const char *, | |
1389 | const char *, int, int, int, __u32, | |
1390 | struct ptlrpc_request **); | |
1391 | ||
1392 | int (*m_getxattr)(struct obd_export *, const struct lu_fid *, | |
1393 | struct obd_capa *, obd_valid, const char *, | |
1394 | const char *, int, int, int, | |
1395 | struct ptlrpc_request **); | |
1396 | ||
44779340 | 1397 | int (*m_init_ea_size)(struct obd_export *, int, int, int, int); |
d7e09d03 PT |
1398 | |
1399 | int (*m_get_lustre_md)(struct obd_export *, struct ptlrpc_request *, | |
1400 | struct obd_export *, struct obd_export *, | |
1401 | struct lustre_md *); | |
1402 | ||
1403 | int (*m_free_lustre_md)(struct obd_export *, struct lustre_md *); | |
1404 | ||
1405 | int (*m_set_open_replay_data)(struct obd_export *, | |
1406 | struct obd_client_handle *, | |
63d42578 | 1407 | struct lookup_intent *); |
d7e09d03 PT |
1408 | int (*m_clear_open_replay_data)(struct obd_export *, |
1409 | struct obd_client_handle *); | |
1410 | int (*m_set_lock_data)(struct obd_export *, __u64 *, void *, __u64 *); | |
1411 | ||
1412 | ldlm_mode_t (*m_lock_match)(struct obd_export *, __u64, | |
1413 | const struct lu_fid *, ldlm_type_t, | |
1414 | ldlm_policy_data_t *, ldlm_mode_t, | |
1415 | struct lustre_handle *); | |
1416 | ||
1417 | int (*m_cancel_unused)(struct obd_export *, const struct lu_fid *, | |
1418 | ldlm_policy_data_t *, ldlm_mode_t, | |
1419 | ldlm_cancel_flags_t flags, void *opaque); | |
1420 | int (*m_renew_capa)(struct obd_export *, struct obd_capa *oc, | |
1421 | renew_capa_cb_t cb); | |
1422 | int (*m_unpack_capa)(struct obd_export *, struct ptlrpc_request *, | |
1423 | const struct req_msg_field *, struct obd_capa **); | |
1424 | ||
1425 | int (*m_get_remote_perm)(struct obd_export *, const struct lu_fid *, | |
1426 | struct obd_capa *, __u32, | |
1427 | struct ptlrpc_request **); | |
1428 | ||
1429 | int (*m_intent_getattr_async)(struct obd_export *, | |
1430 | struct md_enqueue_info *, | |
1431 | struct ldlm_enqueue_info *); | |
1432 | ||
1433 | int (*m_revalidate_lock)(struct obd_export *, struct lookup_intent *, | |
1434 | struct lu_fid *, __u64 *bits); | |
1435 | ||
1436 | /* | |
1437 | * NOTE: If adding ops, add another LPROCFS_MD_OP_INIT() line to | |
1438 | * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a | |
1439 | * wrapper function in include/linux/obd_class.h. | |
1440 | */ | |
1441 | }; | |
1442 | ||
1443 | struct lsm_operations { | |
1444 | void (*lsm_free)(struct lov_stripe_md *); | |
1445 | int (*lsm_destroy)(struct lov_stripe_md *, struct obdo *oa, | |
1446 | struct obd_export *md_exp); | |
1447 | void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, obd_off *, | |
1448 | obd_off *); | |
1449 | void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, obd_off *, | |
1450 | obd_off *); | |
1451 | int (*lsm_lmm_verify) (struct lov_mds_md *lmm, int lmm_bytes, | |
1452 | __u16 *stripe_count); | |
1453 | int (*lsm_unpackmd) (struct lov_obd *lov, struct lov_stripe_md *lsm, | |
1454 | struct lov_mds_md *lmm); | |
1455 | }; | |
1456 | ||
1457 | extern const struct lsm_operations lsm_v1_ops; | |
1458 | extern const struct lsm_operations lsm_v3_ops; | |
1459 | static inline const struct lsm_operations *lsm_op_find(int magic) | |
1460 | { | |
1461 | switch(magic) { | |
1462 | case LOV_MAGIC_V1: | |
1463 | return &lsm_v1_ops; | |
1464 | case LOV_MAGIC_V3: | |
1465 | return &lsm_v3_ops; | |
1466 | default: | |
1467 | CERROR("Cannot recognize lsm_magic %08x\n", magic); | |
1468 | return NULL; | |
1469 | } | |
1470 | } | |
1471 | ||
1472 | /* Requests for obd_extent_calc() */ | |
1473 | #define OBD_CALC_STRIPE_START 1 | |
1474 | #define OBD_CALC_STRIPE_END 2 | |
1475 | ||
1476 | static inline struct lustre_capa *oinfo_capa(struct obd_info *oinfo) | |
1477 | { | |
1478 | return oinfo->oi_capa; | |
1479 | } | |
1480 | ||
1481 | static inline struct md_open_data *obd_mod_alloc(void) | |
1482 | { | |
1483 | struct md_open_data *mod; | |
1484 | OBD_ALLOC_PTR(mod); | |
1485 | if (mod == NULL) | |
1486 | return NULL; | |
1487 | atomic_set(&mod->mod_refcount, 1); | |
1488 | return mod; | |
1489 | } | |
1490 | ||
1491 | #define obd_mod_get(mod) atomic_inc(&(mod)->mod_refcount) | |
1492 | #define obd_mod_put(mod) \ | |
1493 | ({ \ | |
1494 | if (atomic_dec_and_test(&(mod)->mod_refcount)) { \ | |
1495 | if ((mod)->mod_open_req) \ | |
1496 | ptlrpc_req_finished((mod)->mod_open_req); \ | |
1497 | OBD_FREE_PTR(mod); \ | |
1498 | } \ | |
1499 | }) | |
1500 | ||
1501 | void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid); | |
1502 | void obdo_set_parent_fid(struct obdo *dst, const struct lu_fid *parent); | |
1503 | ||
1504 | /* return 1 if client should be resend request */ | |
1505 | static inline int client_should_resend(int resend, struct client_obd *cli) | |
1506 | { | |
1507 | return atomic_read(&cli->cl_resends) ? | |
1508 | atomic_read(&cli->cl_resends) > resend : 1; | |
1509 | } | |
1510 | ||
1511 | /** | |
1512 | * Return device name for this device | |
1513 | * | |
1514 | * XXX: lu_device is declared before obd_device, while a pointer pointing | |
1515 | * back to obd_device in lu_device, so this helper function defines here | |
1516 | * instead of in lu_object.h | |
1517 | */ | |
1518 | static inline const char *lu_dev_name(const struct lu_device *lu_dev) | |
1519 | { | |
1520 | return lu_dev->ld_obd->obd_name; | |
1521 | } | |
1522 | ||
1523 | static inline bool filename_is_volatile(const char *name, int namelen, int *idx) | |
1524 | { | |
1525 | const char *start; | |
1526 | char *end; | |
1527 | ||
1528 | if (strncmp(name, LUSTRE_VOLATILE_HDR, LUSTRE_VOLATILE_HDR_LEN) != 0) | |
1529 | return false; | |
1530 | ||
1531 | /* caller does not care of idx */ | |
1532 | if (idx == NULL) | |
1533 | return true; | |
1534 | ||
1535 | /* volatile file, the MDT can be set from name */ | |
1536 | /* name format is LUSTRE_VOLATILE_HDR:[idx]: */ | |
1537 | /* if no MDT is specified, use std way */ | |
1538 | if (namelen < LUSTRE_VOLATILE_HDR_LEN + 2) | |
1539 | goto bad_format; | |
1540 | /* test for no MDT idx case */ | |
1541 | if ((*(name + LUSTRE_VOLATILE_HDR_LEN) == ':') && | |
1542 | (*(name + LUSTRE_VOLATILE_HDR_LEN + 1) == ':')) { | |
1543 | *idx = -1; | |
1544 | return true; | |
1545 | } | |
1546 | /* we have an idx, read it */ | |
1547 | start = name + LUSTRE_VOLATILE_HDR_LEN + 1; | |
1548 | *idx = strtoul(start, &end, 0); | |
1549 | /* error cases: | |
1550 | * no digit, no trailing :, negative value | |
1551 | */ | |
1552 | if (((*idx == 0) && (end == start)) || | |
1553 | (*end != ':') || (*idx < 0)) | |
1554 | goto bad_format; | |
1555 | ||
1556 | return true; | |
1557 | bad_format: | |
1558 | /* bad format of mdt idx, we cannot return an error | |
1559 | * to caller so we use hash algo */ | |
1560 | CERROR("Bad volatile file name format: %s\n", | |
1561 | name + LUSTRE_VOLATILE_HDR_LEN); | |
1562 | return false; | |
1563 | } | |
1564 | ||
1565 | static inline int cli_brw_size(struct obd_device *obd) | |
1566 | { | |
1567 | LASSERT(obd != NULL); | |
1568 | return obd->u.cli.cl_max_pages_per_rpc << PAGE_CACHE_SHIFT; | |
1569 | } | |
1570 | ||
1571 | #endif /* __OBD_H */ |