6 #include <linux/obd_class.h>
7 #include <linux/lustre_mds.h>
8 #include <linux/lustre_lite.h>
10 #include <sys/types.h>
13 #define PAGE_CACHE_MAXBYTES ((__u64)(~0UL) << PAGE_CACHE_SHIFT)
16 struct obd_client_handle fd_mds_och;
22 struct obd_uuid ll_sb_uuid;
23 struct obd_export *ll_mdc_exp;
24 struct obd_export *ll_osc_exp;
27 struct list_head ll_conn_chain;
29 struct obd_uuid ll_mds_uuid;
30 struct obd_uuid ll_mds_peer_uuid;
34 #define LLI_F_HAVE_OST_SIZE_LOCK 0
35 #define LLI_F_HAVE_MDS_SIZE_LOCK 1
36 #define LLI_F_PREFER_EXTENDED_SIZE 2
38 struct llu_inode_info {
39 struct llu_sb_info *lli_sbi;
40 struct ll_fid lli_fid;
42 struct lov_stripe_md *lli_smd;
43 char *lli_symlink_name;
44 struct semaphore lli_open_sem;
46 unsigned long lli_flags;
49 struct file_identifier lli_sysio_fid;
51 struct lookup_intent *lli_it;
53 /* XXX workaround for libsysio */
56 /* in libsysio we have no chance to store data in file,
57 * so place it here. since it's possible that an file
58 * was opened several times without close, we track an
60 struct ll_file_data *lli_file_data;
63 /* stat FIXME not 64 bit clean */
72 unsigned int lli_st_blksize;
73 unsigned int lli_st_blocks;
78 /* not for stat, change it later */
80 unsigned long lli_st_generation;
83 #define LLU_SYSIO_COOKIE_SIZE(x) \
84 (sizeof(struct llu_sysio_cookie) + \
85 sizeof(struct ll_async_page) * (x) + \
86 sizeof(struct page) * (x))
88 struct llu_sysio_cookie {
89 struct obd_sync_io_container *lsc_osic;
90 struct inode *lsc_inode;
92 struct ll_async_page *lsc_llap;
93 struct page *lsc_pages;
97 /* XXX why uio.h haven't the definition? */
100 struct llu_sysio_callback_args
103 struct llu_sysio_cookie *cookies[MAX_IOVEC];
106 static inline struct llu_sb_info *llu_fs2sbi(struct filesys *fs)
108 return (struct llu_sb_info*)(fs->fs_private);
111 static inline struct llu_inode_info *llu_i2info(struct inode *inode)
113 return (struct llu_inode_info*)(inode->i_private);
116 static inline struct llu_sb_info *llu_i2sbi(struct inode *inode)
118 return llu_i2info(inode)->lli_sbi;
122 static inline struct client_obd *sbi2mdc(struct llu_sb_info *sbi)
124 struct obd_device *obd = class_conn2obd(&sbi->ll_mdc_conn);
131 static inline struct obd_export *llu_i2obdexp(struct inode *inode)
133 return llu_i2info(inode)->lli_sbi->ll_osc_exp;
136 static inline struct obd_export *llu_i2mdcexp(struct inode *inode)
138 return llu_i2info(inode)->lli_sbi->ll_mdc_exp;
142 #define LL_SAVE_INTENT(inode, it) \
144 struct lookup_intent *temp; \
145 LASSERT(llu_i2info(inode)->lli_it == NULL); \
146 OBD_ALLOC(temp, sizeof(*temp)); \
147 memcpy(temp, it, sizeof(*temp)); \
148 llu_i2info(inode)->lli_it = temp; \
149 CDEBUG(D_DENTRY, "alloc intent %p to inode %p(ino %lu)\n", \
150 temp, inode, llu_i2info(inode)->lli_st_ino); \
154 #define LL_GET_INTENT(inode, it) \
156 it = llu_i2info(inode)->lli_it; \
159 llu_i2info(inode)->lli_it = NULL; \
160 CDEBUG(D_DENTRY, "dettach intent %p from inode %p(ino %lu)\n", \
161 it, inode, llu_i2info(inode)->lli_st_ino); \
164 /* interpet return codes from intent lookup */
165 #define LL_LOOKUP_POSITIVE 1
166 #define LL_LOOKUP_NEGATIVE 2
168 static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode)
170 *fid = llu_i2info(inode)->lli_fid;
174 struct inode *icbd_parent;
175 struct pnode *icbd_child;
179 static inline void ll_i2uctxt(struct ll_uctxt *ctxt, struct inode *i1,
182 struct llu_inode_info *lli1 = llu_i2info(i1);
183 struct llu_inode_info *lli2;
188 if (in_group_p(lli1->lli_st_gid))
189 ctxt->gid1 = lli1->lli_st_gid;
194 lli2 = llu_i2info(i2);
195 if (in_group_p(lli2->lli_st_gid))
196 ctxt->gid2 = lli2->lli_st_gid;
204 typedef int (*intent_finish_cb)(struct ptlrpc_request *,
205 struct inode *parent, struct pnode *pnode,
206 struct lookup_intent *, int offset, obd_id ino);
207 int llu_intent_lock(struct inode *parent, struct pnode *pnode,
208 struct lookup_intent *, int flags, intent_finish_cb);
211 static inline int ll_permission(struct inode *inode, int flag, void * unused)
217 static inline int it_disposition(struct lookup_intent *it, int flag)
219 return it->d.lustre.it_disposition & flag;
222 static inline void it_set_disposition(struct lookup_intent *it, int flag)
224 it->d.lustre.it_disposition |= flag;
228 static inline __u64 ll_file_maxbytes(struct inode *inode)
230 return llu_i2info(inode)->lli_maxbytes;
233 struct mount_option_s
240 void generate_random_uuid(unsigned char uuid_out[16]);
241 int liblustre_process_log(struct config_llog_instance *cfg);
242 int ll_parse_mount_target(const char *target, char **mdsnid,
243 char **mdsname, char **profile);
246 extern char *g_zconf_mdsnid;
247 extern char *g_zconf_mdsname;
248 extern char *g_zconf_profile;
249 extern struct mount_option_s mount_option;
252 void llu_update_inode(struct inode *inode, struct mds_body *body,
253 struct lov_stripe_md *lmm);
254 void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid);
255 void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid);
256 //struct inode* llu_new_inode(struct filesys *fs, ino_t ino, mode_t mode);
257 //int llu_inode_getattr(struct inode *inode, struct lov_stripe_md *lsm, void *ostdata);
258 int ll_it_open_error(int phase, struct lookup_intent *it);
259 struct inode *llu_iget(struct filesys *fs, struct lustre_md *md);
260 int llu_inode_getattr(struct inode *inode, struct lov_stripe_md *lsm);
262 extern struct fssw_ops llu_fssw_ops;
265 void llu_prepare_mdc_op_data(struct mdc_op_data *data,
271 int llu_create(struct inode *dir, struct pnode_base *pnode, int mode);
272 int llu_iop_open(struct pnode *pnode, int flags, mode_t mode);
273 int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode);
274 int llu_iop_close(struct inode *inode);
275 int llu_iop_ipreadv(struct inode *ino, struct ioctx *ioctxp);
276 int llu_iop_ipwritev(struct inode *ino, struct ioctx *ioctxp);
277 int llu_vmtruncate(struct inode * inode, loff_t offset);
278 void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_flag valid);
279 int llu_objects_destroy(struct ptlrpc_request *request, struct inode *dir);
282 int llu_iop_iodone(struct ioctx *ioctxp __IS_UNUSED);
283 struct llu_sysio_callback_args*
284 llu_file_write(struct inode *inode, const struct iovec *iovec,
285 size_t iovlen, loff_t pos);
286 struct llu_sysio_callback_args*
287 llu_file_read(struct inode *inode, const struct iovec *iovec,
288 size_t iovlen, loff_t pos);
289 int llu_extent_lock_no_validate(struct ll_file_data *fd,
291 struct lov_stripe_md *lsm,
293 struct ldlm_extent *extent,
294 struct lustre_handle *lockh,
296 int llu_extent_lock(struct ll_file_data *fd, struct inode *inode,
297 struct lov_stripe_md *lsm,
298 int mode, struct ldlm_extent *extent,
299 struct lustre_handle *lockh);
300 int llu_extent_unlock(struct ll_file_data *fd, struct inode *inode,
301 struct lov_stripe_md *lsm, int mode,
302 struct lustre_handle *lockh);
305 int llu_iop_lookup(struct pnode *pnode,
307 struct intent *intnt,
309 void unhook_stale_inode(struct pnode *pno);
310 struct inode *llu_inode_from_lock(struct ldlm_lock *lock);