Whamcloud - gitweb
843bcbe6a1bf1c7e204c74b523765f7a58c3a575
[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 #ifdef LPROCFS
11 void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars);
12 #else
13 static inline void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
14 {
15         memset(lvars, 0, sizeof(*lvars));
16 }
17 #endif
18 void mdc_pack_req_body(struct ptlrpc_request *req, int offset,
19                        __u64 valid, struct ll_fid *fid, int ea_size, int flags);
20 void mdc_pack_rep_body(struct ptlrpc_request *);
21 void mdc_readdir_pack(struct ptlrpc_request *req, int offset, __u64 pg_off,
22                       __u32 size, struct ll_fid *mdc_fid);
23 void mdc_getattr_pack(struct ptlrpc_request *req, int offset, __u64 valid,
24                       int flags, struct mdc_op_data *data);
25 void mdc_setattr_pack(struct ptlrpc_request *req, int offset,
26                       struct mdc_op_data *data,
27                       struct iattr *iattr, void *ea, int ealen,
28                       void *ea2, int ea2len);
29 void mdc_create_pack(struct ptlrpc_request *req, int offset,
30                      struct mdc_op_data *op_data, const void *data, int datalen,
31                      __u32 mode, __u32 uid, __u32 gid, __u32 cap_effective,
32                      __u64 rdev);
33 void mdc_open_pack(struct ptlrpc_request *req, int offset,
34                    struct mdc_op_data *op_data, __u32 mode, __u64 rdev,
35                    __u32 flags, const void *data, int datalen);
36 void mdc_join_pack(struct ptlrpc_request *req, int offset,
37                    struct mdc_op_data *op_data, __u64 head_size);
38 void mdc_unlink_pack(struct ptlrpc_request *req, int offset,
39                      struct mdc_op_data *data);
40 void mdc_link_pack(struct ptlrpc_request *req, int offset,
41                    struct mdc_op_data *data);
42 void mdc_rename_pack(struct ptlrpc_request *req, int offset,
43                      struct mdc_op_data *data,
44                      const char *old, int oldlen, const char *new, int newlen);
45 void mdc_close_pack(struct ptlrpc_request *req, int offset, struct obdo *oa,
46                     __u64 valid, struct obd_client_handle *och);
47 void mdc_exit_request(struct client_obd *cli);
48 void mdc_enter_request(struct client_obd *cli);
49
50 struct mdc_open_data {
51         struct obd_client_handle *mod_och;
52         struct ptlrpc_request    *mod_open_req;
53         struct ptlrpc_request    *mod_close_req;
54 };
55
56 struct mdc_rpc_lock {
57         struct semaphore rpcl_sem;
58         struct lookup_intent *rpcl_it;
59 };
60
61 static inline void mdc_init_rpc_lock(struct mdc_rpc_lock *lck)
62 {
63         sema_init(&lck->rpcl_sem, 1);
64         lck->rpcl_it = NULL;
65 }
66
67 static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck,
68                                     struct lookup_intent *it)
69 {
70         ENTRY;
71         if (!it || (it->it_op != IT_GETATTR && it->it_op != IT_LOOKUP)) {
72                 down(&lck->rpcl_sem);
73                 LASSERT(lck->rpcl_it == NULL);
74                 lck->rpcl_it = it;
75         }
76 }
77
78 static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck,
79                                     struct lookup_intent *it)
80 {
81         if (!it || (it->it_op != IT_GETATTR && it->it_op != IT_LOOKUP)) {
82                 LASSERT(it == lck->rpcl_it);
83                 lck->rpcl_it = NULL;
84                 up(&lck->rpcl_sem);
85         }
86         EXIT;
87 }