1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
10 #include <obd_class.h>
11 #include <lustre_mdc.h>
12 #include <lustre_lite.h>
13 #include <lustre_ver.h>
15 #include <sys/types.h>
18 /* This should not be "optimized" use ~0ULL because page->index is a long and
19 * 32-bit systems are therefore limited to 16TB in a mapping */
20 #define PAGE_CACHE_MAXBYTES ((__u64)(~0UL) << CFS_PAGE_SHIFT)
23 struct obd_client_handle fd_mds_och;
25 struct lustre_handle fd_cwlockh;
30 struct obd_uuid ll_sb_uuid;
31 struct obd_export *ll_md_exp;
32 struct obd_export *ll_dt_exp;
33 struct lu_fid ll_root_fid;
35 struct lustre_client_ocd ll_lco;
36 struct list_head ll_conn_chain;
38 struct obd_uuid ll_mds_uuid;
39 struct obd_uuid ll_mds_peer_uuid;
43 #define LL_SBI_NOLCK 0x1
46 /* MDS has an authority for the Size-on-MDS attributes. */
47 LLIF_MDS_SIZE_LOCK = (1 << 0),
50 struct llu_inode_info {
51 struct llu_sb_info *lli_sbi;
52 struct lu_fid lli_fid;
54 struct lov_stripe_md *lli_smd;
55 char *lli_symlink_name;
56 struct semaphore lli_open_sem;
58 unsigned long lli_flags;
62 struct file_identifier lli_sysio_fid;
64 struct lookup_intent *lli_it;
66 /* XXX workaround for libsysio readdir */
69 /* in libsysio we have no chance to store data in file,
70 * so place it here. since it's possible that an file
71 * was opened several times without close, we track an
73 struct ll_file_data *lli_file_data;
77 /* not for stat, change it later */
79 unsigned long lli_st_generation;
82 static inline struct llu_sb_info *llu_fs2sbi(struct filesys *fs)
84 return (struct llu_sb_info*)(fs->fs_private);
87 static inline struct llu_inode_info *llu_i2info(struct inode *inode)
89 return (struct llu_inode_info*)(inode->i_private);
92 static inline struct intnl_stat *llu_i2stat(struct inode *inode)
94 return &inode->i_stbuf;
97 static inline struct llu_sb_info *llu_i2sbi(struct inode *inode)
99 return llu_i2info(inode)->lli_sbi;
102 static inline struct obd_export *llu_i2obdexp(struct inode *inode)
104 return llu_i2info(inode)->lli_sbi->ll_dt_exp;
107 static inline struct obd_export *llu_i2mdexp(struct inode *inode)
109 return llu_i2info(inode)->lli_sbi->ll_md_exp;
112 static inline int llu_is_root_inode(struct inode *inode)
114 return (fid_seq(&llu_i2info(inode)->lli_fid) ==
115 fid_seq(&llu_i2info(inode)->lli_sbi->ll_root_fid) &&
116 fid_oid(&llu_i2info(inode)->lli_fid) ==
117 fid_oid(&llu_i2info(inode)->lli_sbi->ll_root_fid));
120 #define LL_SAVE_INTENT(inode, it) \
122 struct lookup_intent *temp; \
123 LASSERT(llu_i2info(inode)->lli_it == NULL); \
124 OBD_ALLOC(temp, sizeof(*temp)); \
125 memcpy(temp, it, sizeof(*temp)); \
126 llu_i2info(inode)->lli_it = temp; \
127 CDEBUG(D_DENTRY, "alloc intent %p to inode %p(ino %llu)\n", \
128 temp, inode, (long long)llu_i2stat(inode)->st_ino); \
132 #define LL_GET_INTENT(inode, it) \
134 it = llu_i2info(inode)->lli_it; \
137 llu_i2info(inode)->lli_it = NULL; \
138 CDEBUG(D_DENTRY, "dettach intent %p from inode %p(ino %llu)\n", \
139 it, inode, (long long)llu_i2stat(inode)->st_ino); \
142 /* interpet return codes from intent lookup */
143 #define LL_LOOKUP_POSITIVE 1
144 #define LL_LOOKUP_NEGATIVE 2
146 static inline struct lu_fid *ll_inode2fid(struct inode *inode)
148 LASSERT(inode != NULL);
149 return &llu_i2info(inode)->lli_fid;
153 struct inode *icbd_parent;
154 struct pnode *icbd_child;
158 void ll_i2gids(__u32 *suppgids, struct inode *i1,struct inode *i2);
160 typedef int (*intent_finish_cb)(struct ptlrpc_request *,
161 struct inode *parent, struct pnode *pnode,
162 struct lookup_intent *, int offset, obd_id ino);
163 int llu_intent_lock(struct inode *parent, struct pnode *pnode,
164 struct lookup_intent *, int flags, intent_finish_cb);
166 static inline __u64 ll_file_maxbytes(struct inode *inode)
168 return llu_i2info(inode)->lli_maxbytes;
171 struct mount_option_s
177 #define IS_BAD_PTR(ptr) \
178 ((unsigned long)(ptr) == 0 || (unsigned long)(ptr) > -1000UL)
181 int liblustre_process_log(struct config_llog_instance *cfg, char *mgsnid,
182 char *profile, int allow_recov);
183 int ll_parse_mount_target(const char *target, char **mgsnid,
186 extern struct mount_option_s mount_option;
189 void llu_update_inode(struct inode *inode, struct mdt_body *body,
190 struct lov_stripe_md *lmm);
191 void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid);
192 void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid);
193 int ll_it_open_error(int phase, struct lookup_intent *it);
194 struct inode *llu_iget(struct filesys *fs, struct lustre_md *md);
195 int llu_inode_getattr(struct inode *inode, struct obdo *obdo);
196 int llu_md_setattr(struct inode *inode, struct md_op_data *op_data,
197 struct md_open_data **mod);
198 int llu_setattr_raw(struct inode *inode, struct iattr *attr);
200 extern struct fssw_ops llu_fssw_ops;
203 void llu_prep_md_op_data(struct md_op_data *op_data, struct inode *i1,
204 struct inode *i2, const char *name, int namelen,
205 int mode, __u32 opc);
206 void llu_finish_md_op_data(struct md_op_data *op_data);
207 int llu_create(struct inode *dir, struct pnode_base *pnode, int mode);
208 int llu_local_open(struct llu_inode_info *lli, struct lookup_intent *it);
209 int llu_iop_open(struct pnode *pnode, int flags, mode_t mode);
210 int llu_md_close(struct obd_export *md_exp, struct inode *inode);
211 int llu_file_release(struct inode *inode);
212 int llu_sizeonmds_update(struct inode *inode, struct md_open_data *mod,
213 struct lustre_handle *fh, __u64 ioepoch);
214 int llu_iop_close(struct inode *inode);
215 _SYSIO_OFF_T llu_iop_pos(struct inode *ino, _SYSIO_OFF_T off);
216 int llu_vmtruncate(struct inode * inode, loff_t offset, obd_flag obd_flags);
217 void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_flag valid);
218 int llu_objects_destroy(struct ptlrpc_request *request, struct inode *dir);
221 int llu_iop_read(struct inode *ino, struct ioctx *ioctxp);
222 int llu_iop_write(struct inode *ino, struct ioctx *ioctxp);
223 int llu_iop_iodone(struct ioctx *ioctxp);
224 int llu_local_size(struct inode *inode);
225 int llu_glimpse_size(struct inode *inode);
226 int llu_extent_lock(struct ll_file_data *fd, struct inode *inode,
227 struct lov_stripe_md *lsm, int mode,
228 ldlm_policy_data_t *policy, struct lustre_handle *lockh,
230 int llu_extent_unlock(struct ll_file_data *fd, struct inode *inode,
231 struct lov_stripe_md *lsm, int mode,
232 struct lustre_handle *lockh);
235 int llu_iop_lookup(struct pnode *pnode,
237 struct intent *intnt,
239 void unhook_stale_inode(struct pnode *pno);
240 struct inode *llu_inode_from_lock(struct ldlm_lock *lock);
241 int llu_md_blocking_ast(struct ldlm_lock *lock,
242 struct ldlm_lock_desc *desc,
243 void *data, int flag);
246 ssize_t llu_iop_filldirentries(struct inode *ino, _SYSIO_OFF_T *basep,
247 char *buf, size_t nbytes);
249 /* liblustre/llite_fid.c*/
250 unsigned long llu_fid_build_ino(struct llu_sb_info *sbi,
254 #define EXT2_NAME_LEN (255)
261 char name[EXT2_NAME_LEN];
264 #define EXT2_DIR_PAD 4
265 #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
266 #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
269 static inline struct ext2_dirent *ext2_next_entry(struct ext2_dirent *p)
271 return (struct ext2_dirent*)((char*) p + le16_to_cpu(p->rec_len));
274 static inline void inode_init_lvb(struct inode *inode, struct ost_lvb *lvb)
276 struct intnl_stat *st = llu_i2stat(inode);
277 lvb->lvb_size = st->st_size;
278 lvb->lvb_blocks = st->st_blocks;
279 lvb->lvb_mtime = st->st_mtime;
280 lvb->lvb_atime = st->st_atime;
281 lvb->lvb_ctime = st->st_ctime;