Whamcloud - gitweb
- unland b_fid to HEAD
[fs/lustre-release.git] / lustre / lmv / lmv_internal.h
1 #ifndef _LMV_INTERNAL_H_
2 #define _LMV_INTERNAL_H_
3
4 #define LL_IT2STR(it)                                   \
5         ((it) ? ldlm_it2str((it)->it_op) : "0")
6
7 #define MEA_SIZE_LMV(lmv)                               \
8         ((lmv)->desc.ld_tgt_count *                     \
9          sizeof(struct ll_fid) + sizeof(struct mea))
10         
11 struct lmv_inode {
12         struct ll_fid      fid;            /* fid of dirobj */
13         unsigned long      size;           /* slave size value */
14         int                flags;
15 };
16
17 #define O_FREEING          (1 << 0)
18
19 struct lmv_obj {
20         struct list_head   list;
21         struct semaphore   guard;
22         int                state;          /* object state. */
23         atomic_t           count;          /* ref counter. */
24         struct ll_fid      fid;            /* master fid of dir */
25         void               *update;        /* bitmap of status (uptodate) */
26         __u32              hashtype;
27         int                objcount;       /* number of slaves */
28         struct lmv_inode   *objs;          /* array of dirobjs */
29         struct obd_device  *obd;           /* pointer to LMV itself */
30         unsigned long      mtime;
31         unsigned long      ctime;
32         unsigned long      atime;
33         unsigned long      nlink;
34 };
35
36 static inline void
37 lmv_lock_obj(struct lmv_obj *obj)
38 {
39         LASSERT(obj);
40         down(&obj->guard);
41 }
42
43 static inline void
44 lmv_unlock_obj(struct lmv_obj *obj)
45 {
46         LASSERT(obj);
47         up(&obj->guard);
48 }
49
50 void lmv_add_obj(struct lmv_obj *obj);
51 void lmv_del_obj(struct lmv_obj *obj);
52
53 void lmv_put_obj(struct lmv_obj *obj);
54 void lmv_free_obj(struct lmv_obj *obj);
55
56 int lmv_setup_mgr(struct obd_device *obd);
57 void lmv_cleanup_mgr(struct obd_device *obd);
58 int lmv_check_connect(struct obd_device *obd);
59
60 struct lmv_obj *lmv_get_obj(struct lmv_obj *obj);
61
62 struct lmv_obj *lmv_grab_obj(struct obd_device *obd,
63                              struct ll_fid *fid);
64
65 struct lmv_obj *lmv_alloc_obj(struct obd_device *obd,
66                               struct ll_fid *fid,
67                               struct mea *mea);
68
69 struct lmv_obj *lmv_create_obj(struct obd_export *exp,
70                                struct ll_fid *fid,
71                                struct mea *mea);
72
73 int lmv_delete_obj(struct obd_export *exp, struct ll_fid *fid);
74
75 int lmv_intent_lock(struct obd_export *,
76                     struct ll_fid *, const char *, int, void *, int,
77                     struct ll_fid *, struct lookup_intent *, int,
78                     struct ptlrpc_request **, ldlm_blocking_callback);
79
80 int lmv_intent_lookup(struct obd_export *,
81                       struct ll_fid *, const char *, int, void *, int,
82                       struct ll_fid *, struct lookup_intent *, int,
83                       struct ptlrpc_request **, ldlm_blocking_callback);
84
85 int lmv_intent_getattr(struct obd_export *,
86                        struct ll_fid *, const char *, int, void *, int,
87                        struct ll_fid *, struct lookup_intent *, int,
88                        struct ptlrpc_request **, ldlm_blocking_callback);
89
90 int lmv_intent_open(struct obd_export *,
91                     struct ll_fid *, const char *, int, void *, int,
92                     struct ll_fid *, struct lookup_intent *, int,
93                     struct ptlrpc_request **, ldlm_blocking_callback);
94
95 int lmv_revalidate_slaves(struct obd_export *, struct ptlrpc_request **,
96                           struct ll_fid *, struct lookup_intent *, int,
97                           ldlm_blocking_callback cb_blocking);
98
99 int lmv_get_mea_and_update_object(struct obd_export *, struct ll_fid *);
100 int lmv_dirobj_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
101                             void *, int);
102
103 static inline struct mea * 
104 body_of_splitted_dir(struct ptlrpc_request *req, int offset)
105 {
106         struct mds_body *body;
107         struct mea *mea;
108
109         LASSERT(req);
110
111         body = lustre_msg_buf(req->rq_repmsg, offset, sizeof(*body));
112
113         if (!body || !S_ISDIR(body->mode) || !body->eadatasize)
114                 return NULL;
115
116         mea = lustre_msg_buf(req->rq_repmsg,
117                              offset + 1, body->eadatasize);
118         LASSERT(mea);
119
120         if (mea->mea_count == 0)
121                 return NULL;
122         
123         return mea;
124 }
125
126 static inline int
127 fid_equal(struct ll_fid *fid1, struct ll_fid *fid2)
128 {
129         if (fid1->mds != fid2->mds)
130                 return 0;
131         if (fid1->id != fid2->id)
132                 return 0;
133         if (fid1->generation != fid2->generation)
134                 return 0;
135         return 1;
136 }
137
138 /* lproc_lmv.c */
139 extern struct file_operations lmv_proc_target_fops;
140
141 #endif
142