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_mds.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;
31 struct obd_uuid ll_sb_uuid;
32 struct obd_export *ll_mdc_exp;
33 struct obd_export *ll_osc_exp;
36 struct lustre_client_ocd ll_lco;
37 struct list_head ll_conn_chain;
39 struct obd_uuid ll_mds_uuid;
40 struct obd_uuid ll_mds_peer_uuid;
44 #define LL_SBI_NOLCK 0x1
46 #define LLI_F_HAVE_OST_SIZE_LOCK 0
47 #define LLI_F_HAVE_MDS_SIZE_LOCK 1
49 struct llu_inode_info {
50 struct llu_sb_info *lli_sbi;
51 struct ll_fid lli_fid;
53 struct lov_stripe_md *lli_smd;
54 char *lli_symlink_name;
55 struct semaphore lli_open_sem;
57 unsigned long lli_flags;
60 struct file_identifier lli_sysio_fid;
62 struct lookup_intent *lli_it;
64 /* XXX workaround for libsysio readdir */
67 /* in libsysio we have no chance to store data in file,
68 * so place it here. since it's possible that an file
69 * was opened several times without close, we track an
71 struct ll_file_data *lli_file_data;
75 /* not for stat, change it later */
77 unsigned long lli_st_generation;
80 static inline struct llu_sb_info *llu_fs2sbi(struct filesys *fs)
82 return (struct llu_sb_info*)(fs->fs_private);
85 static inline struct llu_inode_info *llu_i2info(struct inode *inode)
87 return (struct llu_inode_info*)(inode->i_private);
90 static inline struct intnl_stat *llu_i2stat(struct inode *inode)
92 return &inode->i_stbuf;
95 static inline struct llu_sb_info *llu_i2sbi(struct inode *inode)
97 return llu_i2info(inode)->lli_sbi;
100 static inline struct obd_export *llu_i2obdexp(struct inode *inode)
102 return llu_i2info(inode)->lli_sbi->ll_osc_exp;
105 static inline struct obd_export *llu_i2mdcexp(struct inode *inode)
107 return llu_i2info(inode)->lli_sbi->ll_mdc_exp;
110 static inline int llu_is_root_inode(struct inode *inode)
112 return (llu_i2info(inode)->lli_fid.id ==
113 llu_i2info(inode)->lli_sbi->ll_rootino);
116 #define LL_SAVE_INTENT(inode, it) \
118 struct lookup_intent *temp; \
119 LASSERT(llu_i2info(inode)->lli_it == NULL); \
120 OBD_ALLOC(temp, sizeof(*temp)); \
121 memcpy(temp, it, sizeof(*temp)); \
122 llu_i2info(inode)->lli_it = temp; \
123 CDEBUG(D_DENTRY, "alloc intent %p to inode %p(ino %llu)\n", \
124 temp, inode, (long long)llu_i2stat(inode)->st_ino); \
128 #define LL_GET_INTENT(inode, it) \
130 it = llu_i2info(inode)->lli_it; \
133 llu_i2info(inode)->lli_it = NULL; \
134 CDEBUG(D_DENTRY, "dettach intent %p from inode %p(ino %llu)\n", \
135 it, inode, (long long)llu_i2stat(inode)->st_ino); \
138 /* interpet return codes from intent lookup */
139 #define LL_LOOKUP_POSITIVE 1
140 #define LL_LOOKUP_NEGATIVE 2
142 static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode)
144 *fid = llu_i2info(inode)->lli_fid;
148 struct inode *icbd_parent;
149 struct pnode *icbd_child;
153 void ll_i2gids(__u32 *suppgids, struct inode *i1,struct inode *i2);
155 typedef int (*intent_finish_cb)(struct ptlrpc_request *,
156 struct inode *parent, struct pnode *pnode,
157 struct lookup_intent *, int offset, obd_id ino);
158 int llu_intent_lock(struct inode *parent, struct pnode *pnode,
159 struct lookup_intent *, int flags, intent_finish_cb);
161 static inline __u64 ll_file_maxbytes(struct inode *inode)
163 return llu_i2info(inode)->lli_maxbytes;
166 struct mount_option_s
172 #define IS_BAD_PTR(ptr) \
173 ((unsigned long)(ptr) == 0 || (unsigned long)(ptr) > -1000UL)
176 void generate_random_uuid(unsigned char uuid_out[16]);
177 int liblustre_process_log(struct config_llog_instance *cfg, char *mgsnid,
178 char *profile, int allow_recov);
179 int ll_parse_mount_target(const char *target, char **mgsnid,
182 extern struct mount_option_s mount_option;
185 void llu_update_inode(struct inode *inode, struct mds_body *body,
186 struct lov_stripe_md *lmm);
187 void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid);
188 void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid);
189 int ll_it_open_error(int phase, struct lookup_intent *it);
190 struct inode *llu_iget(struct filesys *fs, struct lustre_md *md);
191 int llu_inode_getattr(struct inode *inode, struct lov_stripe_md *lsm);
192 int llu_setattr_raw(struct inode *inode, struct iattr *attr);
194 extern struct fssw_ops llu_fssw_ops;
197 void llu_prepare_mdc_op_data(struct mdc_op_data *data,
203 int llu_create(struct inode *dir, struct pnode_base *pnode, int mode);
204 int llu_local_open(struct llu_inode_info *lli, struct lookup_intent *it);
205 int llu_iop_open(struct pnode *pnode, int flags, mode_t mode);
206 int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode);
207 int llu_file_release(struct inode *inode);
208 int llu_iop_close(struct inode *inode);
209 _SYSIO_OFF_T llu_iop_pos(struct inode *ino, _SYSIO_OFF_T off);
210 int llu_vmtruncate(struct inode * inode, loff_t offset, obd_flag obd_flags);
211 void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_flag valid);
212 int llu_objects_destroy(struct ptlrpc_request *request, struct inode *dir);
215 int llu_iop_read(struct inode *ino, struct ioctx *ioctxp);
216 int llu_iop_write(struct inode *ino, struct ioctx *ioctxp);
217 int llu_iop_iodone(struct ioctx *ioctxp);
218 int llu_glimpse_size(struct inode *inode);
219 int llu_extent_lock(struct ll_file_data *fd, struct inode *inode,
220 struct lov_stripe_md *lsm, int mode,
221 ldlm_policy_data_t *policy, struct lustre_handle *lockh,
223 int llu_extent_unlock(struct ll_file_data *fd, struct inode *inode,
224 struct lov_stripe_md *lsm, int mode,
225 struct lustre_handle *lockh);
228 int llu_iop_lookup(struct pnode *pnode,
230 struct intent *intnt,
232 void unhook_stale_inode(struct pnode *pno);
233 struct inode *llu_inode_from_lock(struct ldlm_lock *lock);
234 int llu_mdc_blocking_ast(struct ldlm_lock *lock,
235 struct ldlm_lock_desc *desc,
236 void *data, int flag);
239 ssize_t llu_iop_filldirentries(struct inode *ino, _SYSIO_OFF_T *basep,
240 char *buf, size_t nbytes);
243 #define EXT2_NAME_LEN (255)
250 char name[EXT2_NAME_LEN];
253 #define EXT2_DIR_PAD 4
254 #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
255 #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
258 static inline struct ext2_dirent *ext2_next_entry(struct ext2_dirent *p)
260 return (struct ext2_dirent*)((char*) p + le16_to_cpu(p->rec_len));
263 static inline void inode_init_lvb(struct inode *inode, struct ost_lvb *lvb)
265 struct intnl_stat *st = llu_i2stat(inode);
266 lvb->lvb_size = st->st_size;
267 lvb->lvb_blocks = st->st_blocks;
268 lvb->lvb_mtime = st->st_mtime;
269 lvb->lvb_atime = st->st_atime;
270 lvb->lvb_ctime = st->st_ctime;