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