Whamcloud - gitweb
Fixes with managing objects in LMV object manager.
[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         struct semaphore        guard;
17         int                     freeing;        /* object ig freeing. */
18         atomic_t                count;
19         struct ll_fid           fid;            /* master fid of dir */
20         void                    *update;        /* bitmap of status (uptodate) */
21         int                     objcount;
22         struct lmv_inode        *objs;          /* array of dirobjs */
23         struct obd_device       *obd;           /* pointer to LMV itself */
24 };
25
26 int lmv_setup_mgr(struct obd_device *obd);
27 void lmv_cleanup_mgr(struct obd_device *obd);
28 int lmv_check_connect(struct obd_device *obd);
29
30 void lmv_put_obj(struct lmv_obj *obj);
31 struct lmv_obj *lmv_get_obj(struct lmv_obj *obj);
32
33 struct lmv_obj *lmv_grab_obj(struct obd_device *obd,
34                              struct ll_fid *fid);
35
36 void lmv_free_obj(struct lmv_obj *obj);
37 void lmv_add_obj(struct lmv_obj *obj);
38 void lmv_del_obj(struct lmv_obj *obj);
39
40 struct lmv_obj *lmv_alloc_obj(struct obd_device *obd,
41                               struct ll_fid *fid,
42                               struct mea *mea);
43
44 int lmv_create_obj(struct obd_export *exp, struct ll_fid *fid,
45                    struct mea *mea);
46
47 int lmv_destroy_obj(struct obd_export *exp, struct ll_fid *fid);
48
49 int lmv_intent_lock(struct obd_export *, struct ll_uctxt *,
50                     struct ll_fid *, const char *, int, void *, int,
51                     struct ll_fid *, struct lookup_intent *, int,
52                     struct ptlrpc_request **, ldlm_blocking_callback);
53
54 int lmv_intent_lookup(struct obd_export *, struct ll_uctxt *,
55                       struct ll_fid *, const char *, int, void *, int,
56                       struct ll_fid *, struct lookup_intent *, int,
57                       struct ptlrpc_request **, ldlm_blocking_callback);
58
59 int lmv_intent_getattr(struct obd_export *, struct ll_uctxt *,
60                        struct ll_fid *, const char *, int, void *, int,
61                        struct ll_fid *, struct lookup_intent *, int,
62                        struct ptlrpc_request **, ldlm_blocking_callback);
63
64 int lmv_intent_open(struct obd_export *, struct ll_uctxt *,
65                     struct ll_fid *, const char *, int, void *, int,
66                     struct ll_fid *, struct lookup_intent *, int,
67                     struct ptlrpc_request **, ldlm_blocking_callback);
68
69 int lmv_revalidate_slaves(struct obd_export *, struct ptlrpc_request **,
70                           struct ll_fid *, struct lookup_intent *, int,
71                           ldlm_blocking_callback cb_blocking);
72
73 int lmv_get_mea_and_update_object(struct obd_export *, struct ll_fid *);
74
75 int lmv_dirobj_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
76                             void *, int);
77
78 static inline struct mea * 
79 is_body_of_splitted_dir(struct ptlrpc_request *req, int offset)
80 {
81         struct mds_body *body;
82         struct mea *mea;
83
84         LASSERT(req);
85
86         body = lustre_msg_buf(req->rq_repmsg, offset, sizeof(*body));
87
88         if (!body || !S_ISDIR(body->mode) || !body->eadatasize)
89                 return NULL;
90
91         mea = lustre_msg_buf(req->rq_repmsg, offset + 1, body->eadatasize);
92         LASSERT(mea);
93
94         if (mea->mea_count == 0)
95                 return NULL;
96         
97         return mea;
98 }
99
100 static inline int fid_equal(struct ll_fid *fid1, struct ll_fid *fid2)
101 {
102         if (fid1->mds != fid2->mds)
103                 return 0;
104         if (fid1->id != fid2->id)
105                 return 0;
106         if (fid1->generation != fid2->generation)
107                 return 0;
108         return 1;
109 }
110
111 #endif
112