Whamcloud - gitweb
land b1_5 onto HEAD
[fs/lustre-release.git] / lustre / mdc / mdc_internal.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *   This file is part of Lustre, http://www.lustre.org
5  *
6  * MDC internal definitions.
7  */
8
9 #include <lustre_mds.h>
10 void mdc_pack_req_body(struct ptlrpc_request *req, int offset,
11                        __u64 valid, struct ll_fid *fid, int ea_size, int flags);
12 void mdc_pack_rep_body(struct ptlrpc_request *);
13 void mdc_readdir_pack(struct ptlrpc_request *req, int offset, __u64 pg_off,
14                       __u32 size, struct ll_fid *mdc_fid);
15 void mdc_getattr_pack(struct ptlrpc_request *req, int offset, int valid,
16                       int flags, struct mdc_op_data *data);
17 void mdc_setattr_pack(struct ptlrpc_request *req, int offset,
18                       struct mdc_op_data *data,
19                       struct iattr *iattr, void *ea, int ealen,
20                       void *ea2, int ea2len);
21 void mdc_create_pack(struct ptlrpc_request *req, int offset,
22                      struct mdc_op_data *op_data, const void *data, int datalen,
23                      __u32 mode, __u32 uid, __u32 gid, __u32 cap_effective,
24                      __u64 rdev);
25 void mdc_open_pack(struct ptlrpc_request *req, int offset,
26                    struct mdc_op_data *op_data, __u32 mode, __u64 rdev,
27                    __u32 flags, const void *data, int datalen);
28 void mdc_join_pack(struct ptlrpc_request *req, int offset,
29                    struct mdc_op_data *op_data, __u64 head_size);
30 void mdc_unlink_pack(struct ptlrpc_request *req, int offset,
31                      struct mdc_op_data *data);
32 void mdc_link_pack(struct ptlrpc_request *req, int offset,
33                    struct mdc_op_data *data);
34 void mdc_rename_pack(struct ptlrpc_request *req, int offset,
35                      struct mdc_op_data *data,
36                      const char *old, int oldlen, const char *new, int newlen);
37 void mdc_close_pack(struct ptlrpc_request *req, int offset, struct obdo *oa,
38                     int valid, struct obd_client_handle *och);
39 void mdc_exit_request(struct client_obd *cli);
40 void mdc_enter_request(struct client_obd *cli);
41
42 struct mdc_open_data {
43         struct obd_client_handle *mod_och;
44         struct ptlrpc_request    *mod_open_req;
45         struct ptlrpc_request    *mod_close_req;
46 };
47
48 struct mdc_rpc_lock {
49         struct semaphore rpcl_sem;
50         struct lookup_intent *rpcl_it;
51 };
52
53 static inline void mdc_init_rpc_lock(struct mdc_rpc_lock *lck)
54 {
55         sema_init(&lck->rpcl_sem, 1);
56         lck->rpcl_it = NULL;
57 }
58
59 static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck,
60                                     struct lookup_intent *it)
61 {
62         ENTRY;
63         if (!it || (it->it_op != IT_GETATTR && it->it_op != IT_LOOKUP)) {
64                 down(&lck->rpcl_sem);
65                 LASSERT(lck->rpcl_it == NULL);
66                 lck->rpcl_it = it;
67         }
68 }
69
70 static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck,
71                                     struct lookup_intent *it)
72 {
73         if (!it || (it->it_op != IT_GETATTR && it->it_op != IT_LOOKUP)) {
74                 LASSERT(it == lck->rpcl_it);
75                 lck->rpcl_it = NULL;
76                 up(&lck->rpcl_sem);
77         }
78         EXIT;
79 }