Whamcloud - gitweb
Fixes and cleanups in lmv.
[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) ((it) ? ldlm_it2str((it)->it_op) : "0")
5 #define MEA_SIZE_LMV(lmv)       \
6         ((lmv)->desc.ld_tgt_count * sizeof(struct ll_fid) + sizeof(struct mea))
7         
8 struct lmv_inode {
9         struct ll_fid   fid;            /* fid of dirobj */
10         unsigned long   size;
11         int             flags;
12 };
13
14 struct lmv_obj {
15         struct list_head        list;
16         atomic_t                count;
17         struct ll_fid           fid;            /* master fid of dir */
18         void                    *update;        /* bitmap of status (uptodate) */
19         int                     objcount;
20         struct lmv_inode        *objs;          /* array of dirobjs */
21         struct obd_device       *obd;           /* pointer to LMV itself */
22 };
23
24 int lmv_dirobj_blocking_ast(struct ldlm_lock *,
25                             struct ldlm_lock_desc *, void *, int);
26 struct lmv_obj *lmv_grab_obj(struct obd_device *obd,
27                              struct ll_fid *fid, int create);
28 void lmv_put_obj(struct lmv_obj *obj);
29
30 int lmv_intent_lock(struct obd_export *, struct ll_uctxt *,
31                     struct ll_fid *, const char *, int, void *, int,
32                     struct ll_fid *, struct lookup_intent *, int,
33                     struct ptlrpc_request **, ldlm_blocking_callback);
34 int lmv_intent_lookup(struct obd_export *, struct ll_uctxt *,
35                       struct ll_fid *, const char *, int, void *, int,
36                       struct ll_fid *, struct lookup_intent *, int,
37                       struct ptlrpc_request **, ldlm_blocking_callback);
38 int lmv_intent_getattr(struct obd_export *, struct ll_uctxt *,
39                        struct ll_fid *, const char *, int, void *, int,
40                        struct ll_fid *, struct lookup_intent *, int,
41                        struct ptlrpc_request **, ldlm_blocking_callback);
42 int lmv_intent_open(struct obd_export *, struct ll_uctxt *,
43                     struct ll_fid *, const char *, int, void *, int,
44                     struct ll_fid *, struct lookup_intent *, int,
45                     struct ptlrpc_request **, ldlm_blocking_callback);
46 int lmv_create_obj_from_attrs(struct obd_export *, struct ll_fid *,
47                                 struct mea *);
48 int lmv_check_connect(struct obd_device *obd);
49 int lmv_revalidate_slaves(struct obd_export *, struct ptlrpc_request **,
50                           struct ll_fid *, struct lookup_intent *, int,
51                           ldlm_blocking_callback cb_blocking);
52 void lmv_cleanup_objs(struct obd_device *obd);
53 int lmv_get_mea_and_update_object(struct obd_export *, struct ll_fid *);
54
55 static inline struct mea * 
56 is_body_of_splitted_dir(struct ptlrpc_request *req, int offset)
57 {
58         struct mds_body *body;
59         struct mea *mea;
60
61         LASSERT(req);
62
63         body = lustre_msg_buf(req->rq_repmsg, offset, sizeof(*body));
64
65         if (!body || !S_ISDIR(body->mode) || !body->eadatasize)
66                 return NULL;
67
68         mea = lustre_msg_buf(req->rq_repmsg, offset + 1, body->eadatasize);
69         LASSERT(mea);
70
71         if (mea->mea_count == 0)
72                 return NULL;
73         
74         return mea;
75 }
76
77 static inline int fid_equal(struct ll_fid *fid1, struct ll_fid *fid2)
78 {
79         if (fid1->mds != fid2->mds)
80                 return 0;
81         if (fid1->id != fid2->id)
82                 return 0;
83         if (fid1->generation != fid2->generation)
84                 return 0;
85         return 1;
86 }
87
88 #endif
89