From: yury Date: Fri, 7 Apr 2006 10:29:35 +0000 (+0000) Subject: - many changes about fids: X-Git-Tag: v1_8_0_110~486^2~2082 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=c6d61a0e57c4bc9e8f6809c103f5836b87afcbe5;p=fs%2Flustre-release.git - many changes about fids: (1) client, mdc and liblustre converted to use new fids; (2) some md related structures renamed into mdt ones to use new fids with no changing anything about MDS code; (3) md methods used obdo switched to use mdc_op_data like others; (4) f_num is now replaced to f_ver and f_oid. --- diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h index 5fcec00..e006a84 100644 --- a/lustre/include/linux/lustre_idl.h +++ b/lustre/include/linux/lustre_idl.h @@ -626,54 +626,49 @@ struct lu_fid { __u64 f_seq; /* holds fid sequence. Lustre should support 2 ^ 64 * objects, thus even if one sequence has one object we * reach this value. */ - __u64 f_num; /* firt 32 bits holds fid number and another 32 bits holds - * version of object. */ + __u32 f_oid; /* fid number within its sequence. */ + __u32 f_ver; /* holds fid version. */ }; +/* maximal objects in sequence */ +#define LUSTRE_FID_SEQ_WIDTH 10000 + +/* shift of version component */ +#define LUSTRE_FID_VER_SHIFT (sizeof(((struct lu_fid *)0)->f_ver) * 8) + /* get object sequence */ static inline __u64 fid_seq(const struct lu_fid *fid) { return fid->f_seq; } -/* get complex object number (id + version) */ -static inline __u64 fid_num(const struct lu_fid *fid) -{ - return fid->f_num; -} - -/* maximal objects in sequence */ -#define LUSTRE_FID_SEQ_WIDTH 10000 - -/* object id is stored in rightmost 32 bits and version in leftmost 32 bits. So - * that if object has no version component ->f_num shows object id and no need - * to mask anything out. */ -#define LUSTRE_FID_OID_MASK 0x00000000ffffffffull -#define LUSTRE_FID_VER_MASK (~LUSTRE_FID_OID_MASK) - -/* shifts of both components */ -#define LUSTRE_FID_OID_SHIFT 0 -#define LUSTRE_FID_VER_SHIFT (sizeof(((struct lu_fid *)0)->f_num) / 2 * 8) - /* get object id */ static inline __u32 fid_oid(const struct lu_fid *fid) { - return (__u32)((fid->f_num & LUSTRE_FID_OID_MASK) >> LUSTRE_FID_OID_SHIFT); + return fid->f_oid; } /* get object version */ static inline __u32 fid_ver(const struct lu_fid *fid) { - return (__u32)((fid->f_num & LUSTRE_FID_VER_MASK) >> LUSTRE_FID_VER_SHIFT); + return fid->f_ver; +} + +/* get complex object number (oid + version) */ +static inline __u64 fid_num(const struct lu_fid *fid) +{ + __u64 f_ver = fid_ver(fid); + f_ver = f_ver << LUSTRE_FID_VER_SHIFT; + return f_ver | fid_oid(fid); } /* show sequence, object id and version */ -#define DFID3 LPU64"/%lu:%lu" +#define DFID3 LPU64"/%u:%u" #define PFID3(fid) \ fid_seq(fid), \ - fid_num(fid), \ - fid_num(fid) + fid_oid(fid), \ + fid_ver(fid) /* temporary stuff for compatibility */ struct ll_fid { @@ -692,7 +687,7 @@ static inline int lu_fid_eq(const struct lu_fid *f0, const struct lu_fid *f1) { /* check that there is no alignment padding */ CLASSERT(sizeof *f0 == - sizeof f0->f_seq + sizeof f0->f_num); + sizeof f0->f_seq + sizeof f0->f_oid + sizeof f0->f_ver); return memcmp(f0, f1, sizeof *f0) == 0; } @@ -813,13 +808,34 @@ struct mds_rec_setattr { __u32 sa_padding; /* also fix lustre_swab_mds_rec_setattr */ }; +extern void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa); + +struct mdt_rec_setattr { + __u32 sa_opcode; + __u32 sa_fsuid; + __u32 sa_fsgid; + __u32 sa_cap; + __u32 sa_suppgid; + __u32 sa_mode; + struct lu_fid sa_fid; + __u64 sa_valid; + __u64 sa_size; + __u64 sa_mtime; + __u64 sa_atime; + __u64 sa_ctime; + __u32 sa_uid; + __u32 sa_gid; + __u32 sa_attr_flags; + __u32 sa_padding; /* also fix lustre_swab_mds_rec_setattr */ +}; + +extern void lustre_swab_mdt_rec_setattr (struct mdt_rec_setattr *sa); + /* Remove this once we declare it in include/linux/fs.h (v21 kernel patch?) */ #ifndef ATTR_CTIME_SET #define ATTR_CTIME_SET 0x2000 #endif -extern void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa); - #ifndef FMODE_READ #define FMODE_READ 00000001 #define FMODE_WRITE 00000002 @@ -840,6 +856,20 @@ extern void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa); #define MDS_OPEN_HAS_EA 010000000000 /* specify object create pattern */ #define MDS_OPEN_HAS_OBJS 020000000000 /* Just set the EA the obj exist */ +struct mds_rec_join { + struct ll_fid jr_fid; + __u64 jr_headsize; +}; + +extern void lustre_swab_mds_rec_join (struct mds_rec_join *jr); + +struct mdt_rec_join { + struct lu_fid jr_fid; + __u64 jr_headsize; +}; + +extern void lustre_swab_mdt_rec_join (struct mdt_rec_join *jr); + struct mds_rec_create { __u32 cr_opcode; __u32 cr_fsuid; @@ -861,12 +891,26 @@ struct mds_rec_create { extern void lustre_swab_mds_rec_create (struct mds_rec_create *cr); -struct mds_rec_join { - struct ll_fid jr_fid; - __u64 jr_headsize; +struct mdt_rec_create { + __u32 cr_opcode; + __u32 cr_fsuid; + __u32 cr_fsgid; + __u32 cr_cap; + __u32 cr_flags; /* for use with open */ + __u32 cr_mode; + struct lu_fid cr_fid; + struct lu_fid cr_replayfid; + __u64 cr_time; + __u64 cr_rdev; + __u32 cr_suppgid; + __u32 cr_padding_1; /* also fix lustre_swab_mds_rec_create */ + __u32 cr_padding_2; /* also fix lustre_swab_mds_rec_create */ + __u32 cr_padding_3; /* also fix lustre_swab_mds_rec_create */ + __u32 cr_padding_4; /* also fix lustre_swab_mds_rec_create */ + __u32 cr_padding_5; /* also fix lustre_swab_mds_rec_create */ }; -extern void lustre_swab_mds_rec_join (struct mds_rec_join *jr); +extern void lustre_swab_mdt_rec_create (struct mdt_rec_create *cr); struct mds_rec_link { __u32 lk_opcode; @@ -886,6 +930,24 @@ struct mds_rec_link { extern void lustre_swab_mds_rec_link (struct mds_rec_link *lk); +struct mdt_rec_link { + __u32 lk_opcode; + __u32 lk_fsuid; + __u32 lk_fsgid; + __u32 lk_cap; + __u32 lk_suppgid1; + __u32 lk_suppgid2; + struct lu_fid lk_fid1; + struct lu_fid lk_fid2; + __u64 lk_time; + __u32 lk_padding_1; /* also fix lustre_swab_mds_rec_link */ + __u32 lk_padding_2; /* also fix lustre_swab_mds_rec_link */ + __u32 lk_padding_3; /* also fix lustre_swab_mds_rec_link */ + __u32 lk_padding_4; /* also fix lustre_swab_mds_rec_link */ +}; + +extern void lustre_swab_mdt_rec_link (struct mdt_rec_link *lk); + struct mds_rec_unlink { __u32 ul_opcode; __u32 ul_fsuid; @@ -904,6 +966,24 @@ struct mds_rec_unlink { extern void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul); +struct mdt_rec_unlink { + __u32 ul_opcode; + __u32 ul_fsuid; + __u32 ul_fsgid; + __u32 ul_cap; + __u32 ul_suppgid; + __u32 ul_mode; + struct lu_fid ul_fid1; + struct lu_fid ul_fid2; + __u64 ul_time; + __u32 ul_padding_1; /* also fix lustre_swab_mds_rec_unlink */ + __u32 ul_padding_2; /* also fix lustre_swab_mds_rec_unlink */ + __u32 ul_padding_3; /* also fix lustre_swab_mds_rec_unlink */ + __u32 ul_padding_4; /* also fix lustre_swab_mds_rec_unlink */ +}; + +extern void lustre_swab_mdt_rec_unlink (struct mdt_rec_unlink *ul); + struct mds_rec_rename { __u32 rn_opcode; __u32 rn_fsuid; @@ -922,6 +1002,24 @@ struct mds_rec_rename { extern void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn); +struct mdt_rec_rename { + __u32 rn_opcode; + __u32 rn_fsuid; + __u32 rn_fsgid; + __u32 rn_cap; + __u32 rn_suppgid1; + __u32 rn_suppgid2; + struct lu_fid rn_fid1; + struct lu_fid rn_fid2; + __u64 rn_time; + __u32 rn_padding_1; /* also fix lustre_swab_mds_rec_rename */ + __u32 rn_padding_2; /* also fix lustre_swab_mds_rec_rename */ + __u32 rn_padding_3; /* also fix lustre_swab_mds_rec_rename */ + __u32 rn_padding_4; /* also fix lustre_swab_mds_rec_rename */ +}; + +extern void lustre_swab_mdt_rec_rename (struct mdt_rec_rename *rn); + /* * LOV data structures */ diff --git a/lustre/include/linux/lustre_mdc.h b/lustre/include/linux/lustre_mdc.h index 4aaa8c3..b817a23 100644 --- a/lustre/include/linux/lustre_mdc.h +++ b/lustre/include/linux/lustre_mdc.h @@ -31,7 +31,7 @@ struct ptlrpc_request; struct obd_device; struct lustre_md { - struct mds_body *body; + struct mdt_body *body; struct lov_stripe_md *lsm; #ifdef CONFIG_FS_POSIX_ACL struct posix_acl *posix_acl; @@ -39,13 +39,21 @@ struct lustre_md { }; struct mdc_op_data { - struct ll_fid fid1; - struct ll_fid fid2; + struct lu_fid fid1; + struct lu_fid fid2; __u64 mod_time; const char *name; int namelen; __u32 create_mode; __u32 suppgids[2]; + + obd_valid valid; + obd_size size; + obd_blocks blocks; + obd_flag flags; + obd_time mtime; + obd_time atime; + obd_time ctime; }; /* mdc/mdc_locks.c */ @@ -53,7 +61,7 @@ int it_disposition(struct lookup_intent *it, int flag); void it_set_disposition(struct lookup_intent *it, int flag); int it_open_error(int phase, struct lookup_intent *it); void mdc_set_lock_data(__u64 *lockh, void *data); -int mdc_change_cbdata(struct obd_export *exp, struct ll_fid *fid, +int mdc_change_cbdata(struct obd_export *exp, struct lu_fid *fid, ldlm_iterator_t it, void *data); int mdc_intent_lock(struct obd_export *exp, struct mdc_op_data *, @@ -80,22 +88,22 @@ int mdc_req2lustre_md(struct ptlrpc_request *req, int offset, struct obd_export *exp, struct lustre_md *md); void mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md); -int mdc_getstatus(struct obd_export *exp, struct ll_fid *rootfid); -int mdc_getattr(struct obd_export *exp, struct ll_fid *fid, +int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid); +int mdc_getattr(struct obd_export *exp, struct lu_fid *fid, obd_valid valid, unsigned int ea_size, struct ptlrpc_request **request); -int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid, +int mdc_getattr_name(struct obd_export *exp, struct lu_fid *fid, const char *filename, int namelen, unsigned long valid, unsigned int ea_size, struct ptlrpc_request **request); int mdc_setattr(struct obd_export *exp, struct mdc_op_data *data, struct iattr *iattr, void *ea, int ealen, void *ea2, int ea2len, struct ptlrpc_request **request); -int mdc_setxattr(struct obd_export *exp, struct ll_fid *fid, +int mdc_setxattr(struct obd_export *exp, struct lu_fid *fid, obd_valid valid, const char *xattr_name, const char *input, int input_size, int output_size, int flags, struct ptlrpc_request **request); -int mdc_getxattr(struct obd_export *exp, struct ll_fid *fid, +int mdc_getxattr(struct obd_export *exp, struct lu_fid *fid, obd_valid valid, const char *xattr_name, const char *input, int input_size, int output_size, struct ptlrpc_request **request); @@ -106,9 +114,9 @@ struct obd_client_handle; void mdc_set_open_replay_data(struct obd_client_handle *och, struct ptlrpc_request *open_req); void mdc_clear_open_replay_data(struct obd_client_handle *och); -int mdc_close(struct obd_export *, struct obdo *, struct obd_client_handle *, +int mdc_close(struct obd_export *, struct mdc_op_data *, struct obd_client_handle *, struct ptlrpc_request **); -int mdc_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, __u64 offset, +int mdc_readpage(struct obd_export *exp, struct lu_fid *mdc_fid, __u64 offset, struct page *, struct ptlrpc_request **); int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data, const void *data, int datalen, int mode, __u32 uid, __u32 gid, @@ -120,22 +128,11 @@ int mdc_link(struct obd_export *exp, struct mdc_op_data *data, int mdc_rename(struct obd_export *exp, struct mdc_op_data *data, const char *old, int oldlen, const char *new, int newlen, struct ptlrpc_request **request); -int mdc_sync(struct obd_export *exp, struct ll_fid *fid, +int mdc_sync(struct obd_export *exp, struct lu_fid *fid, struct ptlrpc_request **); int mdc_create_client(struct obd_uuid uuid, struct ptlrpc_client *cl); -/* Store the generation of a newly-created inode in |req| for replay. */ -void mdc_store_inode_generation(struct ptlrpc_request *req, int reqoff, - int repoff); int mdc_llog_process(struct obd_export *, char *logname, llog_cb_t, void *data); -int mdc_done_writing(struct obd_export *exp, struct obdo *); - -static inline void mdc_pack_fid(struct ll_fid *fid, obd_id ino, __u32 gen, - int type) -{ - fid->id = ino; - fid->generation = gen; - fid->f_type = type; -} +int mdc_done_writing(struct obd_export *exp, struct mdc_op_data *data); #endif diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index 2ebac21..13569a9 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -856,7 +856,7 @@ struct obd_ops { int (*o_llog_finish)(struct obd_device *obd, int count); /* metadata-only methods */ - int (*o_pin)(struct obd_export *, obd_id ino, __u32 gen, int type, + int (*o_pin)(struct obd_export *, struct lu_fid *fid, struct obd_client_handle *, int flag); int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int); diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index 2757b5f..ab0eaf2 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -1067,15 +1067,15 @@ static inline int obd_san_preprw(int cmd, struct obd_export *exp, return(rc); } -static inline int obd_pin(struct obd_export *exp, obd_id ino, __u32 gen, - int type, struct obd_client_handle *handle, int flag) +static inline int obd_pin(struct obd_export *exp, struct lu_fid *fid, + struct obd_client_handle *handle, int flag) { int rc; EXP_CHECK_OP(exp, pin); OBD_COUNTER_INCREMENT(exp->exp_obd, pin); - rc = OBP(exp->exp_obd, pin)(exp, ino, gen, type, handle, flag); + rc = OBP(exp->exp_obd, pin)(exp, fid, handle, flag); return(rc); } diff --git a/lustre/liblustre/dir.c b/lustre/liblustre/dir.c index 3a59da9..db258ba 100644 --- a/lustre/liblustre/dir.c +++ b/lustre/liblustre/dir.c @@ -67,12 +67,11 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page) struct llu_inode_info *lli = llu_i2info(inode); struct intnl_stat *st = llu_i2stat(inode); struct llu_sb_info *sbi = llu_i2sbi(inode); - struct ll_fid mdc_fid; __u64 offset; int rc = 0; struct ptlrpc_request *request; struct lustre_handle lockh; - struct mds_body *body; + struct mdt_body *body; struct lookup_intent it = { .it_op = IT_READDIR }; struct mdc_op_data data; struct obd_device *obddev = class_exp2obd(sbi->ll_mdc_exp); @@ -100,10 +99,8 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page) } ldlm_lock_dump_handle(D_OTHER, &lockh); - mdc_pack_fid(&mdc_fid, st->st_ino, lli->lli_st_generation, S_IFDIR); - offset = page->index << PAGE_SHIFT; - rc = mdc_readpage(sbi->ll_mdc_exp, &mdc_fid, + rc = mdc_readpage(sbi->ll_mdc_exp, &lli->lli_fid, offset, page, &request); if (!rc) { body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*body)); diff --git a/lustre/liblustre/file.c b/lustre/liblustre/file.c index 19ce42b..a23ac80 100644 --- a/lustre/liblustre/file.c +++ b/lustre/liblustre/file.c @@ -127,7 +127,7 @@ static int llu_local_open(struct llu_inode_info *lli, struct lookup_intent *it) { struct ptlrpc_request *req = it->d.lustre.it_data; struct ll_file_data *fd; - struct mds_body *body; + struct mdt_body *body; ENTRY; body = lustre_msg_buf (req->rq_repmsg, 1, sizeof (*body)); @@ -229,7 +229,7 @@ int llu_iop_open(struct pnode *pnode, int flags, mode_t mode) int llu_objects_destroy(struct ptlrpc_request *request, struct inode *dir) { - struct mds_body *body; + struct mdt_body *body; struct lov_mds_md *eadata; struct lov_stripe_md *lsm = NULL; struct obd_trans_info oti = { 0 }; @@ -300,12 +300,12 @@ int llu_objects_destroy(struct ptlrpc_request *request, struct inode *dir) int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode) { struct llu_inode_info *lli = llu_i2info(inode); - struct intnl_stat *st = llu_i2stat(inode); struct ll_file_data *fd = lli->lli_file_data; struct ptlrpc_request *req = NULL; struct obd_client_handle *och = &fd->fd_mds_och; - struct obdo obdo; - int rc, valid; + struct intnl_stat *st = llu_i2stat(inode); + struct mdc_op_data op_data; + int rc; ENTRY; /* clear group lock, if present */ @@ -316,20 +316,28 @@ int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode) &fd->fd_cwlockh); } - obdo.o_id = st->st_ino; - obdo.o_valid = OBD_MD_FLID; - valid = OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLSIZE |OBD_MD_FLBLOCKS | - OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME; - if (test_bit(LLI_F_HAVE_OST_SIZE_LOCK, &lli->lli_flags)) - valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS; + memset(&op_data, 0, sizeof(op_data)); + op_data.fid1 = lli->lli_fid; + op_data.valid = OBD_MD_FLTYPE | OBD_MD_FLMODE | + OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | + OBD_MD_FLATIME | OBD_MD_FLMTIME | + OBD_MD_FLCTIME; + + op_data.atime = LTIME_S(st->st_atime); + op_data.mtime = LTIME_S(st->st_mtime); + op_data.ctime = LTIME_S(st->st_ctime); + op_data.size = st->st_size; + op_data.blocks = st->st_blocks; + op_data.flags = lli->lli_st_flags; - obdo_from_inode(&obdo, inode, valid); + if (test_bit(LLI_F_HAVE_OST_SIZE_LOCK, &lli->lli_flags)) + op_data.valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS; if (0 /* ll_is_inode_dirty(inode) */) { - obdo.o_flags = MDS_BFLAG_UNCOMMITTED_WRITES; - obdo.o_valid |= OBD_MD_FLFLAGS; + op_data.flags = MDS_BFLAG_UNCOMMITTED_WRITES; + op_data.valid |= OBD_MD_FLFLAGS; } - rc = mdc_close(mdc_exp, &obdo, och, &req); + rc = mdc_close(mdc_exp, &op_data, och, &req); if (rc == EAGAIN) { /* We are the last writer, so the MDS has instructed us to get * the file size and any write cookies, then close again. */ diff --git a/lustre/liblustre/llite_lib.h b/lustre/liblustre/llite_lib.h index 77a38b7..714efb9 100644 --- a/lustre/liblustre/llite_lib.h +++ b/lustre/liblustre/llite_lib.h @@ -28,7 +28,7 @@ struct llu_sb_info struct obd_uuid ll_sb_uuid; struct obd_export *ll_mdc_exp; struct obd_export *ll_osc_exp; - struct ll_fid ll_root_fid; + struct lu_fid ll_root_fid; int ll_flags; struct lustre_client_ocd ll_lco; struct list_head ll_conn_chain; @@ -45,7 +45,7 @@ struct llu_sb_info struct llu_inode_info { struct llu_sb_info *lli_sbi; - struct ll_fid lli_fid; + struct lu_fid lli_fid; struct lov_stripe_md *lli_smd; char *lli_symlink_name; @@ -106,8 +106,10 @@ static inline struct obd_export *llu_i2mdcexp(struct inode *inode) static inline int llu_is_root_inode(struct inode *inode) { - return (llu_i2info(inode)->lli_fid.id == - llu_i2info(inode)->lli_sbi->ll_root_fid.id); + return (fid_seq(&llu_i2info(inode)->lli_fid) == + fid_seq(&llu_i2info(inode)->lli_sbi->ll_root_fid) && + fid_num(&llu_i2info(inode)->lli_fid) == + fid_num(&llu_i2info(inode)->lli_sbi->ll_root_fid)); } #define LL_SAVE_INTENT(inode, it) \ @@ -136,8 +138,10 @@ do { \ #define LL_LOOKUP_POSITIVE 1 #define LL_LOOKUP_NEGATIVE 2 -static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode) +static inline void ll_inode2fid(struct lu_fid *fid, struct inode *inode) { + LASSERT(fid != NULL); + LASSERT(fid != NULL); *fid = llu_i2info(inode)->lli_fid; } @@ -179,7 +183,7 @@ int ll_parse_mount_target(const char *target, char **mdsnid, extern struct mount_option_s mount_option; /* super.c */ -void llu_update_inode(struct inode *inode, struct mds_body *body, +void llu_update_inode(struct inode *inode, struct mdt_body *body, struct lov_stripe_md *lmm); void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid); void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid); diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index 3db4b5f..df19bef 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -125,7 +125,7 @@ static void llu_fsop_gone(struct filesys *fs) static struct inode_ops llu_inode_ops; -void llu_update_inode(struct inode *inode, struct mds_body *body, +void llu_update_inode(struct inode *inode, struct mdt_body *body, struct lov_stripe_md *lsm) { struct llu_inode_info *lli = llu_i2info(inode); @@ -183,6 +183,7 @@ void llu_update_inode(struct inode *inode, struct mds_body *body, if (body->valid & OBD_MD_FLGENER) lli->lli_st_generation = body->generation; +#if 0 /* fillin fid */ if (body->valid & OBD_MD_FLID) lli->lli_fid.id = body->ino; @@ -190,6 +191,7 @@ void llu_update_inode(struct inode *inode, struct mds_body *body, lli->lli_fid.generation = body->generation; if (body->valid & OBD_MD_FLTYPE) lli->lli_fid.f_type = body->mode & S_IFMT; +#endif } void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid) @@ -346,17 +348,22 @@ int llu_inode_getattr(struct inode *inode, struct lov_stripe_md *lsm) } static struct inode* llu_new_inode(struct filesys *fs, - struct ll_fid *fid) + struct lu_fid *fid) { struct inode *inode; struct llu_inode_info *lli; struct intnl_stat st = { .st_dev = 0, +#if 0 #ifndef AUTOMOUNT_FILE_NAME .st_mode = fid->f_type & S_IFMT, #else .st_mode = fid->f_type /* all of the bits! */ #endif +#endif + /* FIXME: fix this later */ + .st_mode = 0, + .st_uid = geteuid(), .st_gid = getegid(), }; @@ -436,7 +443,7 @@ static int llu_inode_revalidate(struct inode *inode) struct lustre_md md; struct ptlrpc_request *req = NULL; struct llu_sb_info *sbi = llu_i2sbi(inode); - struct ll_fid fid; + struct lu_fid fid; unsigned long valid = OBD_MD_FLGETATTR; int rc, ealen = 0; @@ -538,7 +545,7 @@ static int null_if_equal(struct ldlm_lock *lock, void *data) void llu_clear_inode(struct inode *inode) { - struct ll_fid fid; + struct lu_fid fid; struct llu_inode_info *lli = llu_i2info(inode); struct llu_sb_info *sbi = llu_i2sbi(inode); ENTRY; @@ -882,8 +889,8 @@ static int llu_readlink_internal(struct inode *inode, { struct llu_inode_info *lli = llu_i2info(inode); struct llu_sb_info *sbi = llu_i2sbi(inode); - struct ll_fid fid; - struct mds_body *body; + struct lu_fid fid; + struct mdt_body *body; struct intnl_stat *st = llu_i2stat(inode); int rc, symlen = st->st_size + 1; ENTRY; @@ -1631,7 +1638,7 @@ struct filesys_ops llu_filesys_ops = struct inode *llu_iget(struct filesys *fs, struct lustre_md *md) { struct inode *inode; - struct ll_fid fid; + struct lu_fid fid; struct file_identifier fileid = {&fid, sizeof(fid)}; if ((md->body->valid & @@ -1643,9 +1650,7 @@ struct inode *llu_iget(struct filesys *fs, struct lustre_md *md) } /* try to find existing inode */ - fid.id = md->body->ino; - fid.generation = md->body->generation; - fid.f_type = md->body->mode & S_IFMT; + fid = md->body->fid1; inode = _sysio_i_find(fs, &fileid); if (inode) { @@ -1679,7 +1684,7 @@ llu_fsswop_mount(const char *source, struct inode *root; struct pnode_base *rootpb; struct obd_device *obd; - struct ll_fid rootfid; + struct lu_fid rootfid; struct llu_sb_info *sbi; struct obd_statfs osfs; static struct qstr noname = { NULL, 0, 0 }; @@ -1816,7 +1821,7 @@ llu_fsswop_mount(const char *source, CERROR("cannot mds_connect: rc = %d\n", err); GOTO(out_osc, err); } - CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id); + CDEBUG(D_SUPER, "rootfid "DFID3"\n", PFID3(&rootfid)); sbi->ll_root_fid = rootfid; /* fetch attr of root inode */ @@ -1833,7 +1838,7 @@ llu_fsswop_mount(const char *source, GOTO(out_request, err); } - LASSERT(sbi->ll_root_fid.id != 0); + LASSERT(fid_num(&sbi->ll_root_fid) != 0); root = llu_iget(fs, &md); if (!root || IS_ERR(root)) { diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index 6ceebfb..fb94cb2 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -395,8 +395,8 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, unlock_kernel(); handle = (flag) ? &ldd->lld_mnt_och : &ldd->lld_cwd_och; - rc = obd_pin(sbi->ll_mdc_exp, inode->i_ino, inode->i_generation, - inode->i_mode & S_IFMT, handle, flag); + rc = obd_pin(sbi->ll_mdc_exp, &ll_i2info(inode)->lli_fid, + handle, flag); if (rc) { lock_kernel(); diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 3c6a445..83b541a 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -59,7 +59,7 @@ typedef struct ext2_dir_entry_2 ext2_dirent; static int ll_dir_readpage(struct file *file, struct page *page) { struct inode *inode = page->mapping->host; - struct ll_fid mdc_fid; + struct lu_fid fid; __u64 offset; struct ptlrpc_request *request; struct mds_body *body; @@ -70,9 +70,9 @@ static int ll_dir_readpage(struct file *file, struct page *page) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) off "LPU64"\n", inode->i_ino, inode->i_generation, inode, offset); - mdc_pack_fid(&mdc_fid, inode->i_ino, inode->i_generation, S_IFDIR); + ll_inode2fid(&fid, inode); - rc = mdc_readpage(ll_i2sbi(inode)->ll_mdc_exp, &mdc_fid, + rc = mdc_readpage(ll_i2sbi(inode)->ll_mdc_exp, &fid, offset, page, &request); if (!rc) { body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*body)); @@ -406,7 +406,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, */ case IOC_MDC_LOOKUP: { struct ptlrpc_request *request = NULL; - struct ll_fid fid; + struct lu_fid fid; char *buf = NULL; char *filename; int namelen, rc, len = 0; @@ -483,7 +483,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, struct ptlrpc_request *request = NULL; struct lov_user_md *lump = (struct lov_user_md *)arg; struct lov_mds_md *lmm; - struct ll_fid fid; + struct lu_fid fid; struct mds_body *body; int rc, lmmsize; @@ -536,7 +536,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, case IOC_MDC_GETFILEINFO: case IOC_MDC_GETSTRIPE: { struct ptlrpc_request *request = NULL; - struct ll_fid fid; + struct lu_fid fid; struct mds_body *body; struct lov_user_md *lump; struct lov_mds_md *lmm; diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 063eed3..f611d8b 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -53,7 +53,7 @@ int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode, struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct ptlrpc_request *req = NULL; struct obd_client_handle *och = &fd->fd_mds_och; - struct obdo obdo; + struct mdc_op_data op_data; int rc; ENTRY; @@ -65,17 +65,26 @@ int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode, &fd->fd_cwlockh); } - obdo.o_id = inode->i_ino; - obdo.o_valid = OBD_MD_FLID; - obdo_from_inode(&obdo, inode, OBD_MD_FLTYPE | OBD_MD_FLMODE | - OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | - OBD_MD_FLATIME | OBD_MD_FLMTIME | - OBD_MD_FLCTIME); + memset(&op_data, 0, sizeof(op_data)); + op_data.fid1 = ll_i2info(inode)->lli_fid; + op_data.valid = OBD_MD_FLTYPE | OBD_MD_FLMODE | + OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | + OBD_MD_FLATIME | OBD_MD_FLMTIME | + OBD_MD_FLCTIME; + + op_data.atime = LTIME_S(inode->i_atime); + op_data.mtime = LTIME_S(inode->i_mtime); + op_data.ctime = LTIME_S(inode->i_ctime); + op_data.size = inode->i_size; + op_data.blocks = inode->i_blocks; + op_data.flags = inode->i_flags; + if (0 /* ll_is_inode_dirty(inode) */) { - obdo.o_flags = MDS_BFLAG_UNCOMMITTED_WRITES; - obdo.o_valid |= OBD_MD_FLFLAGS; + op_data.flags = MDS_BFLAG_UNCOMMITTED_WRITES; + op_data.valid |= OBD_MD_FLFLAGS; } - rc = mdc_close(mdc_exp, &obdo, och, &req); + + rc = mdc_close(mdc_exp, &op_data, och, &req); if (rc == EAGAIN) { /* We are the last writer, so the MDS has instructed us to get * the file size and any write cookies, then close again. */ @@ -1555,7 +1564,7 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data) struct inode *inode = dentry->d_inode; struct ll_inode_info *lli = ll_i2info(inode); struct lov_stripe_md *lsm = lli->lli_smd; - struct ll_fid fid; + struct lu_fid fid; struct ptlrpc_request *req; int rc, err; ENTRY; @@ -1741,7 +1750,7 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it) if (!ll_have_md_lock(dentry)) { struct ptlrpc_request *req = NULL; struct ll_sb_info *sbi = ll_i2sbi(dentry->d_inode); - struct ll_fid fid; + struct lu_fid fid; obd_valid valid = OBD_MD_FLGETATTR; int ealen = 0; diff --git a/lustre/llite/llite_close.c b/lustre/llite/llite_close.c index 420e232..4a4c1e3 100644 --- a/lustre/llite/llite_close.c +++ b/lustre/llite/llite_close.c @@ -122,6 +122,7 @@ static void ll_close_done_writing(struct inode *inode) struct ll_inode_info *lli = ll_i2info(inode); ldlm_policy_data_t policy = { .l_extent = {0, OBD_OBJECT_EOF } }; struct lustre_handle lockh = { 0 }; + struct mdc_op_data op_data; struct obdo obdo; obd_flag valid; int rc, ast_flags = 0; @@ -162,12 +163,12 @@ static void ll_close_done_writing(struct inode *inode) CERROR("unlock failed (%d)? proceeding anyways...\n", rc); rpc: - obdo.o_id = inode->i_ino; - obdo.o_size = inode->i_size; - obdo.o_blocks = inode->i_blocks; - obdo.o_valid = OBD_MD_FLID | OBD_MD_FLSIZE | OBD_MD_FLBLOCKS; + op_data.fid1 = lli->lli_fid; + op_data.size = inode->i_size; + op_data.blocks = inode->i_blocks; + op_data.valid = OBD_MD_FLID | OBD_MD_FLSIZE | OBD_MD_FLBLOCKS; - rc = mdc_done_writing(ll_i2sbi(inode)->ll_mdc_exp, &obdo); + rc = mdc_done_writing(ll_i2sbi(inode)->ll_mdc_exp, &op_data); out: } #endif diff --git a/lustre/llite/llite_fid.c b/lustre/llite/llite_fid.c index e3a9648..8c40db3 100644 --- a/lustre/llite/llite_fid.c +++ b/lustre/llite/llite_fid.c @@ -38,7 +38,13 @@ /* allocates passed fid, that is assigns f_num and f_seq to the @fid */ int ll_fid_alloc(struct ll_sb_info *sbi, struct lu_fid *fid) { - ENTRY; - RETURN(0); + ENTRY; + RETURN(0); } +/* build inode number on passed @fid */ +unsigned long ll_fid2ino(struct ll_sb_info *sbi, struct lu_fid *fid) +{ + ENTRY; + RETURN(0); +} diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index a590e89..9188f98 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -158,7 +158,7 @@ struct ll_sb_info { struct obd_export *ll_mdc_exp; struct obd_export *ll_osc_exp; struct proc_dir_entry* ll_proc_root; - struct ll_fid ll_root_fid; /* root object fid */ + struct lu_fid ll_root_fid; /* root object fid */ int ll_flags; struct list_head ll_conn_chain; /* per-conn chain of SBs */ @@ -543,10 +543,11 @@ static inline struct obd_export *ll_i2mdcexp(struct inode *inode) return ll_s2mdcexp(inode->i_sb); } -static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode) +static inline void ll_inode2fid(struct lu_fid *fid, struct inode *inode) { - mdc_pack_fid(fid, inode->i_ino, inode->i_generation, - inode->i_mode & S_IFMT); + LASSERT(fid != NULL); + LASSERT(inode != NULL); + *fid = ll_i2info(inode)->lli_fid; } static inline int ll_mds_max_easize(struct super_block *sb) @@ -569,5 +570,6 @@ int ll_removexattr(struct dentry *dentry, const char *name); /* llite/llite_fid.c*/ int ll_fid_alloc(struct ll_sb_info *sbi, struct lu_fid *fid); +unsigned long ll_fid2ino(struct ll_sb_info *sbi, struct lu_fid *fid); #endif /* LLITE_INTERNAL_H */ diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index dfeb8fd..d559c11 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -109,7 +110,7 @@ int client_common_fill_super(struct super_block *sb, char *mdc, char *osc) struct inode *root = 0; struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_device *obd; - struct ll_fid rootfid; + struct lu_fid rootfid; struct obd_statfs osfs; struct ptlrpc_request *request = NULL; struct lustre_handle osc_conn = {0, }; @@ -266,7 +267,7 @@ int client_common_fill_super(struct super_block *sb, char *mdc, char *osc) CERROR("cannot mds_connect: rc = %d\n", err); GOTO(out_osc, err); } - CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id); + CDEBUG(D_SUPER, "rootfid "DFID3"\n", PFID3(&rootfid)); sbi->ll_root_fid = rootfid; sb->s_op = &lustre_super_operations; @@ -284,14 +285,14 @@ int client_common_fill_super(struct super_block *sb, char *mdc, char *osc) err = mdc_req2lustre_md(request, 0, sbi->ll_osc_exp, &md); if (err) { - CERROR("failed to understand root inode md: rc = %d\n",err); + CERROR("failed to understand root inode md: rc = %d\n", err); ptlrpc_req_finished (request); GOTO(out_osc, err); } - LASSERT(sbi->ll_root_fid.id != 0); - root = ll_iget(sb, sbi->ll_root_fid.id, &md); - + LASSERT(fid_oid(&sbi->ll_root_fid) != 0); + root = ll_iget(sb, ll_fid2ino(sbi, &sbi->ll_root_fid), &md); + ll_i2info(root)->lli_fid = sbi->ll_root_fid; ptlrpc_req_finished(request); if (root == NULL || is_bad_inode(root)) { @@ -773,7 +774,7 @@ static int null_if_equal(struct ldlm_lock *lock, void *data) void ll_clear_inode(struct inode *inode) { - struct ll_fid fid; + struct lu_fid fid; struct ll_inode_info *lli = ll_i2info(inode); struct ll_sb_info *sbi = ll_i2sbi(inode); ENTRY; @@ -1340,7 +1341,7 @@ int ll_iocontrol(struct inode *inode, struct file *file, switch(cmd) { case EXT3_IOC_GETFLAGS: { - struct ll_fid fid; + struct lu_fid fid; struct mds_body *body; ll_inode2fid(&fid, inode); @@ -1502,8 +1503,8 @@ int ll_prep_inode(struct obd_export *exp, struct inode **inode, struct ptlrpc_request *req, int offset, struct super_block *sb) { - struct lustre_md md; struct ll_sb_info *sbi = NULL; + struct lustre_md md; int rc = 0; ENTRY; @@ -1518,28 +1519,26 @@ int ll_prep_inode(struct obd_export *exp, struct inode **inode, if (*inode) { ll_update_inode(*inode, &md); } else { - LASSERT(sb); - *inode = ll_iget(sb, md.body->ino, &md); + struct lu_fid fid; + + LASSERT(sb != NULL); + + rc = ll_fid_alloc(sbi, &fid); + if (rc) { + CERROR("cannot allocate new fid, rc %d\n", + rc); + mdc_free_lustre_md(exp, &md); + GOTO(out, rc); + } + + *inode = ll_iget(sb, ll_fid2ino(sbi, &fid), &md); if (*inode == NULL || is_bad_inode(*inode)) { mdc_free_lustre_md(exp, &md); rc = -ENOMEM; CERROR("new_inode -fatal: rc %d\n", rc); GOTO(out, rc); } -#if 0 - { - struct ll_inode_info *lli; - - lli = ll_i2info(*inode); - rc = ll_fid_alloc(sbi, lli->lli_fid); - if (rc) { - CERROR("cannot allocate new fid, rc %d\n", - rc); - mdc_free_lustre_md(exp, &md); - GOTO(out, rc); - } - } -#endif + ll_i2info(*inode)->lli_fid = fid; } rc = obd_checkmd(exp, ll_i2mdcexp(*inode), diff --git a/lustre/llite/llite_nfs.c b/lustre/llite/llite_nfs.c index bfe864a..e9f4be2 100644 --- a/lustre/llite/llite_nfs.c +++ b/lustre/llite/llite_nfs.c @@ -37,32 +37,40 @@ __u32 get_uuid2int(const char *name, int len) return (key0 << 1); } +struct ll_ino { + unsigned long ino; + unsigned long gen; +}; + +#if 0 + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) static int ll_nfs_test_inode(struct inode *inode, unsigned long ino, void *opaque) #else static int ll_nfs_test_inode(struct inode *inode, void *opaque) #endif { - struct ll_fid *iid = opaque; + struct ll_ino *iid = opaque; - if (inode->i_ino == iid->id && inode->i_generation == iid->generation) + if (inode->i_ino == iid->ino && inode->i_generation == iid->gen) return 1; return 0; } +#endif -static struct inode * search_inode_for_lustre(struct super_block *sb, - unsigned long ino, - unsigned long generation, - int mode) +static struct inode *search_inode_for_lustre(struct super_block *sb, + unsigned long ino, + unsigned long gen, + int mode) { - struct ptlrpc_request *req = NULL; +#if 0 + struct ll_ino iid = { .ino = ino, .gen = gen }; struct ll_sb_info *sbi = ll_s2sbi(sb); - struct ll_fid fid; + struct ptlrpc_request *req = NULL; + struct inode *inode = NULL; unsigned long valid = 0; int eadatalen = 0, rc; - struct inode *inode = NULL; - struct ll_fid iid = { .id = ino, .generation = generation }; inode = ILOOKUP(sb, ino, ll_nfs_test_inode, &iid); @@ -74,13 +82,11 @@ static struct inode * search_inode_for_lustre(struct super_block *sb, return ERR_PTR(rc); valid |= OBD_MD_FLEASIZE; } - fid.id = (__u64)ino; - fid.generation = generation; - fid.f_type = mode; - rc = mdc_getattr(sbi->ll_mdc_exp, &fid, valid, eadatalen, &req); + rc = mdc_getattr(sbi->ll_mdc_exp, iid, + valid, eadatalen, &req); if (rc) { - CERROR("failure %d inode %lu\n", rc, ino); + CERROR("failure %d fid "DFID3"\n", rc, PFID3(iid)); return ERR_PTR(rc); } @@ -92,6 +98,9 @@ static struct inode * search_inode_for_lustre(struct super_block *sb, ptlrpc_req_finished(req); return inode; +#endif + /* FIXME: this should be worked out later */ + return NULL; } extern struct dentry_operations ll_d_ops; @@ -107,9 +116,9 @@ static struct dentry *ll_iget_for_nfs(struct super_block *sb, unsigned long ino, return ERR_PTR(-ESTALE); inode = search_inode_for_lustre(sb, ino, generation, mode); - if (IS_ERR(inode)) { + if (IS_ERR(inode)) return ERR_PTR(PTR_ERR(inode)); - } + if (is_bad_inode(inode) || (generation && inode->i_generation != generation)){ /* we didn't find the right inode.. */ diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 1d2b58a..d1bbc8b 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -549,7 +549,6 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry, int mode, if (rc) RETURN(rc); - mdc_store_inode_generation(request, MDS_REQ_INTENT_REC_OFF, 1); inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len, NULL, 0, mode, 0, it); if (IS_ERR(inode)) { diff --git a/lustre/llite/symlink.c b/lustre/llite/symlink.c index f069420..ad077c5 100644 --- a/lustre/llite/symlink.c +++ b/lustre/llite/symlink.c @@ -34,7 +34,7 @@ static int ll_readlink_internal(struct inode *inode, { struct ll_inode_info *lli = ll_i2info(inode); struct ll_sb_info *sbi = ll_i2sbi(inode); - struct ll_fid fid; + struct lu_fid fid; struct mds_body *body; int rc, symlen = inode->i_size + 1; ENTRY; diff --git a/lustre/llite/xattr.c b/lustre/llite/xattr.c index 8a97ab6..a4cb190 100644 --- a/lustre/llite/xattr.c +++ b/lustre/llite/xattr.c @@ -94,7 +94,7 @@ int ll_setxattr_common(struct inode *inode, const char *name, { struct ll_sb_info *sbi = ll_i2sbi(inode); struct ptlrpc_request *req; - struct ll_fid fid; + struct lu_fid fid; int xattr_type, rc; ENTRY; @@ -157,7 +157,7 @@ int ll_getxattr_common(struct inode *inode, const char *name, struct ll_sb_info *sbi = ll_i2sbi(inode); struct ptlrpc_request *req = NULL; struct mds_body *body; - struct ll_fid fid; + struct lu_fid fid; void *xdata; int xattr_type, rc; ENTRY; diff --git a/lustre/mdc/mdc_internal.h b/lustre/mdc/mdc_internal.h index 5f62042..63c8e38 100644 --- a/lustre/mdc/mdc_internal.h +++ b/lustre/mdc/mdc_internal.h @@ -1,9 +1,9 @@ #include void mdc_pack_req_body(struct ptlrpc_request *req, int offset, - __u64 valid, struct ll_fid *fid, int ea_size); + __u64 valid, struct lu_fid *fid, int ea_size); void mdc_pack_rep_body(struct ptlrpc_request *); void mdc_readdir_pack(struct ptlrpc_request *req, int pos, __u64 offset, - __u32 size, struct ll_fid *mdc_fid); + __u32 size, struct lu_fid *fid); void mdc_getattr_pack(struct ptlrpc_request *req, int valid, int offset, int flags, struct mdc_op_data *data); void mdc_setattr_pack(struct ptlrpc_request *req, int offset, @@ -26,7 +26,7 @@ void mdc_link_pack(struct ptlrpc_request *req, int offset, void mdc_rename_pack(struct ptlrpc_request *req, int offset, struct mdc_op_data *data, const char *old, int oldlen, const char *new, int newlen); -void mdc_close_pack(struct ptlrpc_request *req, int offset, struct obdo *oa, +void mdc_close_pack(struct ptlrpc_request *req, int offset, struct mdc_op_data *op_data, int valid, struct obd_client_handle *och); struct mdc_open_data { diff --git a/lustre/mdc/mdc_lib.c b/lustre/mdc/mdc_lib.c index 8b829da..c26263d 100644 --- a/lustre/mdc/mdc_lib.c +++ b/lustre/mdc/mdc_lib.c @@ -40,21 +40,21 @@ #endif void mdc_readdir_pack(struct ptlrpc_request *req, int pos, __u64 offset, - __u32 size, struct ll_fid *mdc_fid) + __u32 size, struct lu_fid *fid) { - struct mds_body *b; + struct mdt_body *b; b = lustre_msg_buf(req->rq_reqmsg, pos, sizeof (*b)); b->fsuid = current->fsuid; b->fsgid = current->fsgid; b->capability = current->cap_effective; - b->fid1 = *mdc_fid; + b->fid1 = *fid; b->size = offset; /* !! */ b->suppgid = -1; b->nlink = size; /* !! */ } -static void mdc_pack_body(struct mds_body *b) +static void mdc_pack_body(struct mdt_body *b) { LASSERT (b != NULL); @@ -64,9 +64,9 @@ static void mdc_pack_body(struct mds_body *b) } void mdc_pack_req_body(struct ptlrpc_request *req, int offset, - __u64 valid, struct ll_fid *fid, int ea_size) + __u64 valid, struct lu_fid *fid, int ea_size) { - struct mds_body *b = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*b)); + struct mdt_body *b = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*b)); if (fid) b->fid1 = *fid; @@ -81,7 +81,7 @@ void mdc_create_pack(struct ptlrpc_request *req, int offset, __u32 mode, __u32 uid, __u32 gid, __u32 cap_effective, __u64 rdev) { - struct mds_rec_create *rec; + struct mdt_rec_create *rec; char *tmp; rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec)); @@ -125,7 +125,7 @@ static __u32 mds_pack_open_flags(__u32 flags) void mdc_join_pack(struct ptlrpc_request *req, int offset, struct mdc_op_data *op_data, __u64 head_size) { - struct mds_rec_join *rec; + struct mdt_rec_join *rec; rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*rec)); LASSERT(rec != NULL); @@ -137,7 +137,7 @@ void mdc_open_pack(struct ptlrpc_request *req, int offset, struct mdc_op_data *op_data, __u32 mode, __u64 rdev, __u32 flags, const void *lmm, int lmmlen) { - struct mds_rec_create *rec; + struct mdt_rec_create *rec; char *tmp; rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec)); @@ -172,7 +172,7 @@ void mdc_setattr_pack(struct ptlrpc_request *req, int offset, struct mdc_op_data *data, struct iattr *iattr, void *ea, int ealen, void *ea2, int ea2len) { - struct mds_rec_setattr *rec = lustre_msg_buf(req->rq_reqmsg, offset, + struct mdt_rec_setattr *rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec)); rec->sa_opcode = REINT_SETATTR; rec->sa_fsuid = current->fsuid; @@ -211,7 +211,7 @@ void mdc_setattr_pack(struct ptlrpc_request *req, int offset, void mdc_unlink_pack(struct ptlrpc_request *req, int offset, struct mdc_op_data *data) { - struct mds_rec_unlink *rec; + struct mdt_rec_unlink *rec; char *tmp; rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec)); @@ -235,7 +235,7 @@ void mdc_unlink_pack(struct ptlrpc_request *req, int offset, void mdc_link_pack(struct ptlrpc_request *req, int offset, struct mdc_op_data *data) { - struct mds_rec_link *rec; + struct mdt_rec_link *rec; char *tmp; rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec)); @@ -258,7 +258,7 @@ void mdc_rename_pack(struct ptlrpc_request *req, int offset, struct mdc_op_data *data, const char *old, int oldlen, const char *new, int newlen) { - struct mds_rec_rename *rec; + struct mdt_rec_rename *rec; char *tmp; rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec)); @@ -286,7 +286,7 @@ void mdc_rename_pack(struct ptlrpc_request *req, int offset, void mdc_getattr_pack(struct ptlrpc_request *req, int offset, int valid, int flags, struct mdc_op_data *data) { - struct mds_body *b; + struct mdt_body *b; b = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*b)); b->fsuid = current->fsuid; @@ -305,37 +305,38 @@ void mdc_getattr_pack(struct ptlrpc_request *req, int offset, int valid, } } -void mdc_close_pack(struct ptlrpc_request *req, int offset, struct obdo *oa, - int valid, struct obd_client_handle *och) +void mdc_close_pack(struct ptlrpc_request *req, int offset, + struct mdc_op_data *op_data, int valid, + struct obd_client_handle *och) { - struct mds_body *body; + struct mdt_body *body; body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body)); - mdc_pack_fid(&body->fid1, oa->o_id, 0, oa->o_mode); + body->fid1 = op_data->fid1; memcpy(&body->handle, &och->och_fh, sizeof(body->handle)); - if (oa->o_valid & OBD_MD_FLATIME) { - body->atime = oa->o_atime; + if (op_data->valid & OBD_MD_FLATIME) { + body->atime = op_data->atime; body->valid |= OBD_MD_FLATIME; } - if (oa->o_valid & OBD_MD_FLMTIME) { - body->mtime = oa->o_mtime; + if (op_data->valid & OBD_MD_FLMTIME) { + body->mtime = op_data->mtime; body->valid |= OBD_MD_FLMTIME; } - if (oa->o_valid & OBD_MD_FLCTIME) { - body->ctime = oa->o_ctime; + if (op_data->valid & OBD_MD_FLCTIME) { + body->ctime = op_data->ctime; body->valid |= OBD_MD_FLCTIME; } - if (oa->o_valid & OBD_MD_FLSIZE) { - body->size = oa->o_size; + if (op_data->valid & OBD_MD_FLSIZE) { + body->size = op_data->size; body->valid |= OBD_MD_FLSIZE; } - if (oa->o_valid & OBD_MD_FLBLOCKS) { - body->blocks = oa->o_blocks; + if (op_data->valid & OBD_MD_FLBLOCKS) { + body->blocks = op_data->blocks; body->valid |= OBD_MD_FLBLOCKS; } - if (oa->o_valid & OBD_MD_FLFLAGS) { - body->flags = oa->o_flags; + if (op_data->valid & OBD_MD_FLFLAGS) { + body->flags = op_data->flags; body->valid |= OBD_MD_FLFLAGS; } } diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index f17bc9c..4004e35 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -144,17 +144,17 @@ void mdc_set_lock_data(__u64 *l, void *data) } EXPORT_SYMBOL(mdc_set_lock_data); -int mdc_change_cbdata(struct obd_export *exp, struct ll_fid *fid, +int mdc_change_cbdata(struct obd_export *exp, struct lu_fid *fid, ldlm_iterator_t it, void *data) { struct ldlm_res_id res_id = { .name = {0} }; ENTRY; - res_id.name[0] = fid->id; - res_id.name[1] = fid->generation; + res_id.name[0] = fid_seq(fid); + res_id.name[1] = fid_num(fid); - ldlm_change_cbdata(class_exp2obd(exp)->obd_namespace, &res_id, it, - data); + ldlm_change_cbdata(class_exp2obd(exp)->obd_namespace, + &res_id, it, data); EXIT; return 0; @@ -197,7 +197,7 @@ static int round_up(int val) * but this is incredibly unlikely, and questionable whether the client * could do MDS recovery under OOM anyways... */ static void mdc_realloc_openmsg(struct ptlrpc_request *req, - struct mds_body *body, int size[5]) + struct mdt_body *body, int size[5]) { int new_size, old_size; struct lustre_msg *new_msg; @@ -246,7 +246,7 @@ int mdc_enqueue(struct obd_export *exp, struct ptlrpc_request *req; struct obd_device *obddev = class_exp2obd(exp); struct ldlm_res_id res_id = - { .name = {data->fid1.id, data->fid1.generation} }; + { .name = {fid_seq(&data->fid1), fid_num(&data->fid1)} }; ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_LOOKUP } }; struct ldlm_request *lockreq; struct ldlm_intent *lit; @@ -254,7 +254,7 @@ int mdc_enqueue(struct obd_export *exp, [MDS_REQ_INTENT_IT_OFF] = sizeof(*lit) }; struct ldlm_reply *dlm_rep; int repsize[4] = {sizeof(*dlm_rep), - sizeof(struct mds_body), + sizeof(struct mdt_body), obddev->u.cli.cl_max_mds_easize}; void *eadata; unsigned long irqflags; @@ -269,7 +269,7 @@ int mdc_enqueue(struct obd_export *exp, if (it->it_op & IT_OPEN) { it->it_create_mode |= S_IFREG; - size[req_buffers++] = sizeof(struct mds_rec_create); + size[req_buffers++] = sizeof(struct mdt_rec_create); size[req_buffers++] = data->namelen + 1; /* As an optimization, we allocate an RPC request buffer for * at least a default-sized LOV EA even if we aren't sending @@ -291,7 +291,7 @@ int mdc_enqueue(struct obd_export *exp, /* join is like an unlink of the tail */ policy.l_inodebits.bits = MDS_INODELOCK_UPDATE; - size[req_buffers++] = sizeof(struct mds_rec_join); + size[req_buffers++] = sizeof(struct mdt_rec_join); req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_DLM_VERSION, LDLM_ENQUEUE, req_buffers, size, NULL); @@ -324,7 +324,7 @@ int mdc_enqueue(struct obd_export *exp, repsize[repbufcnt++] = LUSTRE_POSIX_ACL_MAX_SIZE; } else if (it->it_op & IT_UNLINK) { - size[req_buffers++] = sizeof(struct mds_rec_unlink); + size[req_buffers++] = sizeof(struct mdt_rec_unlink); size[req_buffers++] = data->namelen + 1; policy.l_inodebits.bits = MDS_INODELOCK_UPDATE; req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_DLM_VERSION, @@ -344,7 +344,7 @@ int mdc_enqueue(struct obd_export *exp, } else if (it->it_op & (IT_GETATTR | IT_LOOKUP)) { obd_valid valid = OBD_MD_FLGETATTR | OBD_MD_FLEASIZE | OBD_MD_FLACL | OBD_MD_FLMODEASIZE; - size[req_buffers++] = sizeof(struct mds_body); + size[req_buffers++] = sizeof(struct mdt_body); size[req_buffers++] = data->namelen + 1; if (it->it_op & IT_GETATTR) @@ -444,12 +444,12 @@ int mdc_enqueue(struct obd_export *exp, /* We know what to expect, so we do any byte flipping required here */ LASSERT(repbufcnt == 4 || repbufcnt == 1); if (repbufcnt == 4) { - struct mds_body *body; + struct mdt_body *body; body = lustre_swab_repbuf(req, 1, sizeof (*body), - lustre_swab_mds_body); + lustre_swab_mdt_body); if (body == NULL) { - CERROR ("Can't swab mds_body\n"); + CERROR ("Can't swab mdt_body\n"); RETURN (-EPROTO); } @@ -536,23 +536,23 @@ int mdc_intent_lock(struct obd_export *exp, struct mdc_op_data *op_data, struct lustre_handle lockh; struct ptlrpc_request *request; int rc = 0; - struct mds_body *mds_body; + struct mdt_body *mdt_body; struct lustre_handle old_lock; struct ldlm_lock *lock; ENTRY; LASSERT(it); - CDEBUG(D_DLMTRACE,"name: %.*s in inode "LPU64", intent: %s flags %#o\n", - op_data->namelen, op_data->name, op_data->fid1.id, + CDEBUG(D_DLMTRACE,"name: %.*s in obj "DFID3", intent: %s flags %#o\n", + op_data->namelen, op_data->name, PFID3(&op_data->fid1), ldlm_it2str(it->it_op), it->it_flags); - if (op_data->fid2.id && + if (fid_num(&op_data->fid2) && (it->it_op == IT_LOOKUP || it->it_op == IT_GETATTR)) { /* We could just return 1 immediately, but since we should only * be called in revalidate_it if we already have a lock, let's * verify that. */ - struct ldlm_res_id res_id = {.name ={op_data->fid2.id, - op_data->fid2.generation}}; + struct ldlm_res_id res_id = { .name = { fid_seq(&op_data->fid2), + fid_num(&op_data->fid2) } }; struct lustre_handle lockh; ldlm_policy_data_t policy; int mode = LCK_CR; @@ -599,7 +599,7 @@ int mdc_intent_lock(struct obd_export *exp, struct mdc_op_data *op_data, if (rc < 0) RETURN(rc); memcpy(&it->d.lustre.it_lock_handle, &lockh, sizeof(lockh)); - } else if (!op_data->fid2.id) { + } else if (!fid_num(&op_data->fid2)) { /* DISP_ENQ_COMPLETE set means there is extra reference on * request referenced from this intent, saved for subsequent * lookup. This path is executed when we proceed to this @@ -632,16 +632,16 @@ int mdc_intent_lock(struct obd_export *exp, struct mdc_op_data *op_data, if (rc) RETURN(rc); - mds_body = lustre_msg_buf(request->rq_repmsg, 1, sizeof(*mds_body)); - LASSERT(mds_body != NULL); /* mdc_enqueue checked */ + mdt_body = lustre_msg_buf(request->rq_repmsg, 1, sizeof(*mdt_body)); + LASSERT(mdt_body != NULL); /* mdc_enqueue checked */ LASSERT_REPSWABBED(request, 1); /* mdc_enqueue swabbed */ /* If we were revalidating a fid/name pair, mark the intent in * case we fail and get called again from lookup */ - if (op_data->fid2.id) { + if (fid_num(&op_data->fid2)) { it_set_disposition(it, DISP_ENQ_COMPLETE); /* Also: did we find the same inode? */ - if (memcmp(&op_data->fid2, &mds_body->fid1, sizeof(op_data->fid2))) + if (memcmp(&op_data->fid2, &mdt_body->fid1, sizeof(op_data->fid2))) RETURN(-ESTALE); } diff --git a/lustre/mdc/mdc_reint.c b/lustre/mdc/mdc_reint.c index 22af6dc..9b1f7fa 100644 --- a/lustre/mdc/mdc_reint.c +++ b/lustre/mdc/mdc_reint.c @@ -52,9 +52,9 @@ static int mdc_reint(struct ptlrpc_request *request, mdc_put_rpc_lock(rpc_lock, NULL); if (rc) CDEBUG(D_INFO, "error in handling %d\n", rc); - else if (!lustre_swab_repbuf(request, 0, sizeof(struct mds_body), - lustre_swab_mds_body)) { - CERROR ("Can't unpack mds_body\n"); + else if (!lustre_swab_repbuf(request, 0, sizeof(struct mdt_body), + lustre_swab_mdt_body)) { + CERROR ("Can't unpack mdt_body\n"); rc = -EPROTO; } return rc; @@ -71,7 +71,7 @@ int mdc_setattr(struct obd_export *exp, struct mdc_op_data *data, struct ptlrpc_request **request) { struct ptlrpc_request *req; - struct mds_rec_setattr *rec; + struct mdt_rec_setattr *rec; struct mdc_rpc_lock *rpc_lock; struct obd_device *obd = exp->exp_obd; int size[] = { sizeof(*rec), ealen, ea2len}; @@ -103,7 +103,7 @@ int mdc_setattr(struct obd_export *exp, struct mdc_op_data *data, LTIME_S(iattr->ia_mtime), LTIME_S(iattr->ia_ctime)); mdc_setattr_pack(req, MDS_REQ_REC_OFF, data, iattr, ea, ealen, ea2, ea2len); - size[0] = sizeof(struct mds_body); + size[0] = sizeof(struct mdt_body); req->rq_replen = lustre_msg_size(1, size); rc = mdc_reint(req, rpc_lock, LUSTRE_IMP_FULL); @@ -120,7 +120,7 @@ int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data, { struct obd_device *obd = exp->exp_obd; struct ptlrpc_request *req; - int size[] = { sizeof(struct mds_rec_create), op_data->namelen + 1, 0}; + int size[] = { sizeof(struct mdt_rec_create), op_data->namelen + 1, 0}; int rc, level, bufcount = 2; ENTRY; @@ -139,7 +139,7 @@ int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data, mdc_create_pack(req, MDS_REQ_REC_OFF, op_data, data, datalen, mode, uid, gid, cap_effective, rdev); - size[0] = sizeof(struct mds_body); + size[0] = sizeof(struct mdt_body); req->rq_replen = lustre_msg_size(1, size); level = LUSTRE_IMP_FULL; @@ -151,9 +151,6 @@ int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data, goto resend; } - if (!rc) - mdc_store_inode_generation(req, 0, 0); - *request = req; RETURN(rc); } @@ -163,7 +160,7 @@ int mdc_unlink(struct obd_export *exp, struct mdc_op_data *data, { struct obd_device *obd = class_exp2obd(exp); struct ptlrpc_request *req = *request; - int rc, size[] = { sizeof(struct mds_rec_unlink), data->namelen + 1}; + int rc, size[] = { sizeof(struct mdt_rec_unlink), data->namelen + 1}; ENTRY; LASSERT(req == NULL); @@ -173,7 +170,7 @@ int mdc_unlink(struct obd_export *exp, struct mdc_op_data *data, RETURN(-ENOMEM); *request = req; - size[0] = sizeof(struct mds_body); + size[0] = sizeof(struct mdt_body); size[1] = obd->u.cli.cl_max_mds_easize; size[2] = obd->u.cli.cl_max_mds_cookiesize; req->rq_replen = lustre_msg_size(3, size); @@ -191,7 +188,7 @@ int mdc_link(struct obd_export *exp, struct mdc_op_data *data, { struct obd_device *obd = exp->exp_obd; struct ptlrpc_request *req; - int rc, size[] = { sizeof(struct mds_rec_link), data->namelen + 1}; + int rc, size[] = { sizeof(struct mdt_rec_link), data->namelen + 1}; ENTRY; req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION, @@ -201,7 +198,7 @@ int mdc_link(struct obd_export *exp, struct mdc_op_data *data, mdc_link_pack(req, MDS_REQ_REC_OFF, data); - size[0] = sizeof(struct mds_body); + size[0] = sizeof(struct mdt_body); req->rq_replen = lustre_msg_size(1, size); rc = mdc_reint(req, obd->u.cli.cl_rpc_lock, LUSTRE_IMP_FULL); @@ -218,7 +215,7 @@ int mdc_rename(struct obd_export *exp, struct mdc_op_data *data, { struct obd_device *obd = exp->exp_obd; struct ptlrpc_request *req; - int rc, size[] = { sizeof(struct mds_rec_rename), oldlen +1, newlen +1}; + int rc, size[] = { sizeof(struct mdt_rec_rename), oldlen +1, newlen +1}; ENTRY; req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION, @@ -228,7 +225,7 @@ int mdc_rename(struct obd_export *exp, struct mdc_op_data *data, mdc_rename_pack(req, MDS_REQ_REC_OFF, data, old, oldlen, new, newlen); - size[0] = sizeof(struct mds_body); + size[0] = sizeof(struct mdt_body); size[1] = obd->u.cli.cl_max_mds_easize; size[2] = obd->u.cli.cl_max_mds_cookiesize; req->rq_replen = lustre_msg_size(3, size); diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 7886564..bb75303 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -50,11 +50,11 @@ static int mdc_cleanup(struct obd_device *obd); extern int mds_queue_req(struct ptlrpc_request *); /* Helper that implements most of mdc_getstatus and signal_completed_replay. */ /* XXX this should become mdc_get_info("key"), sending MDS_GET_INFO RPC */ -static int send_getstatus(struct obd_import *imp, struct ll_fid *rootfid, +static int send_getstatus(struct obd_import *imp, struct lu_fid *rootfid, int level, int msg_flags) { struct ptlrpc_request *req; - int rc, size[] = { [MDS_REQ_REC_OFF] = sizeof(struct mds_body) }; + int rc, size[] = { [MDS_REQ_REC_OFF] = sizeof(struct mdt_body) }; ENTRY; req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_GETSTATUS, @@ -70,20 +70,20 @@ static int send_getstatus(struct obd_import *imp, struct ll_fid *rootfid, rc = ptlrpc_queue_wait(req); if (!rc) { - struct mds_body *body; + struct mdt_body *body; body = lustre_swab_repbuf(req, 0, sizeof(*body), - lustre_swab_mds_body); + lustre_swab_mdt_body); if (body == NULL) { - CERROR ("Can't extract mds_body\n"); + CERROR ("Can't extract mdt_body\n"); GOTO (out, rc = -EPROTO); } memcpy(rootfid, &body->fid1, sizeof(*rootfid)); - CDEBUG(D_NET, "root ino="LPU64", last_committed="LPU64 + CDEBUG(D_NET, "root fid="DFID3", last_committed="LPU64 ", last_xid="LPU64"\n", - rootfid->id, req->rq_repmsg->last_committed, + PFID3(rootfid), req->rq_repmsg->last_committed, req->rq_repmsg->last_xid); } @@ -94,7 +94,7 @@ static int send_getstatus(struct obd_import *imp, struct ll_fid *rootfid, } /* This should be mdc_get_info("rootfid") */ -int mdc_getstatus(struct obd_export *exp, struct ll_fid *rootfid) +int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid) { return send_getstatus(class_exp2cliimp(exp), rootfid, LUSTRE_IMP_FULL, 0); @@ -104,7 +104,7 @@ static int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size, unsigned int acl_size, struct ptlrpc_request *req) { - struct mds_body *body; + struct mdt_body *body; void *eadata; int rc; int size[3] = {sizeof(*body)}; @@ -132,9 +132,9 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size, RETURN (rc); body = lustre_swab_repbuf (req, 0, sizeof (*body), - lustre_swab_mds_body); + lustre_swab_mdt_body); if (body == NULL) { - CERROR ("Can't unpack mds_body\n"); + CERROR ("Can't unpack mdt_body\n"); RETURN (-EPROTO); } @@ -163,12 +163,12 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size, RETURN (0); } -int mdc_getattr(struct obd_export *exp, struct ll_fid *fid, +int mdc_getattr(struct obd_export *exp, struct lu_fid *fid, obd_valid valid, unsigned int ea_size, struct ptlrpc_request **request) { struct ptlrpc_request *req; - struct mds_body *body; + struct mdt_body *body; int size = sizeof(*body); int acl_size = 0, rc; ENTRY; @@ -197,12 +197,12 @@ int mdc_getattr(struct obd_export *exp, struct ll_fid *fid, RETURN (rc); } -int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid, +int mdc_getattr_name(struct obd_export *exp, struct lu_fid *fid, const char *filename, int namelen, unsigned long valid, unsigned int ea_len, struct ptlrpc_request **request) { struct ptlrpc_request *req; - int rc, size[] = { sizeof(struct mds_body), namelen }; + int rc, size[] = { sizeof(struct mdt_body), namelen }; ENTRY; req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION, @@ -226,13 +226,13 @@ int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid, } static -int mdc_xattr_common(struct obd_export *exp, struct ll_fid *fid, +int mdc_xattr_common(struct obd_export *exp, struct lu_fid *fid, int opcode, obd_valid valid, const char *xattr_name, const char *input, int input_size, int output_size, int flags, struct ptlrpc_request **request) { struct ptlrpc_request *req; - struct mds_body *body; + struct mdt_body *body; int size[3] = {sizeof(*body)}, bufcnt = 1; int xattr_namelen = 0, rc; void *tmp; @@ -292,9 +292,9 @@ int mdc_xattr_common(struct obd_export *exp, struct ll_fid *fid, if (opcode == MDS_GETXATTR) { body = lustre_swab_repbuf(req, 0, sizeof(*body), - lustre_swab_mds_body); + lustre_swab_mdt_body); if (body == NULL) { - CERROR ("Can't unpack mds_body\n"); + CERROR ("Can't unpack mdt_body\n"); GOTO(err_out, rc = -EPROTO); } } @@ -307,7 +307,7 @@ err_out: goto out; } -int mdc_setxattr(struct obd_export *exp, struct ll_fid *fid, +int mdc_setxattr(struct obd_export *exp, struct lu_fid *fid, obd_valid valid, const char *xattr_name, const char *input, int input_size, int output_size, int flags, @@ -317,7 +317,7 @@ int mdc_setxattr(struct obd_export *exp, struct ll_fid *fid, input, input_size, output_size, flags, request); } -int mdc_getxattr(struct obd_export *exp, struct ll_fid *fid, +int mdc_getxattr(struct obd_export *exp, struct lu_fid *fid, obd_valid valid, const char *xattr_name, const char *input, int input_size, int output_size, struct ptlrpc_request **request) @@ -326,35 +326,12 @@ int mdc_getxattr(struct obd_export *exp, struct ll_fid *fid, input, input_size, output_size, 0, request); } -/* This should be called with both the request and the reply still packed. */ -void mdc_store_inode_generation(struct ptlrpc_request *req, int reqoff, - int repoff) -{ - struct mds_rec_create *rec = lustre_msg_buf(req->rq_reqmsg, reqoff, - sizeof(*rec)); - struct mds_body *body = lustre_msg_buf(req->rq_repmsg, repoff, - sizeof(*body)); - - LASSERT (rec != NULL); - LASSERT (body != NULL); - - memcpy(&rec->cr_replayfid, &body->fid1, sizeof rec->cr_replayfid); - if (body->fid1.id == 0) { - DEBUG_REQ(D_ERROR, req, "saving replay request with id = 0 " - "gen = %u", body->fid1.generation); - LBUG(); - } - - DEBUG_REQ(D_HA, req, "storing generation %u for ino "LPU64, - rec->cr_replayfid.generation, rec->cr_replayfid.id); -} - #ifdef CONFIG_FS_POSIX_ACL static int mdc_unpack_acl(struct obd_export *exp, struct ptlrpc_request *req, struct lustre_md *md, unsigned int offset) { - struct mds_body *body = md->body; + struct mdt_body *body = md->body; struct posix_acl *acl; void *buf; int rc; @@ -486,10 +463,10 @@ static void mdc_replay_open(struct ptlrpc_request *req) struct obd_client_handle *och; struct ptlrpc_request *close_req; struct lustre_handle old; - struct mds_body *body; + struct mdt_body *body; ENTRY; - body = lustre_swab_repbuf(req, 1, sizeof(*body), lustre_swab_mds_body); + body = lustre_swab_repbuf(req, 1, sizeof(*body), lustre_swab_mdt_body); LASSERT (body != NULL); if (mod == NULL) { @@ -512,7 +489,7 @@ static void mdc_replay_open(struct ptlrpc_request *req) close_req = mod->mod_close_req; if (close_req != NULL) { - struct mds_body *close_body; + struct mdt_body *close_body; LASSERT(close_req->rq_reqmsg->opc == MDS_CLOSE); close_body = lustre_msg_buf(close_req->rq_reqmsg, MDS_REQ_REC_OFF, @@ -531,10 +508,10 @@ void mdc_set_open_replay_data(struct obd_client_handle *och, struct ptlrpc_request *open_req) { struct mdc_open_data *mod; - struct mds_rec_create *rec = lustre_msg_buf(open_req->rq_reqmsg, + struct mdt_rec_create *rec = lustre_msg_buf(open_req->rq_reqmsg, MDS_REQ_INTENT_REC_OFF, sizeof(*rec)); - struct mds_body *body = lustre_msg_buf(open_req->rq_repmsg, 1, + struct mdt_body *body = lustre_msg_buf(open_req->rq_repmsg, 1, sizeof(*body)); LASSERT(body != NULL); @@ -557,11 +534,6 @@ void mdc_set_open_replay_data(struct obd_client_handle *och, open_req->rq_replay_cb = mdc_replay_open; open_req->rq_commit_cb = mdc_commit_open; open_req->rq_cb_data = mod; - if (body->fid1.id == 0) { - DEBUG_REQ(D_ERROR, open_req, "saving replay request with " - "id = 0 gen = %u", body->fid1.generation); - LBUG(); - } DEBUG_REQ(D_HA, open_req, "set up replay data"); } @@ -610,12 +582,12 @@ static void mdc_commit_close(struct ptlrpc_request *req) spin_unlock(&open_req->rq_lock); } -int mdc_close(struct obd_export *exp, struct obdo *oa, +int mdc_close(struct obd_export *exp, struct mdc_op_data *op_data, struct obd_client_handle *och, struct ptlrpc_request **request) { struct obd_device *obd = class_exp2obd(exp); - int size[] = { sizeof(struct mds_body) }; - int rc, repsize[] = { sizeof(struct mds_body), + int size[] = { sizeof(struct mdt_body) }; + int rc, repsize[] = { sizeof(struct mdt_body), obd->u.cli.cl_max_mds_easize, obd->u.cli.cl_max_mds_cookiesize}; struct ptlrpc_request *req; @@ -646,7 +618,7 @@ int mdc_close(struct obd_export *exp, struct obdo *oa, CDEBUG(D_HA, "couldn't find open req; expecting close error\n"); } - mdc_close_pack(req, MDS_REQ_REC_OFF, oa, oa->o_valid, och); + mdc_close_pack(req, MDS_REQ_REC_OFF, op_data, op_data->valid, och); req->rq_replen = lustre_msg_size(3, repsize); req->rq_commit_cb = mdc_commit_close; @@ -673,9 +645,9 @@ int mdc_close(struct obd_export *exp, struct obdo *oa, CERROR("Unexpected: can't find mdc_open_data, but the " "close succeeded. Please tell CFS.\n"); } - if (!lustre_swab_repbuf(req, 0, sizeof(struct mds_body), - lustre_swab_mds_body)) { - CERROR("Error unpacking mds_body\n"); + if (!lustre_swab_repbuf(req, 0, sizeof(struct mdt_body), + lustre_swab_mdt_body)) { + CERROR("Error unpacking mdt_body\n"); rc = -EPROTO; } } @@ -686,10 +658,10 @@ int mdc_close(struct obd_export *exp, struct obdo *oa, return rc; } -int mdc_done_writing(struct obd_export *exp, struct obdo *obdo) +int mdc_done_writing(struct obd_export *exp, struct mdc_op_data *op_data) { struct ptlrpc_request *req; - struct mds_body *body; + struct mdt_body *body; int rc, size[] = { [MDS_REQ_REC_OFF] = sizeof(*body) }; ENTRY; @@ -699,12 +671,11 @@ int mdc_done_writing(struct obd_export *exp, struct obdo *obdo) RETURN(-ENOMEM); body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof(*body)); - mdc_pack_fid(&body->fid1, obdo->o_id, 0, obdo->o_mode); - body->size = obdo->o_size; - body->blocks = obdo->o_blocks; - body->flags = obdo->o_flags; - body->valid = obdo->o_valid; -// memcpy(&body->handle, &och->och_fh, sizeof(body->handle)); + body->fid1 = op_data->fid1; + body->size = op_data->size; + body->blocks = op_data->blocks; + body->flags = op_data->flags; + body->valid = op_data->valid; req->rq_replen = lustre_msg_size(1, size); @@ -713,17 +684,17 @@ int mdc_done_writing(struct obd_export *exp, struct obdo *obdo) RETURN(rc); } -int mdc_readpage(struct obd_export *exp, struct ll_fid *fid, __u64 offset, +int mdc_readpage(struct obd_export *exp, struct lu_fid *fid, __u64 offset, struct page *page, struct ptlrpc_request **request) { struct obd_import *imp = class_exp2cliimp(exp); struct ptlrpc_request *req = NULL; struct ptlrpc_bulk_desc *desc = NULL; - struct mds_body *body; + struct mdt_body *body; int rc, size[] = { sizeof(*body) }; ENTRY; - CDEBUG(D_INODE, "inode: "LPU64"\n", fid->id); + CDEBUG(D_INODE, "object: "DFID3"\n", PFID3(fid)); req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_READPAGE, 1, size, NULL); @@ -747,9 +718,9 @@ int mdc_readpage(struct obd_export *exp, struct ll_fid *fid, __u64 offset, if (rc == 0) { body = lustre_swab_repbuf(req, 0, sizeof (*body), - lustre_swab_mds_body); + lustre_swab_mdt_body); if (body == NULL) { - CERROR("Can't unpack mds_body\n"); + CERROR("Can't unpack mdt_body\n"); GOTO(out, rc = -EPROTO); } @@ -946,12 +917,12 @@ out: return rc; } -static int mdc_pin(struct obd_export *exp, obd_id ino, __u32 gen, int type, +static int mdc_pin(struct obd_export *exp, struct lu_fid *fid, struct obd_client_handle *handle, int flag) { struct ptlrpc_request *req; - struct mds_body *body; - int rc, size[] = { [MDS_REQ_REC_OFF] = sizeof(struct mds_body) }; + struct mdt_body *body; + int rc, size[] = { [MDS_REQ_REC_OFF] = sizeof(struct mdt_body) }; ENTRY; req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION, @@ -960,7 +931,7 @@ static int mdc_pin(struct obd_export *exp, obd_id ino, __u32 gen, int type, RETURN(-ENOMEM); body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body)); - mdc_pack_fid(&body->fid1, ino, gen, type); + body->fid1 = *fid; body->flags = flag; req->rq_replen = lustre_msg_size(1, size); @@ -974,7 +945,7 @@ static int mdc_pin(struct obd_export *exp, obd_id ino, __u32 gen, int type, RETURN(rc); } - body = lustre_swab_repbuf(req, 0, sizeof(*body), lustre_swab_mds_body); + body = lustre_swab_repbuf(req, 0, sizeof(*body), lustre_swab_mdt_body); if (body == NULL) { ptlrpc_req_finished(req); RETURN(rc); @@ -997,8 +968,8 @@ static int mdc_unpin(struct obd_export *exp, struct obd_client_handle *handle, int flag) { struct ptlrpc_request *req; - struct mds_body *body; - int rc, size[] = { [MDS_REQ_REC_OFF] = sizeof(struct mds_body) }; + struct mdt_body *body; + int rc, size[] = { [MDS_REQ_REC_OFF] = sizeof(struct mdt_body) }; ENTRY; if (handle->och_magic != OBD_CLIENT_HANDLE_MAGIC) @@ -1027,11 +998,11 @@ static int mdc_unpin(struct obd_export *exp, RETURN(rc); } -int mdc_sync(struct obd_export *exp, struct ll_fid *fid, +int mdc_sync(struct obd_export *exp, struct lu_fid *fid, struct ptlrpc_request **request) { struct ptlrpc_request *req; - int rc, size[] = { [MDS_REQ_REC_OFF] = sizeof(struct mds_body) }; + int rc, size[] = { [MDS_REQ_REC_OFF] = sizeof(struct mdt_body) }; ENTRY; req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION, @@ -1309,7 +1280,6 @@ EXPORT_SYMBOL(mdc_done_writing); EXPORT_SYMBOL(mdc_sync); EXPORT_SYMBOL(mdc_set_open_replay_data); EXPORT_SYMBOL(mdc_clear_open_replay_data); -EXPORT_SYMBOL(mdc_store_inode_generation); EXPORT_SYMBOL(mdc_init_ea_size); EXPORT_SYMBOL(mdc_getxattr); EXPORT_SYMBOL(mdc_setxattr); diff --git a/lustre/mds/mds_join.c b/lustre/mds/mds_join.c index 1a56542..180094f 100644 --- a/lustre/mds/mds_join.c +++ b/lustre/mds/mds_join.c @@ -240,6 +240,13 @@ static void mds_finish_join(struct mds_obd *mds, struct ptlrpc_request *req, mds_pack_inode2body(body, inode); } +static inline void mds_pack_fid(struct ll_fid *fid, obd_id ino, __u32 gen, int type) +{ + fid->id = ino; + fid->generation = gen; + fid->f_type = type; +} + static int mds_join_unlink_tail_inode(struct mds_update_record *rec, struct ptlrpc_request *req, struct mds_rec_join *join_rec, @@ -260,8 +267,8 @@ static int mds_join_unlink_tail_inode(struct mds_update_record *rec, ldlm_lock_decref(lockh, LCK_EX); head_inode = dchild->d_inode; - mdc_pack_fid(&head_fid, head_inode->i_ino, head_inode->i_generation, - head_inode->i_mode & S_IFMT); + mds_pack_fid(&head_fid, head_inode->i_ino, head_inode->i_generation, + head_inode->i_mode & S_IFMT); rc = mds_get_parents_children_locked(obd, mds, &join_rec->jr_fid, &de_tailparent, &head_fid, diff --git a/lustre/obdclass/llog_swab.c b/lustre/obdclass/llog_swab.c index 097a95a..87f2883 100644 --- a/lustre/obdclass/llog_swab.c +++ b/lustre/obdclass/llog_swab.c @@ -88,7 +88,8 @@ EXPORT_SYMBOL(lustre_swab_ll_fid); void lustre_swab_lu_fid(struct lu_fid *fid) { __swab64s (&fid->f_seq); - __swab64s (&fid->f_num); + __swab32s (&fid->f_oid); + __swab32s (&fid->f_ver); } EXPORT_SYMBOL(lustre_swab_lu_fid); diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index cb74b16..74b8bdf 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -731,12 +731,38 @@ void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa) CLASSERT(offsetof(typeof(*sa), sa_padding) != 0); } +void lustre_swab_mdt_rec_setattr (struct mdt_rec_setattr *sa) +{ + __swab32s (&sa->sa_opcode); + __swab32s (&sa->sa_fsuid); + __swab32s (&sa->sa_fsgid); + __swab32s (&sa->sa_cap); + __swab32s (&sa->sa_suppgid); + __swab32s (&sa->sa_mode); + lustre_swab_lu_fid (&sa->sa_fid); + __swab64s (&sa->sa_valid); + __swab64s (&sa->sa_size); + __swab64s (&sa->sa_mtime); + __swab64s (&sa->sa_atime); + __swab64s (&sa->sa_ctime); + __swab32s (&sa->sa_uid); + __swab32s (&sa->sa_gid); + __swab32s (&sa->sa_attr_flags); + CLASSERT(offsetof(typeof(*sa), sa_padding) != 0); +} + void lustre_swab_mds_rec_join (struct mds_rec_join *jr) { __swab64s(&jr->jr_headsize); lustre_swab_ll_fid(&jr->jr_fid); } +void lustre_swab_mdt_rec_join (struct mdt_rec_join *jr) +{ + __swab64s(&jr->jr_headsize); + lustre_swab_lu_fid(&jr->jr_fid); +} + void lustre_swab_mds_rec_create (struct mds_rec_create *cr) { __swab32s (&cr->cr_opcode); @@ -757,6 +783,26 @@ void lustre_swab_mds_rec_create (struct mds_rec_create *cr) CLASSERT(offsetof(typeof(*cr), cr_padding_5) != 0); } +void lustre_swab_mdt_rec_create (struct mdt_rec_create *cr) +{ + __swab32s (&cr->cr_opcode); + __swab32s (&cr->cr_fsuid); + __swab32s (&cr->cr_fsgid); + __swab32s (&cr->cr_cap); + __swab32s (&cr->cr_flags); /* for use with open */ + __swab32s (&cr->cr_mode); + lustre_swab_lu_fid (&cr->cr_fid); + lustre_swab_lu_fid (&cr->cr_replayfid); + __swab64s (&cr->cr_time); + __swab64s (&cr->cr_rdev); + __swab32s (&cr->cr_suppgid); + CLASSERT(offsetof(typeof(*cr), cr_padding_1) != 0); + CLASSERT(offsetof(typeof(*cr), cr_padding_2) != 0); + CLASSERT(offsetof(typeof(*cr), cr_padding_3) != 0); + CLASSERT(offsetof(typeof(*cr), cr_padding_4) != 0); + CLASSERT(offsetof(typeof(*cr), cr_padding_5) != 0); +} + void lustre_swab_mds_rec_link (struct mds_rec_link *lk) { __swab32s (&lk->lk_opcode); @@ -774,6 +820,23 @@ void lustre_swab_mds_rec_link (struct mds_rec_link *lk) CLASSERT(offsetof(typeof(*lk), lk_padding_4) != 0); } +void lustre_swab_mdt_rec_link (struct mdt_rec_link *lk) +{ + __swab32s (&lk->lk_opcode); + __swab32s (&lk->lk_fsuid); + __swab32s (&lk->lk_fsgid); + __swab32s (&lk->lk_cap); + __swab32s (&lk->lk_suppgid1); + __swab32s (&lk->lk_suppgid2); + lustre_swab_lu_fid (&lk->lk_fid1); + lustre_swab_lu_fid (&lk->lk_fid2); + __swab64s (&lk->lk_time); + CLASSERT(offsetof(typeof(*lk), lk_padding_1) != 0); + CLASSERT(offsetof(typeof(*lk), lk_padding_2) != 0); + CLASSERT(offsetof(typeof(*lk), lk_padding_3) != 0); + CLASSERT(offsetof(typeof(*lk), lk_padding_4) != 0); +} + void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul) { __swab32s (&ul->ul_opcode); @@ -791,6 +854,23 @@ void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul) CLASSERT(offsetof(typeof(*ul), ul_padding_4) != 0); } +void lustre_swab_mdt_rec_unlink (struct mdt_rec_unlink *ul) +{ + __swab32s (&ul->ul_opcode); + __swab32s (&ul->ul_fsuid); + __swab32s (&ul->ul_fsgid); + __swab32s (&ul->ul_cap); + __swab32s (&ul->ul_suppgid); + __swab32s (&ul->ul_mode); + lustre_swab_lu_fid (&ul->ul_fid1); + lustre_swab_lu_fid (&ul->ul_fid2); + __swab64s (&ul->ul_time); + CLASSERT(offsetof(typeof(*ul), ul_padding_1) != 0); + CLASSERT(offsetof(typeof(*ul), ul_padding_2) != 0); + CLASSERT(offsetof(typeof(*ul), ul_padding_3) != 0); + CLASSERT(offsetof(typeof(*ul), ul_padding_4) != 0); +} + void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn) { __swab32s (&rn->rn_opcode); @@ -808,6 +888,23 @@ void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn) CLASSERT(offsetof(typeof(*rn), rn_padding_4) != 0); } +void lustre_swab_mdt_rec_rename (struct mdt_rec_rename *rn) +{ + __swab32s (&rn->rn_opcode); + __swab32s (&rn->rn_fsuid); + __swab32s (&rn->rn_fsgid); + __swab32s (&rn->rn_cap); + __swab32s (&rn->rn_suppgid1); + __swab32s (&rn->rn_suppgid2); + lustre_swab_lu_fid (&rn->rn_fid1); + lustre_swab_lu_fid (&rn->rn_fid2); + __swab64s (&rn->rn_time); + CLASSERT(offsetof(typeof(*rn), rn_padding_1) != 0); + CLASSERT(offsetof(typeof(*rn), rn_padding_2) != 0); + CLASSERT(offsetof(typeof(*rn), rn_padding_3) != 0); + CLASSERT(offsetof(typeof(*rn), rn_padding_4) != 0); +} + void lustre_swab_lov_desc (struct lov_desc *ld) { __swab32s (&ld->ld_tgt_count); diff --git a/lustre/ptlrpc/ptlrpc_module.c b/lustre/ptlrpc/ptlrpc_module.c index 182537e..f9beb17 100644 --- a/lustre/ptlrpc/ptlrpc_module.c +++ b/lustre/ptlrpc/ptlrpc_module.c @@ -194,11 +194,17 @@ EXPORT_SYMBOL(lustre_swab_mds_body); EXPORT_SYMBOL(lustre_swab_mdt_body); EXPORT_SYMBOL(lustre_swab_obd_quotactl); EXPORT_SYMBOL(lustre_swab_mds_rec_setattr); +EXPORT_SYMBOL(lustre_swab_mdt_rec_setattr); EXPORT_SYMBOL(lustre_swab_mds_rec_create); +EXPORT_SYMBOL(lustre_swab_mdt_rec_create); EXPORT_SYMBOL(lustre_swab_mds_rec_join); +EXPORT_SYMBOL(lustre_swab_mdt_rec_join); EXPORT_SYMBOL(lustre_swab_mds_rec_link); +EXPORT_SYMBOL(lustre_swab_mdt_rec_link); EXPORT_SYMBOL(lustre_swab_mds_rec_unlink); +EXPORT_SYMBOL(lustre_swab_mdt_rec_unlink); EXPORT_SYMBOL(lustre_swab_mds_rec_rename); +EXPORT_SYMBOL(lustre_swab_mdt_rec_rename); EXPORT_SYMBOL(lustre_swab_lov_desc); EXPORT_SYMBOL(lustre_swab_lov_user_md); EXPORT_SYMBOL(lustre_swab_lov_user_md_objects);