1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37#ifndef __OBD_H
38#define __OBD_H
39
40#include "linux/obd.h"
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
51#include "lustre/lustre_idl.h"
52#include "lustre_lib.h"
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"
58
59#define MAX_OBD_DEVICES 8192
60
61struct osc_async_rc {
62 int ar_rc;
63 int ar_force_sync;
64 __u64 ar_min_xid;
65};
66
67struct lov_oinfo {
68 struct ost_id loi_oi;
69 int loi_ost_idx;
70 int loi_ost_gen;
71
72 unsigned long loi_kms_valid:1;
73 __u64 loi_kms;
74 struct ost_lvb loi_lvb;
75 struct osc_async_rc loi_ar;
76};
77
78static 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
84static inline void loi_init(struct lov_oinfo *loi)
85{
86}
87
88struct lov_stripe_md {
89 atomic_t lsm_refc;
90 spinlock_t lsm_lock;
91 pid_t lsm_lock_owner;
92
93
94
95 __u64 lsm_maxbytes;
96 struct {
97
98 struct ost_id lw_object_oi;
99
100
101 __u32 lw_magic;
102 __u32 lw_stripe_size;
103 __u32 lw_pattern;
104 __u16 lw_stripe_count;
105 __u16 lw_layout_gen;
106 char lw_pool_name[LOV_MAXPOOLNAME];
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
120static inline bool lsm_is_released(struct lov_stripe_md *lsm)
121{
122 return !!(lsm->lsm_pattern & LOV_PATTERN_F_RELEASED);
123}
124
125static 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
134static 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
141struct obd_info;
142
143typedef int (*obd_enqueue_update_f)(void *cookie, int rc);
144
145
146struct obd_info {
147
148
149
150 ldlm_policy_data_t oi_policy;
151
152
153
154
155
156
157 __u64 oi_flags;
158
159 struct lustre_handle *oi_lockh;
160
161 struct lov_stripe_md *oi_md;
162
163 struct obdo *oi_oa;
164
165 struct obd_statfs *oi_osfs;
166
167
168
169
170 obd_enqueue_update_f oi_cb_up;
171
172
173 void *oi_capa;
174
175 char *oi_jobid;
176};
177
178
179static inline int lov_stripe_md_cmp(struct lov_stripe_md *m1,
180 struct lov_stripe_md *m2)
181{
182
183
184
185
186 return memcmp(&m1->lsm_wire, &m2->lsm_wire, sizeof(m1->lsm_wire));
187}
188
189static 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
211static 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
240void lov_stripe_lock(struct lov_stripe_md *md);
241void lov_stripe_unlock(struct lov_stripe_md *md);
242
243struct obd_type {
244 struct list_head typ_chain;
245 struct obd_ops *typ_dt_ops;
246 struct md_ops *typ_md_ops;
247 struct proc_dir_entry *typ_procroot;
248 char *typ_name;
249 int typ_refcnt;
250 struct lu_device_type *typ_lu;
251 spinlock_t obd_type_lock;
252};
253
254struct brw_page {
255 u64 off;
256 struct page *pg;
257 int count;
258 u32 flag;
259};
260
261
262enum 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,
275 LLOG_CHANGELOG_ORIG_CTXT,
276 LLOG_CHANGELOG_REPL_CTXT,
277 LLOG_CHANGELOG_USER_ORIG_CTXT,
278 LLOG_AGENT_ORIG_CTXT,
279 LLOG_MAX_CTXTS
280};
281
282struct timeout_item {
283 enum timeout_event ti_event;
284 unsigned long ti_timeout;
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
296#define OSC_DEFAULT_RESENDS 10
297
298
299enum {
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
309struct mdc_rpc_lock;
310struct obd_import;
311struct client_obd {
312 struct rw_semaphore cl_sem;
313 struct obd_uuid cl_target_uuid;
314 struct obd_import *cl_import;
315 int cl_conn_count;
316
317
318 int cl_default_mds_easize;
319 int cl_max_mds_easize;
320 int cl_default_mds_cookiesize;
321 int cl_max_mds_cookiesize;
322
323 enum lustre_sec_part cl_sp_me;
324 enum lustre_sec_part cl_sp_to;
325 struct sptlrpc_flavor cl_flvr_mgc;
326
327
328 long cl_dirty;
329 long cl_dirty_max;
330 long cl_dirty_transit;
331 long cl_avail_grant;
332 long cl_lost_grant;
333
334
335
336
337
338 long cl_reserved_grant;
339 struct list_head cl_cache_waiters;
340 unsigned long cl_next_shrink_grant;
341 struct list_head cl_grant_shrink_list;
342 int cl_grant_shrink_interval;
343
344
345
346 int cl_chunkbits;
347 int cl_chunk;
348 int cl_extent_tax;
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
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
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
391 struct cl_client_cache *cl_cache;
392 struct list_head cl_lru_osc;
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;
398 client_obd_lock_t cl_lru_list_lock;
399
400
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
408 struct mutex cl_mgc_mutex;
409 struct local_oid_storage *cl_mgc_los;
410 struct dt_object *cl_mgc_configs_dir;
411 atomic_t cl_mgc_refcount;
412 struct obd_export *cl_mgc_mgsexp;
413
414
415 unsigned int cl_checksum:1;
416
417 __u32 cl_supp_cksum_types;
418
419 cksum_type_t cl_cksum_type;
420
421
422 struct osc_async_rc cl_ar;
423
424
425 int cl_qchk_stat;
426#define CL_NOT_QUOTACHECKED 1
427#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 7, 50, 0)
428#warning "please consider removing quotacheck compatibility code"
429#endif
430
431
432 struct lu_client_seq *cl_seq;
433
434 atomic_t cl_resends;
435
436
437 void *cl_writeback_work;
438
439 struct cfs_hash *cl_quota_hash[MAXQUOTAS];
440};
441#define obd2cli_tgt(obd) ((char *)(obd)->u.cli.cl_target_uuid.uuid)
442
443struct obd_id_info {
444 __u32 idx;
445 u64 *data;
446};
447
448struct echo_client_obd {
449 struct obd_export *ec_exp;
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
457struct lov_qos_oss {
458 struct obd_uuid lqo_uuid;
459 struct list_head lqo_oss_list;
460 __u64 lqo_bavail;
461 __u64 lqo_penalty;
462 __u64 lqo_penalty_per_obj;
463 time_t lqo_used;
464 __u32 lqo_ost_count;
465};
466
467struct ltd_qos {
468 struct lov_qos_oss *ltq_oss;
469 __u64 ltq_penalty;
470 __u64 ltq_penalty_per_obj;
471 __u64 ltq_weight;
472 time_t ltq_used;
473 unsigned int ltq_usable:1;
474};
475
476
477struct ost_pool {
478 __u32 *op_array;
479
480 unsigned int op_count;
481 unsigned int op_size;
482 struct rw_semaphore op_rw_sem;
483};
484
485
486struct lov_qos_rr {
487 __u32 lqr_start_idx;
488 __u32 lqr_offset_idx;
489 int lqr_start_count;
490 struct ost_pool lqr_pool;
491 unsigned long lqr_dirty:1;
492};
493
494
495#define OBD_STATFS_CACHE_SECONDS 1
496
497struct lov_statfs_data {
498 struct obd_info lsd_oi;
499 struct obd_statfs lsd_statfs;
500};
501
502struct lov_qos {
503 struct list_head lq_oss_list;
504 struct rw_semaphore lq_rw_sem;
505 __u32 lq_active_oss_count;
506 unsigned int lq_prio_free;
507 unsigned int lq_threshold_rr;
508 struct lov_qos_rr lq_rr;
509 unsigned long lq_dirty:1,
510 lq_same_space:1,
511
512 lq_reset:1,
513 lq_statfs_in_progress:1;
514
515
516 struct lov_statfs_data *lq_statfs_data;
517 wait_queue_head_t lq_statfs_waitq;
518
519};
520
521struct 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;
527 __u32 ltd_gen;
528 __u32 ltd_index;
529 unsigned long ltd_active:1,
530 ltd_activate:1,
531 ltd_reap:1;
532};
533
534
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
540struct pool_desc {
541 char pool_name[LOV_MAXPOOLNAME + 1];
542 struct ost_pool pool_obds;
543 atomic_t pool_refcount;
544 struct lov_qos_rr pool_rr;
545 struct hlist_node pool_hash;
546 struct list_head pool_list;
547 struct proc_dir_entry *pool_proc_entry;
548 struct obd_device *pool_lobd;
549
550};
551
552struct lov_obd {
553 struct lov_desc desc;
554 struct lov_tgt_desc **lov_tgts;
555 struct ost_pool lov_packed;
556
557 struct mutex lov_lock;
558 struct obd_connect_data lov_ocd;
559 atomic_t lov_refcount;
560 __u32 lov_tgt_count;
561 __u32 lov_active_tgt_count;
562 __u32 lov_death_row;
563 __u32 lov_tgt_size;
564 int lov_connects;
565 int lov_pool_count;
566 struct cfs_hash *lov_pools_hash_body;
567 struct list_head lov_pool_list;
568 struct proc_dir_entry *lov_pool_proc_entry;
569 enum lustre_sec_part lov_sp_me;
570
571
572 void *lov_cache;
573
574 struct rw_semaphore lov_notify_lock;
575};
576
577struct 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;
583};
584
585enum placement_policy {
586 PLACEMENT_CHAR_POLICY = 0,
587 PLACEMENT_NID_POLICY = 1,
588 PLACEMENT_INVAL_POLICY = 2,
589 PLACEMENT_MAX_POLICY
590};
591
592struct lmv_obd {
593 int refcount;
594 struct lu_client_fld lmv_fld;
595 spinlock_t lmv_lock;
596 enum placement_policy lmv_placement;
597 struct lmv_desc desc;
598 struct obd_uuid cluuid;
599 struct obd_export *exp;
600
601 struct mutex init_mutex;
602 int connected;
603 int max_easize;
604 int max_def_easize;
605 int max_cookiesize;
606 int max_def_cookiesize;
607 int server_timeout;
608
609 int tgts_size;
610 struct lmv_tgt_desc **tgts;
611
612 struct obd_connect_data conn_data;
613};
614
615struct niobuf_local {
616 __u64 lnb_file_offset;
617 __u32 lnb_page_offset;
618 __u32 len;
619 __u32 flags;
620 struct page *page;
621 struct dentry *dentry;
622 int lnb_grant_used;
623 int rc;
624};
625
626#define LUSTRE_FLD_NAME "fld"
627#define LUSTRE_SEQ_NAME "seq"
628
629#define LUSTRE_MDD_NAME "mdd"
630#define LUSTRE_OSD_LDISKFS_NAME "osd-ldiskfs"
631#define LUSTRE_OSD_ZFS_NAME "osd-zfs"
632#define LUSTRE_VVP_NAME "vvp"
633#define LUSTRE_LMV_NAME "lmv"
634#define LUSTRE_SLP_NAME "slp"
635#define LUSTRE_LOD_NAME "lod"
636#define LUSTRE_OSP_NAME "osp"
637#define LUSTRE_LWP_NAME "lwp"
638
639
640
641#define LUSTRE_MDS_NAME "mds"
642#define LUSTRE_MDT_NAME "mdt"
643#define LUSTRE_MDC_NAME "mdc"
644#define LUSTRE_OSS_NAME "ost"
645#define LUSTRE_OST_NAME "obdfilter"
646#define LUSTRE_OSC_NAME "osc"
647#define LUSTRE_LOV_NAME "lov"
648#define LUSTRE_MGS_NAME "mgs"
649#define LUSTRE_MGC_NAME "mgc"
650
651#define LUSTRE_ECHO_NAME "obdecho"
652#define LUSTRE_ECHO_CLIENT_NAME "echo_client"
653#define LUSTRE_QMT_NAME "qmt"
654
655
656#define LUSTRE_MDS_OBDNAME "MDS"
657#define LUSTRE_OSS_OBDNAME "OSS"
658#define LUSTRE_MGS_OBDNAME "MGS"
659#define LUSTRE_MGC_OBDNAME "MGC"
660
661
662#define N_LOCAL_TEMP_PAGE 0x10000000
663
664struct obd_trans_info {
665 __u64 oti_transno;
666 __u64 oti_xid;
667
668 struct oti_req_ack_lock {
669 struct lustre_handle lock;
670 __u32 mode;
671 } oti_ack_locks[4];
672 void *oti_handle;
673 struct llog_cookie oti_onecookie;
674 struct llog_cookie *oti_logcookies;
675 int oti_numcookies;
676
677 unsigned long oti_sync_write:1;
678
679
680 struct ptlrpc_thread *oti_thread;
681 __u32 oti_conn_cnt;
682
683 __u64 oti_pre_version;
684
685 char *oti_jobid;
686
687 struct obd_uuid *oti_ost_uuid;
688};
689
690static inline void oti_init(struct obd_trans_info *oti,
691 struct ptlrpc_request *req)
692{
693 if (oti == NULL)
694 return;
695 memset(oti, 0, sizeof(*oti));
696
697 if (req == NULL)
698 return;
699
700 oti->oti_xid = req->rq_xid;
701
702 if (req->rq_reqmsg != NULL &&
703 lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
704 __u64 *pre_version = lustre_msg_get_versions(req->rq_reqmsg);
705
706 oti->oti_pre_version = pre_version ? pre_version[0] : 0;
707 oti->oti_transno = lustre_msg_get_transno(req->rq_reqmsg);
708 }
709
710
711 if (req->rq_repmsg != NULL)
712 oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg);
713 oti->oti_thread = req->rq_svc_thread;
714 if (req->rq_reqmsg != NULL)
715 oti->oti_conn_cnt = lustre_msg_get_conn_cnt(req->rq_reqmsg);
716}
717
718static inline void oti_alloc_cookies(struct obd_trans_info *oti,
719 int num_cookies)
720{
721 if (!oti)
722 return;
723
724 if (num_cookies == 1)
725 oti->oti_logcookies = &oti->oti_onecookie;
726 else
727 OBD_ALLOC_LARGE(oti->oti_logcookies,
728 num_cookies * sizeof(oti->oti_onecookie));
729
730 oti->oti_numcookies = num_cookies;
731}
732
733static inline void oti_free_cookies(struct obd_trans_info *oti)
734{
735 if (!oti || !oti->oti_logcookies)
736 return;
737
738 if (oti->oti_logcookies == &oti->oti_onecookie)
739 LASSERT(oti->oti_numcookies == 1);
740 else
741 OBD_FREE_LARGE(oti->oti_logcookies,
742 oti->oti_numcookies*sizeof(oti->oti_onecookie));
743 oti->oti_logcookies = NULL;
744 oti->oti_numcookies = 0;
745}
746
747
748
749
750enum obd_notify_event {
751
752 OBD_NOTIFY_CREATE,
753
754 OBD_NOTIFY_CONNECT,
755
756 OBD_NOTIFY_ACTIVE,
757
758 OBD_NOTIFY_INACTIVE,
759
760 OBD_NOTIFY_DISCON,
761
762 OBD_NOTIFY_OCD,
763
764 OBD_NOTIFY_SYNC_NONBLOCK,
765 OBD_NOTIFY_SYNC,
766
767 OBD_NOTIFY_CONFIG,
768
769 OBD_NOTIFY_DEACTIVATE,
770 OBD_NOTIFY_ACTIVATE
771};
772
773
774
775
776
777struct obd_notify_upcall {
778 int (*onu_upcall)(struct obd_device *host, struct obd_device *watched,
779 enum obd_notify_event ev, void *owner, void *data);
780
781 void *onu_owner;
782};
783
784struct target_recovery_data {
785 svc_handler_t trd_recovery_handler;
786 pid_t trd_processing_task;
787 struct completion trd_starting;
788 struct completion trd_finishing;
789};
790
791struct obd_llog_group {
792 int olg_seq;
793 struct llog_ctxt *olg_ctxts[LLOG_MAX_CTXTS];
794 wait_queue_head_t olg_waitq;
795 spinlock_t olg_lock;
796 struct mutex olg_cat_processing;
797};
798
799
800#define OBD_DEVICE_MAGIC 0XAB5CD6EF
801#define OBD_DEV_BY_DEVNAME 0xffffd0de
802
803struct lvfs_run_ctxt {
804 struct dt_device *dt;
805};
806
807struct obd_device {
808 struct obd_type *obd_type;
809 __u32 obd_magic;
810
811
812 char obd_name[MAX_OBD_NAME];
813 struct obd_uuid obd_uuid;
814
815 struct lu_device *obd_lu_dev;
816
817 int obd_minor;
818
819 unsigned long obd_attached:1,
820 obd_set_up:1,
821 obd_recovering:1,
822 obd_abort_recovery:1,
823 obd_version_recov:1,
824 obd_replayable:1,
825 obd_no_transno:1,
826 obd_no_recov:1,
827 obd_stopping:1,
828 obd_starting:1,
829 obd_force:1,
830 obd_fail:1,
831 obd_async_recov:1,
832 obd_no_conn:1,
833 obd_inactive:1,
834
835 obd_no_ir:1,
836 obd_process_conf:1;
837
838
839 unsigned long obd_recovery_expired:1;
840
841 struct cfs_hash *obd_uuid_hash;
842
843 struct cfs_hash *obd_nid_hash;
844
845 struct cfs_hash *obd_nid_stats_hash;
846 struct list_head obd_nid_stats;
847 atomic_t obd_refcount;
848 wait_queue_head_t obd_refcount_waitq;
849 struct list_head obd_exports;
850 struct list_head obd_unlinked_exports;
851 struct list_head obd_delayed_exports;
852 int obd_num_exports;
853 spinlock_t obd_nid_lock;
854 struct ldlm_namespace *obd_namespace;
855 struct ptlrpc_client obd_ldlm_client;
856
857 spinlock_t obd_dev_lock;
858 struct mutex obd_dev_mutex;
859 __u64 obd_last_committed;
860 spinlock_t obd_osfs_lock;
861 struct obd_statfs obd_osfs;
862 __u64 obd_osfs_age;
863 struct lvfs_run_ctxt obd_lvfs_ctxt;
864 struct obd_llog_group obd_olg;
865 struct obd_device *obd_observer;
866 struct rw_semaphore obd_observer_link_sem;
867 struct obd_notify_upcall obd_upcall;
868 struct obd_export *obd_self_export;
869
870 struct list_head obd_exports_timed;
871 time_t obd_eviction_timer;
872
873 int obd_max_recoverable_clients;
874 atomic_t obd_connected_clients;
875 int obd_stale_clients;
876 int obd_delayed_clients;
877
878
879 spinlock_t obd_recovery_task_lock;
880 __u64 obd_next_recovery_transno;
881 int obd_replayed_requests;
882 int obd_requests_queued_for_recovery;
883 wait_queue_head_t obd_next_transno_waitq;
884
885 struct timer_list obd_recovery_timer;
886 time_t obd_recovery_start;
887 time_t obd_recovery_end;
888 int obd_recovery_time_hard;
889 int obd_recovery_timeout;
890 int obd_recovery_ir_factor;
891
892
893 struct target_recovery_data obd_recovery_data;
894 int obd_replayed_locks;
895 atomic_t obd_req_replay_clients;
896 atomic_t obd_lock_replay_clients;
897
898 struct list_head obd_req_replay_queue;
899 struct list_head obd_lock_replay_queue;
900 struct list_head obd_final_req_queue;
901 int obd_recovery_stage;
902
903 union {
904 struct client_obd cli;
905 struct echo_client_obd echo_client;
906 struct lov_obd lov;
907 struct lmv_obd lmv;
908 } u;
909
910 unsigned int obd_cntr_base;
911 struct lprocfs_stats *obd_stats;
912
913 unsigned int md_cntr_base;
914 struct lprocfs_stats *md_stats;
915
916 struct proc_dir_entry *obd_proc_entry;
917 void *obd_proc_private;
918 struct proc_dir_entry *obd_proc_exports_entry;
919 struct proc_dir_entry *obd_svc_procroot;
920 struct lprocfs_stats *obd_svc_stats;
921 atomic_t obd_evict_inprogress;
922 wait_queue_head_t obd_evict_inprogress_waitq;
923 struct list_head obd_evict_list;
924
925
926
927
928 rwlock_t obd_pool_lock;
929 int obd_pool_limit;
930 __u64 obd_pool_slv;
931
932
933
934
935
936 struct lu_ref obd_reference;
937
938 int obd_conn_inprogress;
939};
940
941#define OBD_LLOG_FL_SENDNOW 0x0001
942#define OBD_LLOG_FL_EXIT 0x0002
943
944enum obd_cleanup_stage {
945
946 OBD_CLEANUP_EARLY,
947
948 OBD_CLEANUP_EXPORTS,
949};
950
951
952#define KEY_ASYNC "async"
953#define KEY_BLOCKSIZE_BITS "blocksize_bits"
954#define KEY_BLOCKSIZE "blocksize"
955#define KEY_CAPA_KEY "capa_key"
956#define KEY_CHANGELOG_CLEAR "changelog_clear"
957#define KEY_FID2PATH "fid2path"
958#define KEY_CHECKSUM "checksum"
959#define KEY_CLEAR_FS "clear_fs"
960#define KEY_CONN_DATA "conn_data"
961#define KEY_EVICT_BY_NID "evict_by_nid"
962#define KEY_FIEMAP "fiemap"
963#define KEY_FLUSH_CTX "flush_ctx"
964#define KEY_GRANT_SHRINK "grant_shrink"
965#define KEY_HSM_COPYTOOL_SEND "hsm_send"
966#define KEY_INIT_RECOV_BACKUP "init_recov_bk"
967#define KEY_INIT_RECOV "initial_recov"
968#define KEY_INTERMDS "inter_mds"
969#define KEY_LAST_ID "last_id"
970#define KEY_LAST_FID "last_fid"
971#define KEY_LOCK_TO_STRIPE "lock_to_stripe"
972#define KEY_LOVDESC "lovdesc"
973#define KEY_LOV_IDX "lov_idx"
974#define KEY_MAX_EASIZE "max_easize"
975#define KEY_DEFAULT_EASIZE "default_easize"
976#define KEY_MAX_COOKIESIZE "max_cookiesize"
977#define KEY_DEFAULT_COOKIESIZE "default_cookiesize"
978#define KEY_MDS_CONN "mds_conn"
979#define KEY_MGSSEC "mgssec"
980#define KEY_NEXT_ID "next_id"
981#define KEY_READ_ONLY "read-only"
982#define KEY_REGISTER_TARGET "register_target"
983#define KEY_SET_FS "set_fs"
984#define KEY_TGT_COUNT "tgt_count"
985
986#define KEY_SPTLRPC_CONF "sptlrpc_conf"
987#define KEY_CONNECT_FLAG "connect_flags"
988#define KEY_SYNC_LOCK_CANCEL "sync_lock_cancel"
989
990#define KEY_CACHE_SET "cache_set"
991#define KEY_CACHE_LRU_SHRINK "cache_lru_shrink"
992#define KEY_CHANGELOG_INDEX "changelog_index"
993
994struct lu_context;
995
996
997#define IT_OPEN (1 << 0)
998#define IT_CREAT (1 << 1)
999#define IT_READDIR (1 << 2)
1000#define IT_GETATTR (1 << 3)
1001#define IT_LOOKUP (1 << 4)
1002#define IT_UNLINK (1 << 5)
1003#define IT_TRUNC (1 << 6)
1004#define IT_GETXATTR (1 << 7)
1005#define IT_EXEC (1 << 8)
1006#define IT_PIN (1 << 9)
1007#define IT_LAYOUT (1 << 10)
1008#define IT_QUOTA_DQACQ (1 << 11)
1009#define IT_QUOTA_CONN (1 << 12)
1010#define IT_SETXATTR (1 << 13)
1011
1012static inline int it_to_lock_mode(struct lookup_intent *it)
1013{
1014
1015 if (it->it_op & IT_CREAT)
1016 return LCK_CW;
1017 else if (it->it_op & (IT_READDIR | IT_GETATTR | IT_OPEN | IT_LOOKUP |
1018 IT_LAYOUT))
1019 return LCK_CR;
1020 else if (it->it_op & IT_GETXATTR)
1021 return LCK_PR;
1022 else if (it->it_op & IT_SETXATTR)
1023 return LCK_PW;
1024
1025 LASSERTF(0, "Invalid it_op: %d\n", it->it_op);
1026 return -EINVAL;
1027}
1028
1029struct md_op_data {
1030 struct lu_fid op_fid1;
1031 struct lu_fid op_fid2;
1032 struct lu_fid op_fid3;
1033 struct lu_fid op_fid4;
1034 u32 op_mds;
1035 struct lustre_handle op_handle;
1036 s64 op_mod_time;
1037 const char *op_name;
1038 int op_namelen;
1039 __u32 op_mode;
1040 struct lmv_stripe_md *op_mea1;
1041 struct lmv_stripe_md *op_mea2;
1042 __u32 op_suppgids[2];
1043 __u32 op_fsuid;
1044 __u32 op_fsgid;
1045 cfs_cap_t op_cap;
1046 void *op_data;
1047
1048
1049 struct iattr op_attr;
1050 unsigned int op_attr_flags;
1051 __u64 op_valid;
1052 loff_t op_attr_blocks;
1053
1054
1055 __u64 op_ioepoch;
1056 __u32 op_flags;
1057
1058
1059 struct obd_capa *op_capa1;
1060 struct obd_capa *op_capa2;
1061
1062
1063 enum mds_op_bias op_bias;
1064
1065
1066 __u32 op_opc;
1067
1068
1069 __u64 op_offset;
1070
1071
1072 __u32 op_npages;
1073
1074
1075
1076 __u32 op_cli_flags;
1077
1078
1079 __u64 op_data_version;
1080 struct lustre_handle op_lease_handle;
1081};
1082
1083enum op_cli_flags {
1084 CLI_SET_MEA = 1 << 0,
1085 CLI_RM_ENTRY = 1 << 1,
1086};
1087
1088struct md_enqueue_info;
1089
1090
1091struct md_enqueue_info {
1092 struct md_op_data mi_data;
1093 struct lookup_intent mi_it;
1094 struct lustre_handle mi_lockh;
1095 struct inode *mi_dir;
1096 int (*mi_cb)(struct ptlrpc_request *req,
1097 struct md_enqueue_info *minfo, int rc);
1098 __u64 mi_cbdata;
1099 unsigned int mi_generation;
1100};
1101
1102struct obd_ops {
1103 struct module *o_owner;
1104 int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
1105 void *karg, void *uarg);
1106 int (*o_get_info)(const struct lu_env *env, struct obd_export *,
1107 __u32 keylen, void *key, __u32 *vallen, void *val,
1108 struct lov_stripe_md *lsm);
1109 int (*o_set_info_async)(const struct lu_env *, struct obd_export *,
1110 __u32 keylen, void *key,
1111 __u32 vallen, void *val,
1112 struct ptlrpc_request_set *set);
1113 int (*o_attach)(struct obd_device *dev, u32 len, void *data);
1114 int (*o_detach)(struct obd_device *dev);
1115 int (*o_setup)(struct obd_device *dev, struct lustre_cfg *cfg);
1116 int (*o_precleanup)(struct obd_device *dev,
1117 enum obd_cleanup_stage cleanup_stage);
1118 int (*o_cleanup)(struct obd_device *dev);
1119 int (*o_process_config)(struct obd_device *dev, u32 len, void *data);
1120 int (*o_postrecov)(struct obd_device *dev);
1121 int (*o_add_conn)(struct obd_import *imp, struct obd_uuid *uuid,
1122 int priority);
1123 int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid);
1124
1125
1126
1127
1128 int (*o_connect)(const struct lu_env *env,
1129 struct obd_export **exp, struct obd_device *src,
1130 struct obd_uuid *cluuid, struct obd_connect_data *ocd,
1131 void *localdata);
1132 int (*o_reconnect)(const struct lu_env *env,
1133 struct obd_export *exp, struct obd_device *src,
1134 struct obd_uuid *cluuid,
1135 struct obd_connect_data *ocd,
1136 void *localdata);
1137 int (*o_disconnect)(struct obd_export *exp);
1138
1139
1140 int (*o_fid_init)(struct obd_device *obd,
1141 struct obd_export *exp, enum lu_cli_type type);
1142 int (*o_fid_fini)(struct obd_device *obd);
1143
1144
1145 int (*o_fid_alloc)(struct obd_export *exp, struct lu_fid *fid,
1146 struct md_op_data *op_data);
1147
1148
1149
1150
1151
1152 int (*o_statfs)(const struct lu_env *, struct obd_export *exp,
1153 struct obd_statfs *osfs, __u64 max_age, __u32 flags);
1154 int (*o_statfs_async)(struct obd_export *exp, struct obd_info *oinfo,
1155 __u64 max_age, struct ptlrpc_request_set *set);
1156 int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
1157 struct lov_stripe_md *mem_src);
1158 int (*o_unpackmd)(struct obd_export *exp,
1159 struct lov_stripe_md **mem_tgt,
1160 struct lov_mds_md *disk_src, int disk_len);
1161 int (*o_preallocate)(struct lustre_handle *, u32 *req, u64 *ids);
1162
1163 int (*o_create)(const struct lu_env *env, struct obd_export *exp,
1164 struct obdo *oa, struct lov_stripe_md **ea,
1165 struct obd_trans_info *oti);
1166 int (*o_destroy)(const struct lu_env *env, struct obd_export *exp,
1167 struct obdo *oa, struct lov_stripe_md *ea,
1168 struct obd_trans_info *oti, struct obd_export *md_exp,
1169 void *capa);
1170 int (*o_setattr)(const struct lu_env *, struct obd_export *exp,
1171 struct obd_info *oinfo, struct obd_trans_info *oti);
1172 int (*o_setattr_async)(struct obd_export *exp, struct obd_info *oinfo,
1173 struct obd_trans_info *oti,
1174 struct ptlrpc_request_set *rqset);
1175 int (*o_getattr)(const struct lu_env *env, struct obd_export *exp,
1176 struct obd_info *oinfo);
1177 int (*o_getattr_async)(struct obd_export *exp, struct obd_info *oinfo,
1178 struct ptlrpc_request_set *set);
1179 int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm,
1180 u64 size, int shrink);
1181 int (*o_preprw)(const struct lu_env *env, int cmd,
1182 struct obd_export *exp, struct obdo *oa, int objcount,
1183 struct obd_ioobj *obj, struct niobuf_remote *remote,
1184 int *nr_pages, struct niobuf_local *local,
1185 struct obd_trans_info *oti, struct lustre_capa *capa);
1186 int (*o_commitrw)(const struct lu_env *env, int cmd,
1187 struct obd_export *exp, struct obdo *oa,
1188 int objcount, struct obd_ioobj *obj,
1189 struct niobuf_remote *remote, int pages,
1190 struct niobuf_local *local,
1191 struct obd_trans_info *oti, int rc);
1192 int (*o_find_cbdata)(struct obd_export *, struct lov_stripe_md *,
1193 ldlm_iterator_t it, void *data);
1194 int (*o_init_export)(struct obd_export *exp);
1195 int (*o_destroy_export)(struct obd_export *exp);
1196
1197
1198 int (*o_import_event)(struct obd_device *, struct obd_import *,
1199 enum obd_import_event);
1200
1201 int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
1202 enum obd_notify_event ev, void *data);
1203
1204 int (*o_health_check)(const struct lu_env *env, struct obd_device *);
1205 struct obd_uuid *(*o_get_uuid)(struct obd_export *exp);
1206
1207
1208 int (*o_quotacheck)(struct obd_device *, struct obd_export *,
1209 struct obd_quotactl *);
1210 int (*o_quotactl)(struct obd_device *, struct obd_export *,
1211 struct obd_quotactl *);
1212
1213
1214 int (*o_pool_new)(struct obd_device *obd, char *poolname);
1215 int (*o_pool_del)(struct obd_device *obd, char *poolname);
1216 int (*o_pool_add)(struct obd_device *obd, char *poolname,
1217 char *ostname);
1218 int (*o_pool_rem)(struct obd_device *obd, char *poolname,
1219 char *ostname);
1220 void (*o_getref)(struct obd_device *obd);
1221 void (*o_putref)(struct obd_device *obd);
1222
1223
1224
1225
1226};
1227
1228enum {
1229 LUSTRE_OPC_MKDIR = (1 << 0),
1230 LUSTRE_OPC_SYMLINK = (1 << 1),
1231 LUSTRE_OPC_MKNOD = (1 << 2),
1232 LUSTRE_OPC_CREATE = (1 << 3),
1233 LUSTRE_OPC_ANY = (1 << 4)
1234};
1235
1236
1237#define MEA_MAGIC_LAST_CHAR 0xb2221ca1
1238#define MEA_MAGIC_ALL_CHARS 0xb222a11c
1239#define MEA_MAGIC_HASH_SEGMENT 0xb222a11b
1240
1241#define MAX_HASH_SIZE_32 0x7fffffffUL
1242#define MAX_HASH_SIZE 0x7fffffffffffffffULL
1243#define MAX_HASH_HIGHEST_BIT 0x1000000000000000ULL
1244
1245struct lustre_md {
1246 struct mdt_body *body;
1247 struct lov_stripe_md *lsm;
1248 struct lmv_stripe_md *mea;
1249#ifdef CONFIG_FS_POSIX_ACL
1250 struct posix_acl *posix_acl;
1251#endif
1252 struct mdt_remote_perm *remote_perm;
1253 struct obd_capa *mds_capa;
1254 struct obd_capa *oss_capa;
1255};
1256
1257struct md_open_data {
1258 struct obd_client_handle *mod_och;
1259 struct ptlrpc_request *mod_open_req;
1260 struct ptlrpc_request *mod_close_req;
1261 atomic_t mod_refcount;
1262 bool mod_is_create;
1263};
1264
1265struct lookup_intent;
1266
1267struct md_ops {
1268 int (*m_getstatus)(struct obd_export *, struct lu_fid *,
1269 struct obd_capa **);
1270 int (*m_null_inode)(struct obd_export *, const struct lu_fid *);
1271 int (*m_find_cbdata)(struct obd_export *, const struct lu_fid *,
1272 ldlm_iterator_t, void *);
1273 int (*m_close)(struct obd_export *, struct md_op_data *,
1274 struct md_open_data *, struct ptlrpc_request **);
1275 int (*m_create)(struct obd_export *, struct md_op_data *,
1276 const void *, int, int, __u32, __u32, cfs_cap_t,
1277 __u64, struct ptlrpc_request **);
1278 int (*m_done_writing)(struct obd_export *, struct md_op_data *,
1279 struct md_open_data *);
1280 int (*m_enqueue)(struct obd_export *, struct ldlm_enqueue_info *,
1281 struct lookup_intent *, struct md_op_data *,
1282 struct lustre_handle *, void *, int,
1283 struct ptlrpc_request **, __u64);
1284 int (*m_getattr)(struct obd_export *, struct md_op_data *,
1285 struct ptlrpc_request **);
1286 int (*m_getattr_name)(struct obd_export *, struct md_op_data *,
1287 struct ptlrpc_request **);
1288 int (*m_intent_lock)(struct obd_export *, struct md_op_data *,
1289 void *, int, struct lookup_intent *, int,
1290 struct ptlrpc_request **,
1291 ldlm_blocking_callback, __u64);
1292 int (*m_link)(struct obd_export *, struct md_op_data *,
1293 struct ptlrpc_request **);
1294 int (*m_rename)(struct obd_export *, struct md_op_data *,
1295 const char *, int, const char *, int,
1296 struct ptlrpc_request **);
1297 int (*m_is_subdir)(struct obd_export *, const struct lu_fid *,
1298 const struct lu_fid *,
1299 struct ptlrpc_request **);
1300 int (*m_setattr)(struct obd_export *, struct md_op_data *, void *,
1301 int , void *, int, struct ptlrpc_request **,
1302 struct md_open_data **mod);
1303 int (*m_sync)(struct obd_export *, const struct lu_fid *,
1304 struct obd_capa *, struct ptlrpc_request **);
1305 int (*m_readpage)(struct obd_export *, struct md_op_data *,
1306 struct page **, struct ptlrpc_request **);
1307
1308 int (*m_unlink)(struct obd_export *, struct md_op_data *,
1309 struct ptlrpc_request **);
1310
1311 int (*m_setxattr)(struct obd_export *, const struct lu_fid *,
1312 struct obd_capa *, u64, const char *,
1313 const char *, int, int, int, __u32,
1314 struct ptlrpc_request **);
1315
1316 int (*m_getxattr)(struct obd_export *, const struct lu_fid *,
1317 struct obd_capa *, u64, const char *,
1318 const char *, int, int, int,
1319 struct ptlrpc_request **);
1320
1321 int (*m_init_ea_size)(struct obd_export *, int, int, int, int);
1322
1323 int (*m_get_lustre_md)(struct obd_export *, struct ptlrpc_request *,
1324 struct obd_export *, struct obd_export *,
1325 struct lustre_md *);
1326
1327 int (*m_free_lustre_md)(struct obd_export *, struct lustre_md *);
1328
1329 int (*m_set_open_replay_data)(struct obd_export *,
1330 struct obd_client_handle *,
1331 struct lookup_intent *);
1332 int (*m_clear_open_replay_data)(struct obd_export *,
1333 struct obd_client_handle *);
1334 int (*m_set_lock_data)(struct obd_export *, __u64 *, void *, __u64 *);
1335
1336 ldlm_mode_t (*m_lock_match)(struct obd_export *, __u64,
1337 const struct lu_fid *, ldlm_type_t,
1338 ldlm_policy_data_t *, ldlm_mode_t,
1339 struct lustre_handle *);
1340
1341 int (*m_cancel_unused)(struct obd_export *, const struct lu_fid *,
1342 ldlm_policy_data_t *, ldlm_mode_t,
1343 ldlm_cancel_flags_t flags, void *opaque);
1344 int (*m_renew_capa)(struct obd_export *, struct obd_capa *oc,
1345 renew_capa_cb_t cb);
1346 int (*m_unpack_capa)(struct obd_export *, struct ptlrpc_request *,
1347 const struct req_msg_field *, struct obd_capa **);
1348
1349 int (*m_get_remote_perm)(struct obd_export *, const struct lu_fid *,
1350 struct obd_capa *, __u32,
1351 struct ptlrpc_request **);
1352
1353 int (*m_intent_getattr_async)(struct obd_export *,
1354 struct md_enqueue_info *,
1355 struct ldlm_enqueue_info *);
1356
1357 int (*m_revalidate_lock)(struct obd_export *, struct lookup_intent *,
1358 struct lu_fid *, __u64 *bits);
1359
1360
1361
1362
1363
1364
1365};
1366
1367struct lsm_operations {
1368 void (*lsm_free)(struct lov_stripe_md *);
1369 int (*lsm_destroy)(struct lov_stripe_md *, struct obdo *oa,
1370 struct obd_export *md_exp);
1371 void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, u64 *,
1372 u64 *);
1373 void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, u64 *,
1374 u64 *);
1375 int (*lsm_lmm_verify)(struct lov_mds_md *lmm, int lmm_bytes,
1376 __u16 *stripe_count);
1377 int (*lsm_unpackmd)(struct lov_obd *lov, struct lov_stripe_md *lsm,
1378 struct lov_mds_md *lmm);
1379};
1380
1381extern const struct lsm_operations lsm_v1_ops;
1382extern const struct lsm_operations lsm_v3_ops;
1383static inline const struct lsm_operations *lsm_op_find(int magic)
1384{
1385 switch (magic) {
1386 case LOV_MAGIC_V1:
1387 return &lsm_v1_ops;
1388 case LOV_MAGIC_V3:
1389 return &lsm_v3_ops;
1390 default:
1391 CERROR("Cannot recognize lsm_magic %08x\n", magic);
1392 return NULL;
1393 }
1394}
1395
1396
1397#define OBD_CALC_STRIPE_START 1
1398#define OBD_CALC_STRIPE_END 2
1399
1400static inline struct lustre_capa *oinfo_capa(struct obd_info *oinfo)
1401{
1402 return oinfo->oi_capa;
1403}
1404
1405static inline struct md_open_data *obd_mod_alloc(void)
1406{
1407 struct md_open_data *mod;
1408
1409 OBD_ALLOC_PTR(mod);
1410 if (mod == NULL)
1411 return NULL;
1412 atomic_set(&mod->mod_refcount, 1);
1413 return mod;
1414}
1415
1416#define obd_mod_get(mod) atomic_inc(&(mod)->mod_refcount)
1417#define obd_mod_put(mod) \
1418({ \
1419 if (atomic_dec_and_test(&(mod)->mod_refcount)) { \
1420 if ((mod)->mod_open_req) \
1421 ptlrpc_req_finished((mod)->mod_open_req); \
1422 OBD_FREE_PTR(mod); \
1423 } \
1424})
1425
1426void obdo_from_inode(struct obdo *dst, struct inode *src, u32 valid);
1427void obdo_set_parent_fid(struct obdo *dst, const struct lu_fid *parent);
1428
1429
1430static inline int client_should_resend(int resend, struct client_obd *cli)
1431{
1432 return atomic_read(&cli->cl_resends) ?
1433 atomic_read(&cli->cl_resends) > resend : 1;
1434}
1435
1436
1437
1438
1439
1440
1441
1442
1443static inline const char *lu_dev_name(const struct lu_device *lu_dev)
1444{
1445 return lu_dev->ld_obd->obd_name;
1446}
1447
1448static inline bool filename_is_volatile(const char *name, int namelen, int *idx)
1449{
1450 const char *start;
1451 char *end;
1452
1453 if (strncmp(name, LUSTRE_VOLATILE_HDR, LUSTRE_VOLATILE_HDR_LEN) != 0)
1454 return false;
1455
1456
1457 if (idx == NULL)
1458 return true;
1459
1460
1461
1462
1463 if (namelen < LUSTRE_VOLATILE_HDR_LEN + 2)
1464 goto bad_format;
1465
1466 if ((*(name + LUSTRE_VOLATILE_HDR_LEN) == ':') &&
1467 (*(name + LUSTRE_VOLATILE_HDR_LEN + 1) == ':')) {
1468 *idx = -1;
1469 return true;
1470 }
1471
1472 start = name + LUSTRE_VOLATILE_HDR_LEN + 1;
1473 *idx = strtoul(start, &end, 0);
1474
1475
1476
1477 if (((*idx == 0) && (end == start)) ||
1478 (*end != ':') || (*idx < 0))
1479 goto bad_format;
1480
1481 return true;
1482bad_format:
1483
1484
1485 CERROR("Bad volatile file name format: %s\n",
1486 name + LUSTRE_VOLATILE_HDR_LEN);
1487 return false;
1488}
1489
1490static inline int cli_brw_size(struct obd_device *obd)
1491{
1492 LASSERT(obd != NULL);
1493 return obd->u.cli.cl_max_pages_per_rpc << PAGE_CACHE_SHIFT;
1494}
1495
1496#endif
1497