Whamcloud - gitweb
land b1_5 onto HEAD
[fs/lustre-release.git] / lustre / include / lustre_mds.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  * MDS data structures.
7  * See also lustre_idl.h for wire formats of requests.
8  */
9
10 #ifndef _LUSTRE_MDS_H
11 #define _LUSTRE_MDS_H
12
13 #include <lustre_handles.h>
14 #include <libcfs/kp30.h>
15 #include <lustre/lustre_idl.h>
16 #include <lustre_lib.h>
17 #include <lustre_dlm.h>
18 #include <lustre_log.h>
19 #include <lustre_export.h>
20
21 #if defined(__linux__)
22 #include <linux/lustre_mds.h>
23 #elif defined(__APPLE__)
24 #include <darwin/lustre_mds.h>
25 #elif defined(__WINNT__)
26 #include <winnt/lustre_mds.h>
27 #else
28 #error Unsupported operating system.
29 #endif
30
31 struct ldlm_lock_desc;
32 struct mds_obd;
33 struct ptlrpc_connection;
34 struct ptlrpc_client;
35 struct obd_export;
36 struct ptlrpc_request;
37 struct obd_device;
38 struct ll_file_data;
39
40 struct lustre_md {
41         struct mds_body         *body;
42         struct lov_stripe_md    *lsm;
43 #ifdef CONFIG_FS_POSIX_ACL
44         struct posix_acl        *posix_acl;
45 #endif
46 };
47
48 struct mdc_op_data {
49         struct ll_fid    fid1;
50         struct ll_fid    fid2;
51         __u64            mod_time;
52         const char      *name;
53         int              namelen;
54         __u32            create_mode;
55         __u32            suppgids[2];
56 };
57
58 struct mds_update_record {
59         __u32 ur_opcode;
60         struct ll_fid *ur_fid1;
61         struct ll_fid *ur_fid2;
62         int ur_namelen;
63         char *ur_name;
64         int ur_tgtlen;
65         char *ur_tgt;
66         int ur_eadatalen;
67         void *ur_eadata;
68         int ur_cookielen;
69         struct llog_cookie *ur_logcookies;
70         struct iattr ur_iattr;
71         struct lvfs_ucred ur_uc;
72         __u64 ur_rdev;
73         __u64 ur_time;
74         __u32 ur_mode;
75         __u32 ur_flags;
76         struct lvfs_grp_hash_entry *ur_grp_entry;
77 };
78
79 /* file data for open files on MDS */
80 struct mds_file_data {
81         struct portals_handle mfd_handle; /* must be first */
82         atomic_t              mfd_refcount;
83         struct list_head      mfd_list; /* protected by med_open_lock */
84         __u64                 mfd_xid;
85         int                   mfd_mode;
86         struct dentry        *mfd_dentry;
87 };
88
89 /* ACL */
90 #ifdef CONFIG_FS_POSIX_ACL
91 #ifdef HAVE_XATTR_ACL
92 #  define MDS_XATTR_NAME_ACL_ACCESS XATTR_NAME_ACL_ACCESS
93 #  define mds_xattr_acl_size(entry) xattr_acl_size(entry)
94 # else
95 #  define MDS_XATTR_NAME_ACL_ACCESS POSIX_ACL_XATTR_ACCESS
96 #  define mds_xattr_acl_size(entry) posix_acl_xattr_size(entry)
97 # endif
98 # define LUSTRE_POSIX_ACL_MAX_ENTRIES   (32)
99 # define LUSTRE_POSIX_ACL_MAX_SIZE      \
100                 (mds_xattr_acl_size(LUSTRE_POSIX_ACL_MAX_ENTRIES))
101 #else
102 # define LUSTRE_POSIX_ACL_MAX_SIZE      0
103 #endif
104
105 /* mds/mds_reint.c */
106 int mds_reint_rec(struct mds_update_record *r, int offset,
107                   struct ptlrpc_request *req, struct lustre_handle *);
108
109 /* mds/mds_lov.c */
110
111 /* mdc/mdc_locks.c */
112 int it_disposition(struct lookup_intent *it, int flag);
113 void it_set_disposition(struct lookup_intent *it, int flag);
114 void it_clear_disposition(struct lookup_intent *it, int flag);
115 int it_open_error(int phase, struct lookup_intent *it);
116 void mdc_set_lock_data(__u64 *lockh, void *data);
117 int mdc_change_cbdata(struct obd_export *exp, struct ll_fid *fid,
118                       ldlm_iterator_t it, void *data);
119 int mdc_intent_lock(struct obd_export *exp,
120                     struct mdc_op_data *,
121                     void *lmm, int lmmsize,
122                     struct lookup_intent *, int,
123                     struct ptlrpc_request **reqp,
124                     ldlm_blocking_callback cb_blocking, int extra_lock_flags);
125 int mdc_enqueue(struct obd_export *exp,
126                 int lock_type,
127                 struct lookup_intent *it,
128                 int lock_mode,
129                 struct mdc_op_data *data,
130                 struct lustre_handle *lockh,
131                 void *lmm,
132                 int lmmlen,
133                 ldlm_completion_callback cb_completion,
134                 ldlm_blocking_callback cb_blocking,
135                 void *cb_data, int extra_lock_flags);
136
137 /* mdc/mdc_request.c */
138 int mdc_init_ea_size(struct obd_export *mdc_exp, struct obd_export *lov_exp);
139 int mdc_req2lustre_md(struct ptlrpc_request *req, int offset,
140                       struct obd_export *exp, struct lustre_md *md);
141 void mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md);
142 int mdc_getstatus(struct obd_export *exp, struct ll_fid *rootfid);
143 int mdc_getattr(struct obd_export *exp, struct ll_fid *fid,
144                 obd_valid valid, unsigned int ea_size,
145                 struct ptlrpc_request **request);
146 int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid,
147                      const char *filename, int namelen, unsigned long valid,
148                      unsigned int ea_size, struct ptlrpc_request **request);
149 int mdc_setattr(struct obd_export *exp, struct mdc_op_data *data,
150                 struct iattr *iattr, void *ea, int ealen, void *ea2, int ea2len,
151                 struct ptlrpc_request **request);
152 int mdc_setxattr(struct obd_export *exp, struct ll_fid *fid,
153                  obd_valid valid, const char *xattr_name,
154                  const char *input, int input_size,
155                  int output_size, int flags,
156                  struct ptlrpc_request **request);
157 int mdc_getxattr(struct obd_export *exp, struct ll_fid *fid,
158                  obd_valid valid, const char *xattr_name,
159                  const char *input, int input_size,
160                  int output_size, struct ptlrpc_request **request);
161 int mdc_open(struct obd_export *exp, obd_id ino, int type, int flags,
162              struct lov_mds_md *lmm, int lmm_size, struct lustre_handle *fh,
163              struct ptlrpc_request **);
164 struct obd_client_handle;
165 void mdc_set_open_replay_data(struct obd_client_handle *och,
166                               struct ptlrpc_request *open_req);
167 void mdc_clear_open_replay_data(struct obd_client_handle *och);
168 int mdc_close(struct obd_export *, struct obdo *, struct obd_client_handle *,
169               struct ptlrpc_request **);
170 int mdc_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, __u64 offset,
171                  struct page *, struct ptlrpc_request **);
172 int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data,
173                const void *data, int datalen, int mode, __u32 uid, __u32 gid,
174                __u32 cap_effective, __u64 rdev,struct ptlrpc_request **request);
175 int mdc_unlink(struct obd_export *exp, struct mdc_op_data *data,
176                struct ptlrpc_request **request);
177 int mdc_link(struct obd_export *exp, struct mdc_op_data *data,
178              struct ptlrpc_request **);
179 int mdc_rename(struct obd_export *exp, struct mdc_op_data *data,
180                const char *old, int oldlen, const char *new, int newlen,
181                struct ptlrpc_request **request);
182 int mdc_sync(struct obd_export *exp, struct ll_fid *fid,
183              struct ptlrpc_request **);
184 int mdc_create_client(struct obd_uuid uuid, struct ptlrpc_client *cl);
185
186 /* Store the generation of a newly-created inode in |req| for replay. */
187 void mdc_store_inode_generation(struct ptlrpc_request *req, int reqoff,
188                                 int repoff);
189 int mdc_llog_process(struct obd_export *, char *logname, llog_cb_t, void *data);
190 int mdc_done_writing(struct obd_export *exp, struct obdo *);
191
192 static inline void mdc_pack_fid(struct ll_fid *fid, obd_id ino, __u32 gen,
193                                 int type)
194 {
195         fid->id = ino;
196         fid->generation = gen;
197         fid->f_type = type;
198 }
199
200 /* ioctls for trying requests */
201 #define IOC_REQUEST_TYPE                   'f'
202 #define IOC_REQUEST_MIN_NR                 30
203
204 #define IOC_REQUEST_GETATTR             _IOWR('f', 30, long)
205 #define IOC_REQUEST_READPAGE            _IOWR('f', 31, long)
206 #define IOC_REQUEST_SETATTR             _IOWR('f', 32, long)
207 #define IOC_REQUEST_CREATE              _IOWR('f', 33, long)
208 #define IOC_REQUEST_OPEN                _IOWR('f', 34, long)
209 #define IOC_REQUEST_CLOSE               _IOWR('f', 35, long)
210 #define IOC_REQUEST_MAX_NR               35
211
212 #endif