From 16c6c401e587541fb7444348bf9f051f46110ba5 Mon Sep 17 00:00:00 2001 From: yury Date: Tue, 14 Nov 2006 16:21:20 +0000 Subject: [PATCH] - fixed race in lmv about fid allocation. It allocated fid on one target and sent create operation to anorher mds if dir got split in the middle; - added proc stats to mdt. --- lustre/cmm/cmm_internal.h | 1 + lustre/cmm/cmm_lproc.c | 2 + lustre/cmm/cmm_object.c | 48 +++++++++++-------- lustre/include/linux/lustre_intent.h | 18 +++---- lustre/include/lustre/lustre_idl.h | 11 +++++ lustre/include/obd.h | 21 +++----- lustre/include/obd_class.h | 8 ++-- lustre/liblustre/dir.c | 3 +- lustre/liblustre/file.c | 7 ++- lustre/liblustre/llite_fid.c | 25 ---------- lustre/liblustre/llite_lib.h | 8 +--- lustre/liblustre/namei.c | 26 +++++----- lustre/liblustre/super.c | 63 ++++++++---------------- lustre/llite/dcache.c | 50 ++++---------------- lustre/llite/dir.c | 6 ++- lustre/llite/file.c | 8 ++-- lustre/llite/llite_fid.c | 34 +------------ lustre/llite/llite_internal.h | 8 +--- lustre/llite/llite_lib.c | 65 +++++++++++++++++-------- lustre/llite/namei.c | 92 ++++++++++-------------------------- lustre/lmv/lmv_intent.c | 12 +++++ lustre/lmv/lmv_internal.h | 2 + lustre/lmv/lmv_obd.c | 50 +++++++++++--------- lustre/mdc/mdc_internal.h | 3 ++ lustre/mdc/mdc_locks.c | 12 ++++- lustre/mdc/mdc_reint.c | 16 ++++++- lustre/mdc/mdc_request.c | 8 ++-- lustre/mdt/mdt_handler.c | 14 ++++-- lustre/mdt/mdt_internal.h | 34 +++++++++++-- lustre/mdt/mdt_lproc.c | 92 +++++++++++++++++++++++++++++++++++- lustre/mdt/mdt_open.c | 29 +++++++----- lustre/mdt/mdt_reint.c | 5 ++ 32 files changed, 418 insertions(+), 363 deletions(-) diff --git a/lustre/cmm/cmm_internal.h b/lustre/cmm/cmm_internal.h index e3af448..ac0ee9a 100644 --- a/lustre/cmm/cmm_internal.h +++ b/lustre/cmm/cmm_internal.h @@ -224,6 +224,7 @@ enum { LPROC_CMM_SPLIT_CHECK = 0, LPROC_CMM_SPLIT, LPROC_CMM_LOOKUP, + LPROC_CMM_CREATE, LPROC_CMM_LAST }; diff --git a/lustre/cmm/cmm_lproc.c b/lustre/cmm/cmm_lproc.c index 2aa1e99..554f155 100644 --- a/lustre/cmm/cmm_lproc.c +++ b/lustre/cmm/cmm_lproc.c @@ -58,6 +58,8 @@ static int cmm_procfs_init_stats(struct cmm_device *cmm, int num_stats) cmm->cmm_stats = stats; + lprocfs_counter_init(cmm->cmm_stats, LPROC_CMM_CREATE, + LPROCFS_CNTR_AVGMINMAX, "create", "time"); lprocfs_counter_init(cmm->cmm_stats, LPROC_CMM_LOOKUP, LPROCFS_CNTR_AVGMINMAX, "lookup", "time"); lprocfs_counter_init(cmm->cmm_stats, LPROC_CMM_SPLIT, diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index 22fa8c0..8c00059 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -78,7 +78,7 @@ struct lu_object *cmm_object_alloc(const struct lu_env *env, const struct lu_fid *fid = &loh->loh_fid; struct lu_object *lo = NULL; struct cmm_device *cd; - mdsno_t mdsnum; + mdsno_t mds; int rc = 0; ENTRY; @@ -86,7 +86,7 @@ struct lu_object *cmm_object_alloc(const struct lu_env *env, cd = lu2cmm_dev(ld); if (cd->cmm_flags & CMM_INITIALIZED) { /* get object location */ - rc = cmm_fld_lookup(lu2cmm_dev(ld), fid, &mdsnum, env); + rc = cmm_fld_lookup(lu2cmm_dev(ld), fid, &mds, env); if (rc) RETURN(NULL); } else @@ -95,10 +95,10 @@ struct lu_object *cmm_object_alloc(const struct lu_env *env, * as part of early bootstrap procedure (it is /ROOT, or /fld, * etc.). Such object *has* to be local. */ - mdsnum = cd->cmm_local_num; + mds = cd->cmm_local_num; /* select the proper set of operations based on object location */ - if (mdsnum == cd->cmm_local_num) { + if (mds == cd->cmm_local_num) { struct cml_object *clo; OBD_ALLOC_PTR(clo); @@ -119,7 +119,7 @@ struct lu_object *cmm_object_alloc(const struct lu_env *env, cro->cmm_obj.cmo_obj.mo_ops = &cmr_mo_ops; cro->cmm_obj.cmo_obj.mo_dir_ops = &cmr_dir_ops; lo->lo_ops = &cmr_obj_ops; - cro->cmo_num = mdsnum; + cro->cmo_num = mds; } } RETURN(lo); @@ -389,11 +389,14 @@ static int cml_create(const struct lu_env *env, struct md_object *mo_p, const char *name, struct md_object *mo_c, struct md_op_spec *spec, struct md_attr *ma) { + struct cmm_device *cmm = cmm_obj2dev(md2cmm_obj(mo_p)); + struct timeval start; int rc; ENTRY; -#ifdef HAVE_SPLIT_SUPPORT + cmm_lprocfs_time_start(cmm, &start, LPROC_CMM_CREATE); +#ifdef HAVE_SPLIT_SUPPORT /* Lock mode always should be sane. */ LASSERT(spec->sp_cr_mode != MDL_MINMODE); @@ -401,15 +404,17 @@ static int cml_create(const struct lu_env *env, struct md_object *mo_p, * Sigh... This is long story. MDT may have race with detecting if split * is possible in cmm. We know this race and let it live, because * getting it rid (with some sem or spinlock) will also mean that - * PDIROPS for create will not work, what is really bad for performance - * and makes no sense. So, we better allow the race but split dir only - * if some of concurrent threads takes EX lock. So that, say, two - * concurrent threads may have different lock modes on directory (CW and - * EX) and not first one which comes here should split dir, but only - * that which has EX lock. And we do not care that in this case, split - * will happen a bit later may be (when dir size will not be mandatory - * 64K, but may be larger). So that, we allow concurrent creates and - * protect split by EX lock. + * PDIROPS for create will not work because we kill parallel work, what + * is really bad for performance and makes no sense having PDIROPS. So, + * we better allow the race to live, but split dir only if some of + * concurrent threads takes EX lock, not matter which one. So that, say, + * two concurrent threads may have different lock modes on directory (CW + * and EX) and not first one which comes here and see that split is + * possible should split the dir, but only that one which has EX + * lock. And we do not care that in this case, split may happen a bit + * later (when dir size will not be necessarily 64K, but may be a bit + * larger). So that, we allow concurrent creates and protect split by EX + * lock. */ if (spec->sp_cr_mode == MDL_EX) { /* @@ -424,7 +429,7 @@ static int cml_create(const struct lu_env *env, struct md_object *mo_p, * -ERESTART or some split error is returned, we can't * proceed with create. */ - RETURN(rc); + GOTO(out, rc); } if (spec != NULL && spec->sp_ck_split) { @@ -435,14 +440,17 @@ static int cml_create(const struct lu_env *env, struct md_object *mo_p, */ rc = cmm_split_check(env, mo_p, name); if (rc) - RETURN(rc); + GOTO(out, rc); } #endif rc = mdo_create(env, md_object_next(mo_p), name, md_object_next(mo_c), spec, ma); - RETURN(rc); + EXIT; +out: + cmm_lprocfs_time_end(cmm, &start, LPROC_CMM_CREATE); + return rc; } static int cml_create_data(const struct lu_env *env, struct md_object *p, @@ -836,6 +844,7 @@ static int cmr_create(const struct lu_env *env, struct md_object *mo_p, int rc; ENTRY; + /* check the SGID attr */ cmi = cmm_env_info(env); LASSERT(cmi); @@ -850,7 +859,6 @@ static int cmr_create(const struct lu_env *env, struct md_object *mo_p, tmp_ma->ma_need |= MA_ACL_DEF; } #endif - rc = mo_attr_get(env, md_object_next(mo_p), tmp_ma); if (rc) RETURN(rc); @@ -871,7 +879,7 @@ static int cmr_create(const struct lu_env *env, struct md_object *mo_p, } #endif - /* remote object creation and local name insert */ + /* Remote object creation and local name insert. */ rc = mo_object_create(env, md_object_next(mo_c), spec, ma); if (rc == 0) { rc = mdo_name_insert(env, md_object_next(mo_p), diff --git a/lustre/include/linux/lustre_intent.h b/lustre/include/linux/lustre_intent.h index 3d8cb2c..84629e1 100644 --- a/lustre/include/linux/lustre_intent.h +++ b/lustre/include/linux/lustre_intent.h @@ -4,14 +4,15 @@ #include #ifndef LUSTRE_KERNEL_VERSION -#define IT_OPEN (1) -#define IT_CREAT (1<<1) -#define IT_READDIR (1<<2) -#define IT_GETATTR (1<<3) -#define IT_LOOKUP (1<<4) -#define IT_UNLINK (1<<5) -#define IT_TRUNC (1<<6) -#define IT_GETXATTR (1<<7) + +#define IT_OPEN (1 << 0) +#define IT_CREAT (1 << 1) +#define IT_READDIR (1 << 2) +#define IT_GETATTR (1 << 3) +#define IT_LOOKUP (1 << 4) +#define IT_UNLINK (1 << 5) +#define IT_TRUNC (1 << 6) +#define IT_GETXATTR (1 << 7) struct lustre_intent_data { int it_disposition; @@ -30,6 +31,5 @@ struct lookup_intent { } d; }; - #endif #endif diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 880a764..0011a98 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -634,6 +634,14 @@ struct obdo { extern void lustre_swab_obdo (struct obdo *o); +enum { + LUSTRE_OPC_MKDIR = (1 << 0), + LUSTRE_OPC_SYMLINK = (1 << 1), + LUSTRE_OPC_MKNOD = (1 << 2), + LUSTRE_OPC_CREATE = (1 << 3), + LUSTRE_OPC_ANY = (1 << 4) +}; + struct md_op_data { struct lu_fid op_fid1; struct lu_fid op_fid2; @@ -668,6 +676,9 @@ struct md_op_data { /* Various operation flags. */ __u32 op_bias; + + /* Operation type */ + __u32 op_opc; }; #define MDS_MODE_DONT_LOCK (1 << 30) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 738846b..6b7aa93 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -707,18 +707,6 @@ struct niobuf_local { int rc; }; -#define LUSTRE_OPC_MKDIR (1 << 0) -#define LUSTRE_OPC_SYMLINK (1 << 1) -#define LUSTRE_OPC_MKNOD (1 << 2) -#define LUSTRE_OPC_CREATE (1 << 3) - -struct lu_placement_hint { - struct qstr *ph_pname; - struct lu_fid *ph_pfid; - struct qstr *ph_cname; - int ph_opc; -}; - #define LUSTRE_FLD_NAME "fld" #define LUSTRE_SEQ_NAME "seq" @@ -1022,13 +1010,18 @@ struct obd_ops { struct obd_connect_data *ocd); int (*o_disconnect)(struct obd_export *exp); - /* maybe later these should be moved into separate fid_ops */ + /* Initialize/finalize fids infrastructure. */ int (*o_fid_init)(struct obd_export *exp); int (*o_fid_fini)(struct obd_export *exp); + /* Allocate new fid according to passed @hint. */ int (*o_fid_alloc)(struct obd_export *exp, struct lu_fid *fid, - struct lu_placement_hint *hint); + struct md_op_data *op_data); + /* + * Object with @fid is getting deleted, we may want to do something + * about this. + */ int (*o_fid_delete)(struct obd_export *exp, const struct lu_fid *fid); int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs, diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 7eb0396..45eed12 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -780,7 +780,7 @@ static inline int obd_fid_init(struct obd_export *exp) ENTRY; if (OBP(exp->exp_obd, fid_init) == NULL) - RETURN(-ENOTSUPP); + RETURN(0); OBD_COUNTER_INCREMENT(exp->exp_obd, fid_init); @@ -794,7 +794,7 @@ static inline int obd_fid_fini(struct obd_export *exp) ENTRY; if (OBP(exp->exp_obd, fid_fini) == NULL) - RETURN(-ENOTSUPP); + RETURN(0); OBD_COUNTER_INCREMENT(exp->exp_obd, fid_fini); @@ -804,7 +804,7 @@ static inline int obd_fid_fini(struct obd_export *exp) static inline int obd_fid_alloc(struct obd_export *exp, struct lu_fid *fid, - struct lu_placement_hint *hint) + struct md_op_data *op_data) { int rc; ENTRY; @@ -814,7 +814,7 @@ static inline int obd_fid_alloc(struct obd_export *exp, OBD_COUNTER_INCREMENT(exp->exp_obd, fid_alloc); - rc = OBP(exp->exp_obd, fid_alloc)(exp, fid, hint); + rc = OBP(exp->exp_obd, fid_alloc)(exp, fid, op_data); RETURN(rc); } diff --git a/lustre/liblustre/dir.c b/lustre/liblustre/dir.c index a747f46..a24b203 100644 --- a/lustre/liblustre/dir.c +++ b/lustre/liblustre/dir.c @@ -85,7 +85,8 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page) rc = ldlm_lock_match(obddev->obd_namespace, LDLM_FL_BLOCK_GRANTED, &res_id, LDLM_IBITS, &policy, LCK_CR, &lockh); if (!rc) { - llu_prep_md_op_data(&op_data, inode, NULL, NULL, 0, 0); + llu_prep_md_op_data(&op_data, inode, NULL, NULL, 0, 0, + LUSTRE_OPC_ANY); rc = md_enqueue(sbi->ll_md_exp, LDLM_IBITS, &it, LCK_CR, &op_data, &lockh, NULL, 0, diff --git a/lustre/liblustre/file.c b/lustre/liblustre/file.c index aa9c17b..9cc8e8a 100644 --- a/lustre/liblustre/file.c +++ b/lustre/liblustre/file.c @@ -73,7 +73,7 @@ void ll_i2gids(__u32 *suppgids, struct inode *i1, struct inode *i2) void llu_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, struct inode *i2, const char *name, int namelen, - int mode) + int mode, __u32 opc) { LASSERT(i1 != NULL || i2 != NULL); LASSERT(op_data); @@ -89,10 +89,13 @@ void llu_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, if (i2) op_data->op_fid2 = *ll_inode2fid(i2); + else + fid_zero(&op_data->op_fid2); + op_data->op_opc = opc; op_data->op_name = name; - op_data->op_namelen = namelen; op_data->op_mode = mode; + op_data->op_namelen = namelen; op_data->op_mod_time = CURRENT_TIME; } diff --git a/lustre/liblustre/llite_fid.c b/lustre/liblustre/llite_fid.c index 4de84fe..20df52f 100644 --- a/lustre/liblustre/llite_fid.c +++ b/lustre/liblustre/llite_fid.c @@ -51,31 +51,6 @@ #include #include -static int llu_fid_alloc(struct obd_export *exp, struct lu_fid *fid, - struct lu_placement_hint *hint) -{ - int rc; - ENTRY; - rc = obd_fid_alloc(exp, fid, hint); - RETURN(rc); -} - -/* allocates passed fid, that is assigns f_num and f_seq to the @fid */ -int llu_fid_md_alloc(struct llu_sb_info *sbi, struct lu_fid *fid, - struct lu_placement_hint *hint) -{ - ENTRY; - RETURN(llu_fid_alloc(sbi->ll_md_exp, fid, hint)); -} - -/* allocates passed fid, that is assigns f_num and f_seq to the @fid */ -int llu_fid_dt_alloc(struct llu_sb_info *sbi, struct lu_fid *fid, - struct lu_placement_hint *hint) -{ - ENTRY; - RETURN(llu_fid_alloc(sbi->ll_dt_exp, fid, hint)); -} - /* build inode number on passed @fid */ unsigned long llu_fid_build_ino(struct llu_sb_info *sbi, struct lu_fid *fid) diff --git a/lustre/liblustre/llite_lib.h b/lustre/liblustre/llite_lib.h index f1d230f..35a1c0d 100644 --- a/lustre/liblustre/llite_lib.h +++ b/lustre/liblustre/llite_lib.h @@ -200,7 +200,7 @@ extern struct fssw_ops llu_fssw_ops; /* file.c */ void llu_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, struct inode *i2, const char *name, int namelen, - int mode); + int mode, __u32 opc); void llu_finish_md_op_data(struct md_op_data *op_data); int llu_create(struct inode *dir, struct pnode_base *pnode, int mode); int llu_local_open(struct llu_inode_info *lli, struct lookup_intent *it); @@ -244,12 +244,6 @@ ssize_t llu_iop_filldirentries(struct inode *ino, _SYSIO_OFF_T *basep, char *buf, size_t nbytes); /* liblustre/llite_fid.c*/ -int llu_fid_md_alloc(struct llu_sb_info *sbi, struct lu_fid *fid, - struct lu_placement_hint *hint); - -int llu_fid_dt_alloc(struct llu_sb_info *sbi, struct lu_fid *fid, - struct lu_placement_hint *hint); - unsigned long llu_fid_build_ino(struct llu_sb_info *sbi, struct lu_fid *fid); diff --git a/lustre/liblustre/namei.c b/lustre/liblustre/namei.c index 979d295..c70d9c0 100644 --- a/lustre/liblustre/namei.c +++ b/lustre/liblustre/namei.c @@ -276,7 +276,8 @@ static int llu_pb_revalidate(struct pnode *pnode, int flags, } llu_prep_md_op_data(&op_data, pnode->p_parent->p_base->pb_ino, - pb->pb_ino, pb->pb_name.name, pb->pb_name.len,0); + pb->pb_ino, pb->pb_name.name, pb->pb_name.len, + 0, LUSTRE_OPC_ANY); rc = md_intent_lock(exp, &op_data, NULL, 0, it, flags, &req, llu_md_blocking_ast, @@ -430,6 +431,7 @@ static int llu_lookup_it(struct inode *parent, struct pnode *pnode, struct it_cb_data icbd; struct ptlrpc_request *req = NULL; struct lookup_intent lookup_it = { .it_op = IT_LOOKUP }; + __u32 opc; int rc; ENTRY; @@ -444,23 +446,17 @@ static int llu_lookup_it(struct inode *parent, struct pnode *pnode, icbd.icbd_child = pnode; icbd.icbd_parent = parent; - llu_prep_md_op_data(&op_data, parent, NULL, - pnode->p_base->pb_name.name, - pnode->p_base->pb_name.len, flags); - - /* allocate new fid for child */ if (it->it_op & IT_CREAT || (it->it_op & IT_OPEN && it->it_create_mode & O_CREAT)) { - struct lu_placement_hint hint = { .ph_pname = NULL, - .ph_cname = &pnode->p_base->pb_name, - .ph_opc = LUSTRE_OPC_CREATE }; - - rc = llu_fid_md_alloc(llu_i2sbi(parent), &op_data.op_fid2, &hint); - if (rc) { - CERROR("can't allocate new fid, rc %d\n", rc); - LBUG(); - } + opc = LUSTRE_OPC_CREATE; + } else { + opc = LUSTRE_OPC_ANY; } + + llu_prep_md_op_data(&op_data, parent, NULL, + pnode->p_base->pb_name.name, + pnode->p_base->pb_name.len, flags, opc); + rc = md_intent_lock(llu_i2mdcexp(parent), &op_data, NULL, 0, it, flags, &req, llu_md_blocking_ast, LDLM_FL_CANCEL_ON_BLOCK); diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index 32962d1..627fc6f 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -624,7 +624,7 @@ int llu_md_setattr(struct inode *inode, struct md_op_data *op_data) int rc; ENTRY; - llu_prep_md_op_data(op_data, inode, NULL, NULL, 0, 0); + llu_prep_md_op_data(op_data, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY); rc = md_setattr(sbi->ll_md_exp, op_data, NULL, 0, NULL, 0, &request); if (rc) { @@ -933,11 +933,6 @@ static int llu_iop_symlink_raw(struct pnode *pno, const char *tgt) struct ptlrpc_request *request = NULL; struct llu_sb_info *sbi = llu_i2sbi(dir); struct md_op_data op_data; - struct lu_placement_hint hint = { - .ph_pname = NULL, - .ph_cname = qstr, - .ph_opc = LUSTRE_OPC_SYMLINK - }; int err = -EMLINK; ENTRY; @@ -945,14 +940,9 @@ static int llu_iop_symlink_raw(struct pnode *pno, const char *tgt) if (llu_i2stat(dir)->st_nlink >= EXT2_LINK_MAX) RETURN(err); - llu_prep_md_op_data(&op_data, dir, NULL, name, len, 0); + llu_prep_md_op_data(&op_data, dir, NULL, name, len, 0, + LUSTRE_OPC_SYMLINK); - /* allocate new fid */ - err = llu_fid_md_alloc(sbi, &op_data.op_fid2, &hint); - if (err) { - CERROR("can't allocate new fid, rc %d\n", err); - RETURN(err); - } err = md_create(sbi->ll_md_exp, &op_data, tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO, current->fsuid, current->fsgid, current->cap_effective, @@ -1059,11 +1049,6 @@ static int llu_iop_mknod_raw(struct pnode *pno, struct llu_sb_info *sbi = llu_i2sbi(dir); struct md_op_data op_data; int err = -EMLINK; - struct lu_placement_hint hint = { - .ph_pname = NULL, - .ph_cname = &pno->p_base->pb_name, - .ph_opc = LUSTRE_OPC_MKNOD - }; ENTRY; liblustre_wait_event(0); @@ -1084,13 +1069,8 @@ static int llu_iop_mknod_raw(struct pnode *pno, case S_IFSOCK: llu_prep_md_op_data(&op_data, dir, NULL, pno->p_base->pb_name.name, - pno->p_base->pb_name.len, 0); - /* allocate new fid */ - err = llu_fid_md_alloc(sbi, &op_data.op_fid2, &hint); - if (err) { - CERROR("can't allocate new fid, rc %d\n", err); - RETURN(err); - } + pno->p_base->pb_name.len, 0, + LUSTRE_OPC_MKNOD); err = md_create(sbi->ll_md_exp, &op_data, NULL, 0, mode, current->fsuid, current->fsgid, @@ -1122,7 +1102,8 @@ static int llu_iop_link_raw(struct pnode *old, struct pnode *new) LASSERT(dir); liblustre_wait_event(0); - llu_prep_md_op_data(&op_data, src, dir, name, namelen, 0); + llu_prep_md_op_data(&op_data, src, dir, name, namelen, 0, + LUSTRE_OPC_ANY); rc = md_link(llu_i2sbi(src)->ll_md_exp, &op_data, &request); ptlrpc_req_finished(request); liblustre_wait_event(0); @@ -1148,7 +1129,8 @@ static int llu_iop_unlink_raw(struct pnode *pno) LASSERT(target); liblustre_wait_event(0); - llu_prep_md_op_data(&op_data, dir, NULL, name, len, 0); + llu_prep_md_op_data(&op_data, dir, NULL, name, len, 0, + LUSTRE_OPC_ANY); rc = md_unlink(llu_i2sbi(dir)->ll_md_exp, &op_data, &request); if (!rc) rc = llu_objects_destroy(request, dir); @@ -1175,7 +1157,8 @@ static int llu_iop_rename_raw(struct pnode *old, struct pnode *new) LASSERT(tgt); liblustre_wait_event(0); - llu_prep_md_op_data(&op_data, src, tgt, NULL, 0, 0); + llu_prep_md_op_data(&op_data, src, tgt, NULL, 0, 0, + LUSTRE_OPC_ANY); rc = md_rename(llu_i2sbi(src)->ll_md_exp, &op_data, oldname, oldnamelen, newname, newnamelen, &request); @@ -1311,12 +1294,6 @@ static int llu_iop_mkdir_raw(struct pnode *pno, mode_t mode) struct ptlrpc_request *request = NULL; struct intnl_stat *st = llu_i2stat(dir); struct md_op_data op_data; - struct lu_placement_hint hint = { - .ph_pname = NULL, - .ph_cname = qstr, - .ph_opc = LUSTRE_OPC_MKDIR - }; - int err = -EMLINK; ENTRY; @@ -1327,14 +1304,9 @@ static int llu_iop_mkdir_raw(struct pnode *pno, mode_t mode) if (st->st_nlink >= EXT2_LINK_MAX) RETURN(err); - llu_prep_md_op_data(&op_data, dir, NULL, name, len, 0); + llu_prep_md_op_data(&op_data, dir, NULL, name, len, 0, + LUSTRE_OPC_MKDIR); - /* allocate new fid */ - err = llu_fid_md_alloc(llu_i2sbi(dir), &op_data.op_fid2, &hint); - if (err) { - CERROR("can't allocate new fid, rc %d\n", err); - RETURN(err); - } err = md_create(llu_i2sbi(dir)->ll_md_exp, &op_data, NULL, 0, mode, current->fsuid, current->fsgid, current->cap_effective, 0, &request); @@ -1359,7 +1331,8 @@ static int llu_iop_rmdir_raw(struct pnode *pno) (long long)llu_i2stat(dir)->st_ino, llu_i2info(dir)->lli_st_generation, dir); - llu_prep_md_op_data(&op_data, dir, NULL, name, len, S_IFDIR); + llu_prep_md_op_data(&op_data, dir, NULL, name, len, S_IFDIR, + LUSTRE_OPC_ANY); rc = md_unlink(llu_i2sbi(dir)->ll_md_exp, &op_data, &request); ptlrpc_req_finished(request); @@ -1699,7 +1672,8 @@ static int llu_lov_dir_setstripe(struct inode *ino, unsigned long arg) struct lov_user_md lum, *lump = (struct lov_user_md *)arg; int rc = 0; - llu_prep_md_op_data(&op_data, ino, NULL, NULL, 0, 0); + llu_prep_md_op_data(&op_data, ino, NULL, NULL, 0, 0, + LUSTRE_OPC_ANY); LASSERT(sizeof(lum) == sizeof(*lump)); LASSERT(sizeof(lum.lmm_objects[0]) == @@ -1762,7 +1736,8 @@ static int llu_lov_setstripe_ea_info(struct inode *ino, int flags, lli2->lli_symlink_name = NULL; ino->i_private = lli2; - llu_prep_md_op_data(&data, NULL, ino, NULL, 0, O_RDWR); + llu_prep_md_op_data(&data, NULL, ino, NULL, 0, O_RDWR, + LUSTRE_OPC_ANY); rc = md_enqueue(sbi->ll_md_exp, LDLM_IBITS, &oit, LCK_CR, &data, &lockh, lum, lum_size, ldlm_completion_ast, diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index 0fcb61d..f2d69d4 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -397,31 +397,14 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, parent = de->d_parent->d_inode; if (it->it_op & IT_CREAT) { - /* - * Allocate new fid for case of create or open(O_CREAT). In both - * cases it->it_op will contain IT_CREAT. In case of - * open(O_CREAT) agains existing file, fid allocating is not - * needed, but this is not known until server returns - * anything. Well, in this case new allocated fid is lost. But - * this is not big deal, we have 64bit fids. --umka - */ - struct lu_placement_hint hint = { .ph_pname = NULL, - .ph_pfid = ll_inode2fid(parent), - .ph_cname = &de->d_name, - .ph_opc = LUSTRE_OPC_CREATE }; - - op_data = ll_prep_md_op_data(NULL, parent, NULL, - de->d_name.name, de->d_name.len, 0); + op_data = ll_prep_md_op_data(NULL, parent, NULL, de->d_name.name, + de->d_name.len, 0, LUSTRE_OPC_CREATE); if (op_data == NULL) RETURN(-ENOMEM); - rc = ll_fid_md_alloc(ll_i2sbi(parent), &op_data->op_fid2, &hint); - if (rc) { - ll_finish_md_op_data(op_data); - RETURN(rc); - } } else { op_data = ll_prep_md_op_data(NULL, parent, de->d_inode, - de->d_name.name, de->d_name.len, 0); + de->d_name.name, de->d_name.len, + 0, LUSTRE_OPC_ANY); if (op_data == NULL) RETURN(-ENOMEM); } @@ -574,29 +557,14 @@ do_lookup: it = &lookup_it; } - /* do real lookup here */ - op_data = ll_prep_md_op_data(NULL, parent, NULL, - de->d_name.name, de->d_name.len, 0); + /* Do real lookup here. */ + op_data = ll_prep_md_op_data(NULL, parent, NULL, de->d_name.name, + de->d_name.len, 0, (it->it_op & IT_CREAT ? + LUSTRE_OPC_CREATE : + LUSTRE_OPC_ANY)); if (op_data == NULL) RETURN(-ENOMEM); - if (it->it_op & IT_CREAT) { - /* - * Allocate new fid for case of create or open with O_CREAT. In - * both cases it->it_op will contain IT_CREAT. - */ - struct lu_placement_hint hint = { .ph_pname = NULL, - .ph_pfid = ll_inode2fid(parent), - .ph_cname = &de->d_name, - .ph_opc = LUSTRE_OPC_CREATE }; - - rc = ll_fid_md_alloc(ll_i2sbi(parent), &op_data->op_fid2, &hint); - if (rc) { - ll_finish_md_op_data(op_data); - RETURN(rc); - } - } - rc = md_intent_lock(exp, op_data, NULL, 0, it, 0, &req, ll_md_blocking_ast, 0); if (rc >= 0) { diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index cfe67c0..e7b91e8 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -293,7 +293,8 @@ static struct page *ll_get_dir_page(struct inode *dir, __u32 hash, int exact, struct ptlrpc_request *request; struct md_op_data *op_data; - op_data = ll_prep_md_op_data(NULL, dir, NULL, NULL, 0, 0); + op_data = ll_prep_md_op_data(NULL, dir, NULL, NULL, 0, 0, + LUSTRE_OPC_ANY); if (op_data == NULL) return ERR_PTR(-ENOMEM); @@ -606,7 +607,8 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, lustre_swab_lov_user_md(&lum); /* swabbing is done in lov_setstripe() on server side */ - op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0); + op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, + LUSTRE_OPC_ANY); if (op_data == NULL) RETURN(-ENOMEM); rc = md_setattr(sbi->ll_md_exp, op_data, &lum, diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 6306c9d..126c0b3 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -328,7 +328,7 @@ static int ll_intent_file_open(struct file *file, void *lmm, itp->it_flags |= MDS_OPEN_LOCK; op_data = ll_prep_md_op_data(NULL, parent->d_inode, NULL, name, len, - O_RDWR); + O_RDWR, LUSTRE_OPC_ANY); if (op_data == NULL) RETURN(-ENOMEM); @@ -1881,7 +1881,8 @@ static int join_file(struct inode *head_inode, struct file *head_filp, op_data = ll_prep_md_op_data(NULL, head_inode, tail_parent, tail_dentry->d_name.name, - tail_dentry->d_name.len, 0); + tail_dentry->d_name.len, 0, + LUSTRE_OPC_ANY); if (op_data == NULL) RETURN(-ENOMEM); @@ -2416,7 +2417,8 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it) /* Call getattr by fid, so do not provide name at all. */ op_data = ll_prep_md_op_data(NULL, dentry->d_parent->d_inode, - dentry->d_inode, NULL, 0, 0); + dentry->d_inode, NULL, 0, 0, + LUSTRE_OPC_ANY); if (op_data == NULL) RETURN(-ENOMEM); it->it_flags |= O_CHECK_STALE; diff --git a/lustre/llite/llite_fid.c b/lustre/llite/llite_fid.c index 0242b4c..4c2a6167 100644 --- a/lustre/llite/llite_fid.c +++ b/lustre/llite/llite_fid.c @@ -36,39 +36,7 @@ #include #include "llite_internal.h" -static int ll_fid_alloc(struct obd_export *exp, struct lu_fid *fid, - struct lu_placement_hint *hint) -{ - int rc; - ENTRY; - - rc = obd_fid_alloc(exp, fid, hint); - if (rc) { - CERROR("Can't allocate new fid, rc %d\n", rc); - RETURN(rc); - } - - LASSERT(fid_is_sane(fid)); - RETURN(rc); -} - -/* allocates passed fid, that is assigns f_num and f_seq to the @fid */ -int ll_fid_md_alloc(struct ll_sb_info *sbi, struct lu_fid *fid, - struct lu_placement_hint *hint) -{ - ENTRY; - RETURN(ll_fid_alloc(sbi->ll_md_exp, fid, hint)); -} - -/* allocates passed fid, that is assigns f_num and f_seq to the @fid */ -int ll_fid_dt_alloc(struct ll_sb_info *sbi, struct lu_fid *fid, - struct lu_placement_hint *hint) -{ - ENTRY; - RETURN(ll_fid_alloc(sbi->ll_dt_exp, fid, hint)); -} - -/* build inode number on passed @fid */ +/* Build inode number on passed @fid */ ino_t ll_fid_build_ino(struct ll_sb_info *sbi, struct lu_fid *fid) { diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 040f653..e16839a 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -578,7 +578,7 @@ int ll_ioctl_setfacl(struct inode *inode, struct rmtacl_ioctl_data *ioc); struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, struct inode *i2, const char *name, int namelen, - int mode); + int mode, __u32 opc); void ll_finish_md_op_data(struct md_op_data *op_data); /* llite/llite_nfs.c */ @@ -727,12 +727,6 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm); int lustre_check_remote_perm(struct inode *inode, int mask); /* llite/llite_fid.c */ -int ll_fid_md_alloc(struct ll_sb_info *sbi, struct lu_fid *fid, - struct lu_placement_hint *hint); - -int ll_fid_dt_alloc(struct ll_sb_info *sbi, struct lu_fid *fid, - struct lu_placement_hint *hint); - ino_t ll_fid_build_ino(struct ll_sb_info *sbi, struct lu_fid *fid); /* llite/llite_capa.c */ diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 4359684..4fa69db 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -230,13 +230,20 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, } sbi->ll_md_exp = class_conn2export(&md_conn); + err = obd_fid_init(sbi->ll_md_exp); + if (err) { + CERROR("Can't init metadata layer FID infrastructure, " + "rc %d\n", err); + GOTO(out_md, err); + } + err = obd_statfs(obd, &osfs, cfs_time_current_64() - HZ); if (err) - GOTO(out_md, err); + GOTO(out_md_fid, err); size = sizeof(*data); - err = obd_get_info(sbi->ll_md_exp, strlen(KEY_CONN_DATA), KEY_CONN_DATA, - &size, data); + err = obd_get_info(sbi->ll_md_exp, strlen(KEY_CONN_DATA), + KEY_CONN_DATA, &size, data); if (err) { CERROR("Get connect data failed: %d \n", err); GOTO(out_md, err); @@ -316,7 +323,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, obd = class_name2obd(dt); if (!obd) { CERROR("DT %s: not setup or attached\n", dt); - GOTO(out_md, err = -ENODEV); + GOTO(out_md_fid, err = -ENODEV); } data->ocd_connect_flags = OBD_CONNECT_GRANT | OBD_CONNECT_VERSION | @@ -337,14 +344,21 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, LCONSOLE_ERROR("An OST (dt %s) is performing recovery, of which this" " client is not a part. Please wait for recovery to " "complete, abort, or time out.\n", dt); - GOTO(out, err); + GOTO(out_md_fid, err); } else if (err) { - CERROR("cannot connect to %s: rc = %d\n", dt, err); - GOTO(out_md, err); + CERROR("Cannot connect to %s: rc = %d\n", dt, err); + GOTO(out_md_fid, err); } sbi->ll_dt_exp = class_conn2export(&dt_conn); + err = obd_fid_init(sbi->ll_dt_exp); + if (err) { + CERROR("Can't init data layer FID infrastructure, " + "rc %d\n", err); + GOTO(out_dt, err); + } + spin_lock(&sbi->ll_lco.lco_lock); sbi->ll_lco.lco_flags = data->ocd_connect_flags; spin_unlock(&sbi->ll_lco.lco_lock); @@ -357,7 +371,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, LCONSOLE_ERROR("There are no OST's in this filesystem. " "There must be at least one active OST for " "a client to start.\n"); - GOTO(out_dt, err); + GOTO(out_dt_fid, err); } if (!ll_async_page_slab) { @@ -367,13 +381,13 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ll_async_page_slab_size, 0, 0, NULL, NULL); if (!ll_async_page_slab) - GOTO(out_dt, err = -ENOMEM); + GOTO(out_dt_fid, err = -ENOMEM); } err = md_getstatus(sbi->ll_md_exp, &rootfid, &oc); if (err) { CERROR("cannot mds_connect: rc = %d\n", err); - GOTO(out_dt, err); + GOTO(out_dt_fid, err); } CDEBUG(D_SUPER, "rootfid "DFID"\n", PFID(&rootfid)); sbi->ll_root_fid = rootfid; @@ -396,7 +410,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, free_capa(oc); if (err) { CERROR("md_getattr failed for root: rc = %d\n", err); - GOTO(out_dt, err); + GOTO(out_dt_fid, err); } err = md_get_lustre_md(sbi->ll_md_exp, request, @@ -405,7 +419,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (err) { CERROR("failed to understand root inode md: rc = %d\n", err); ptlrpc_req_finished (request); - GOTO(out_dt, err); + GOTO(out_dt_fid, err); } LASSERT(fid_is_sane(&sbi->ll_root_fid)); @@ -438,13 +452,16 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, OBD_FREE(data, sizeof(*data)); sb->s_root->d_op = &ll_d_root_ops; RETURN(err); - out_root: if (root) iput(root); +out_dt_fid: + obd_fid_fini(sbi->ll_dt_exp); out_dt: obd_disconnect(sbi->ll_dt_exp); sbi->ll_dt_exp = NULL; +out_md_fid: + obd_fid_fini(sbi->ll_md_exp); out_md: obd_disconnect(sbi->ll_md_exp); sbi->ll_md_exp = NULL; @@ -452,7 +469,7 @@ out: if (data != NULL) OBD_FREE_PTR(data); lprocfs_unregister_mountpoint(sbi); - RETURN(err); + return err; } int ll_get_max_mdsize(struct ll_sb_info *sbi, int *lmmsize) @@ -637,11 +654,14 @@ void client_common_put_super(struct super_block *sb) prune_deathrow(sbi, 0); list_del(&sbi->ll_conn_chain); + + obd_fid_fini(sbi->ll_dt_exp); obd_disconnect(sbi->ll_dt_exp); sbi->ll_dt_exp = NULL; lprocfs_unregister_mountpoint(sbi); + obd_fid_fini(sbi->ll_md_exp); obd_disconnect(sbi->ll_md_exp); sbi->ll_md_exp = NULL; @@ -1254,8 +1274,10 @@ int ll_md_setattr(struct inode *inode, struct md_op_data *op_data) int rc; ENTRY; - op_data = ll_prep_md_op_data(op_data, inode, NULL, NULL, 0, 0); - rc = md_setattr(sbi->ll_md_exp, op_data, NULL, 0, NULL, 0, &request); + op_data = ll_prep_md_op_data(op_data, inode, NULL, NULL, 0, 0, + LUSTRE_OPC_ANY); + rc = md_setattr(sbi->ll_md_exp, op_data, NULL, 0, NULL, 0, + &request); if (rc) { ptlrpc_req_finished(request); if (rc == -ENOENT) { @@ -1942,7 +1964,8 @@ int ll_iocontrol(struct inode *inode, struct file *file, if (!oinfo.oi_oa) RETURN(-ENOMEM); - op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0); + op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, + LUSTRE_OPC_ANY); if (op_data == NULL) RETURN(-ENOMEM); @@ -2236,7 +2259,8 @@ int ll_process_config(struct lustre_cfg *lcfg) /* this function prepares md_op_data hint for passing ot down to MD stack. */ struct md_op_data * ll_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, - struct inode *i2, const char *name, int namelen, int mode) + struct inode *i2, const char *name, int namelen, + int mode, __u32 opc) { LASSERT(i1 != NULL); @@ -2250,11 +2274,11 @@ ll_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, op_data->op_fid1 = *ll_inode2fid(i1); op_data->op_capa1 = ll_mdscapa_get(i1); - /* @i2 may be NULL. In this case caller itself has to initialize ->fid2 - * if needed. */ if (i2) { op_data->op_fid2 = *ll_inode2fid(i2); op_data->op_capa2 = ll_mdscapa_get(i2); + } else { + fid_zero(&op_data->op_fid2); } op_data->op_name = name; @@ -2265,6 +2289,7 @@ ll_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, op_data->op_fsgid = current->fsgid; op_data->op_cap = current->cap_effective; op_data->op_bias = MDS_CHECK_SPLIT; + op_data->op_opc = opc; return op_data; } diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index f755360..ac34532 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -416,6 +416,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, struct ptlrpc_request *req = NULL; struct md_op_data *op_data; struct it_cb_data icbd; + __u32 opc; int rc; ENTRY; @@ -434,29 +435,17 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, icbd.icbd_childp = &dentry; icbd.icbd_parent = parent; - /* prepare operatoin hint first */ - + if (it->it_op & IT_CREAT || + (it->it_op & IT_OPEN && it->it_create_mode & O_CREAT)) + opc = LUSTRE_OPC_CREATE; + else + opc = LUSTRE_OPC_ANY; + op_data = ll_prep_md_op_data(NULL, parent, NULL, dentry->d_name.name, - dentry->d_name.len, lookup_flags); + dentry->d_name.len, lookup_flags, opc); if (op_data == NULL) RETURN(ERR_PTR(-ENOMEM)); - /* allocate new fid for child */ - if (it->it_op & IT_CREAT || - (it->it_op & IT_OPEN && it->it_create_mode & O_CREAT)) { - struct lu_placement_hint hint = { .ph_pname = NULL, - .ph_pfid = ll_inode2fid(parent), - .ph_cname = &dentry->d_name, - .ph_opc = LUSTRE_OPC_CREATE }; - - rc = ll_fid_md_alloc(ll_i2sbi(parent), &op_data->op_fid2, &hint); - if (rc) { - ll_finish_md_op_data(op_data); - LASSERT(rc < 0); - RETURN(ERR_PTR(rc)); - } - } - it->it_create_mode &= ~current->fs->umask; rc = md_intent_lock(ll_i2mdexp(parent), op_data, NULL, 0, it, @@ -721,16 +710,10 @@ static void ll_update_times(struct ptlrpc_request *request, int offset, static int ll_mknod_generic(struct inode *dir, struct qstr *name, int mode, unsigned rdev, struct dentry *dchild) { - struct ptlrpc_request *request = NULL; - struct inode *inode = NULL; struct ll_sb_info *sbi = ll_i2sbi(dir); + struct ptlrpc_request *request = NULL; struct md_op_data *op_data; - struct lu_placement_hint hint = { - .ph_pname = NULL, - .ph_pfid = ll_inode2fid(dir), - .ph_cname = name, - .ph_opc = LUSTRE_OPC_MKNOD - }; + struct inode *inode = NULL; int err; ENTRY; @@ -749,14 +732,10 @@ static int ll_mknod_generic(struct inode *dir, struct qstr *name, int mode, case S_IFIFO: case S_IFSOCK: op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, - name->len, 0); + name->len, 0, LUSTRE_OPC_MKNOD); if (op_data == NULL) RETURN(-ENOMEM); - err = ll_fid_md_alloc(sbi, &op_data->op_fid2, &hint); - if (err) { - ll_finish_md_op_data(op_data); - break; - } + err = md_create(sbi->ll_md_exp, op_data, NULL, 0, mode, current->fsuid, current->fsgid, current->cap_effective, rdev, &request); @@ -834,11 +813,6 @@ static int ll_symlink_generic(struct inode *dir, struct dentry *dchild, const char *tgt) { struct qstr *name = &dchild->d_name; - struct lu_placement_hint hint = { .ph_pname = NULL, - .ph_pfid = ll_inode2fid(dir), - .ph_cname = name, - .ph_opc = LUSTRE_OPC_SYMLINK }; - struct ptlrpc_request *request = NULL; struct ll_sb_info *sbi = ll_i2sbi(dir); struct inode *inode = NULL; @@ -850,21 +824,14 @@ static int ll_symlink_generic(struct inode *dir, struct dentry *dchild, name->len, name->name, dir->i_ino, dir->i_generation, dir, tgt); - op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len, 0); + op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, + name->len, 0, LUSTRE_OPC_SYMLINK); if (op_data == NULL) RETURN(-ENOMEM); - /* allocate new fid */ - err = ll_fid_md_alloc(ll_i2sbi(dir), &op_data->op_fid2, &hint); - if (err) { - ll_finish_md_op_data(op_data); - RETURN(err); - } - - err = md_create(sbi->ll_md_exp, op_data, - tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO, - current->fsuid, current->fsgid, current->cap_effective, - 0, &request); + err = md_create(sbi->ll_md_exp, op_data, tgt, strlen(tgt) + 1, + S_IFLNK | S_IRWXUGO, current->fsuid, current->fsgid, + current->cap_effective, 0, &request); ll_finish_md_op_data(op_data); if (err == 0) { ll_update_times(request, REPLY_REC_OFF, dir); @@ -895,7 +862,8 @@ static int ll_link_generic(struct inode *src, struct inode *dir, src->i_ino, src->i_generation, src, dir->i_ino, dir->i_generation, dir, name->len, name->name); - op_data = ll_prep_md_op_data(NULL, src, dir, name->name, name->len, 0); + op_data = ll_prep_md_op_data(NULL, src, dir, name->name, name->len, + 0, LUSTRE_OPC_ANY); if (op_data == NULL) RETURN(-ENOMEM); err = md_link(sbi->ll_md_exp, op_data, &request); @@ -911,10 +879,6 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, int mode, struct dentry *dchild) { - struct lu_placement_hint hint = { .ph_pname = NULL, - .ph_pfid = ll_inode2fid(dir), - .ph_cname = name, - .ph_opc = LUSTRE_OPC_MKDIR }; struct ptlrpc_request *request = NULL; struct ll_sb_info *sbi = ll_i2sbi(dir); struct inode *inode = NULL; @@ -927,17 +891,11 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, mode = (mode & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR; - op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len, 0); + op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len, + 0, LUSTRE_OPC_MKDIR); if (op_data == NULL) RETURN(-ENOMEM); - /* Allocate new fid. */ - err = ll_fid_md_alloc(ll_i2sbi(dir), &op_data->op_fid2, &hint); - if (err) { - ll_finish_md_op_data(op_data); - RETURN(err); - } - err = md_create(sbi->ll_md_exp, op_data, NULL, 0, mode, current->fsuid, current->fsgid, current->cap_effective, 0, &request); @@ -981,7 +939,7 @@ static int ll_rmdir_generic(struct inode *dir, struct dentry *dparent, } op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len, - S_IFDIR); + S_IFDIR, LUSTRE_OPC_ANY); if (op_data == NULL) RETURN(-ENOMEM); rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request); @@ -1077,7 +1035,8 @@ static int ll_unlink_generic(struct inode *dir, struct qstr *name) CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n", name->len, name->name, dir->i_ino, dir->i_generation, dir); - op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len, 0); + op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, + name->len, 0, LUSTRE_OPC_ANY); if (op_data == NULL) RETURN(-ENOMEM); rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request); @@ -1107,7 +1066,8 @@ static int ll_rename_generic(struct inode *src, struct qstr *src_name, src->i_ino, src->i_generation, src, tgt_name->len, tgt_name->name, tgt->i_ino, tgt->i_generation, tgt); - op_data = ll_prep_md_op_data(NULL, src, tgt, NULL, 0, 0); + op_data = ll_prep_md_op_data(NULL, src, tgt, NULL, 0, 0, + LUSTRE_OPC_ANY); if (op_data == NULL) RETURN(-ENOMEM); err = md_rename(sbi->ll_md_exp, op_data, diff --git a/lustre/lmv/lmv_intent.c b/lustre/lmv/lmv_intent.c index 167f0c9..f85915d 100644 --- a/lustre/lmv/lmv_intent.c +++ b/lustre/lmv/lmv_intent.c @@ -207,6 +207,7 @@ repeat: obj = lmv_obj_grab(obd, &rpid); if (obj) { int mea_idx; + /* * Directory is already split, so we have to forward request to * the right MDS. @@ -229,6 +230,16 @@ repeat: sop_data->op_fid1 = rpid; + if (it->it_op & IT_CREAT) { + /* + * For open with IT_CREATE and for IT_CREATE cases allocate new + * fid and setup FLD for it. + */ + rc = lmv_fid_alloc(exp, &sop_data->op_fid2, sop_data); + if (rc) + GOTO(out_free_sop_data, rc); + } + rc = md_intent_lock(tgt_exp, sop_data, lmm, lmmsize, it, flags, reqp, cb_blocking, extra_lock_flags); @@ -239,6 +250,7 @@ repeat: ptlrpc_req_finished(*reqp); *reqp = NULL; it->d.lustre.it_data = 0; + /* * Directory got split. Time to update local object and repeat * the request with proper MDS. diff --git a/lustre/lmv/lmv_internal.h b/lustre/lmv/lmv_internal.h index 8b7d823..0a2c0cb 100644 --- a/lustre/lmv/lmv_internal.h +++ b/lustre/lmv/lmv_internal.h @@ -141,6 +141,8 @@ int lmv_fld_lookup(struct lmv_obd *lmv, const struct lu_fid *fid, mdsno_t *mds); int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid, mdsno_t mds); +int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid, + struct md_op_data *op_data); int lmv_alloc_slave_fids(struct obd_device *obd, struct lu_fid *pid, struct md_op_data *op, struct lu_fid *fid); diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 7fec591..01c9848 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -729,19 +729,19 @@ static int lmv_fids_balanced(struct obd_device *obd) RETURN(1); } -static int lmv_all_chars_policy(int count, struct qstr *name) +static int lmv_all_chars_policy(int count, const char *name, + int len) { unsigned int c = 0; - unsigned int len = name->len; while (len > 0) - c += name->name[-- len]; + c += name[--len]; c = c % count; return c; } static int lmv_placement_policy(struct obd_device *obd, - struct lu_placement_hint *hint, + struct md_op_data *op_data, mdsno_t *mds) { struct lmv_obd *lmv = &obd->u.lmv; @@ -758,7 +758,7 @@ static int lmv_placement_policy(struct obd_device *obd, * balanced, that is all sequences have more or less equal * number of objects created. */ - obj = lmv_obj_grab(obd, hint->ph_pfid); + obj = lmv_obj_grab(obd, &op_data->op_fid1); if (obj) { struct lu_fid *rpid; int mea_idx; @@ -770,27 +770,28 @@ static int lmv_placement_policy(struct obd_device *obd, */ mea_idx = raw_name2idx(obj->lo_hashtype, obj->lo_objcount, - hint->ph_cname->name, - hint->ph_cname->len); + op_data->op_name, + op_data->op_namelen); rpid = &obj->lo_inodes[mea_idx].li_fid; *mds = obj->lo_inodes[mea_idx].li_mds; lmv_obj_put(obj); rc = 0; - CDEBUG(D_INODE, "The obj "DFID" has been split, got " - "MDS at "LPU64" by name %s\n", PFID(hint->ph_pfid), - *mds, hint->ph_cname->name); - } else if (hint->ph_cname && (hint->ph_opc == LUSTRE_OPC_MKDIR)) { + CDEBUG(D_INODE, "The obj "DFID" has been split, got MDS at " + LPU64" by name %s\n", PFID(&op_data->op_fid1), *mds, + op_data->op_name); + } else if (op_data->op_name && (op_data->op_opc == LUSTRE_OPC_MKDIR)) { /* Default policy for directories. */ *mds = lmv_all_chars_policy(lmv->desc.ld_tgt_count, - hint->ph_cname); + op_data->op_name, + op_data->op_namelen); rc = 0; } else { /* * Default policy for others is to use parent MDS. * ONLY directories can be cross-ref during creation. */ - rc = lmv_fld_lookup(lmv, hint->ph_pfid, mds); + rc = lmv_fld_lookup(lmv, &op_data->op_fid1, mds); } } else { /* @@ -838,8 +839,8 @@ int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid, RETURN(rc); } -static int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid, - struct lu_placement_hint *hint) +int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid, + struct md_op_data *op_data) { struct obd_device *obd = class_exp2obd(exp); struct lmv_obd *lmv = &obd->u.lmv; @@ -847,12 +848,13 @@ static int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid, int rc; ENTRY; - LASSERT(hint != NULL); + LASSERT(op_data != NULL); LASSERT(fid != NULL); - rc = lmv_placement_policy(obd, hint, &mds); + rc = lmv_placement_policy(obd, op_data, &mds); if (rc) { - CERROR("Can't get target for allocating fid, rc %d\n", rc); + CERROR("Can't get target for allocating fid, " + "rc %d\n", rc); RETURN(rc); } @@ -1326,6 +1328,10 @@ repeat: if (IS_ERR(tgt_exp)) RETURN(PTR_ERR(tgt_exp)); + rc = lmv_fid_alloc(exp, &op_data->op_fid2, op_data); + if (rc) + RETURN(rc); + CDEBUG(D_OTHER, "CREATE '%*s' on "DFID"\n", op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1)); @@ -1334,13 +1340,14 @@ repeat: if (rc == 0) { if (*request == NULL) RETURN(rc); - CDEBUG(D_OTHER, "created. "DFID"\n", PFID(&op_data->op_fid1)); + CDEBUG(D_OTHER, "created - "DFID"\n", PFID(&op_data->op_fid1)); } else if (rc == -ERESTART) { LASSERT(*request != NULL); DEBUG_REQ(D_WARNING|D_RPCTRACE, *request, "Got -ERESTART during create!\n"); ptlrpc_req_finished(*request); *request = NULL; + /* * Directory got split. Time to update local object and repeat * the request with proper MDS. @@ -2604,9 +2611,8 @@ struct obd_ops lmv_obd_ops = { .o_packmd = lmv_packmd, .o_unpackmd = lmv_unpackmd, .o_notify = lmv_notify, - .o_fid_alloc = lmv_fid_alloc, - .o_fid_delete = lmv_fid_delete, - .o_iocontrol = lmv_iocontrol + .o_iocontrol = lmv_iocontrol, + .o_fid_delete = lmv_fid_delete }; struct md_ops lmv_md_ops = { diff --git a/lustre/mdc/mdc_internal.h b/lustre/mdc/mdc_internal.h index 22ba601..9d76457 100644 --- a/lustre/mdc/mdc_internal.h +++ b/lustre/mdc/mdc_internal.h @@ -105,6 +105,9 @@ int mdc_enqueue(struct obd_export *exp, void *cb_data, int extra_lock_flags); /* mdc/mdc_request.c */ +int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid, + struct md_op_data *op_data); + int mdc_init_ea_size(struct obd_export *exp, int easize, int def_easzie, int cookiesize); diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index f408d91..1a2f3ac 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -711,6 +711,15 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, * this and use the request from revalidate. In this case, revalidate * never dropped its reference, so the refcounts are all OK */ if (!it_disposition(it, DISP_ENQ_COMPLETE)) { + /* For case if upper layer did not alloc fid, do it now. */ + if (!fid_is_sane(&op_data->op_fid2) && it->it_op & IT_CREAT) { + rc = mdc_fid_alloc(exp, &op_data->op_fid2, op_data); + if (rc < 0) { + CERROR("Can't alloc new fid, rc %d\n", rc); + RETURN(rc); + } + } + rc = mdc_enqueue(exp, LDLM_IBITS, it, it_to_lock_mode(it), op_data, &lockh, lmm, lmmsize, ldlm_completion_ast, cb_blocking, NULL, @@ -718,8 +727,7 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, if (rc < 0) RETURN(rc); memcpy(&it->d.lustre.it_lock_handle, &lockh, sizeof(lockh)); - } else if (!fid_is_sane(&op_data->op_fid2) || - !(it->it_flags & O_CHECK_STALE)) { + } else if (!fid_is_sane(&op_data->op_fid2) || !(it->it_flags & O_CHECK_STALE)) { /* 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 diff --git a/lustre/mdc/mdc_reint.c b/lustre/mdc/mdc_reint.c index d14640a..7aa3a67 100644 --- a/lustre/mdc/mdc_reint.c +++ b/lustre/mdc/mdc_reint.c @@ -135,8 +135,22 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request *req; ENTRY; + /* For case if upper layer did not alloc fid, do it now. */ + if (!fid_is_sane(&op_data->op_fid2)) { + /* + * mdc_fid_alloc() may return errno 1 in case of switch to new + * sequence, handle this. + */ + rc = mdc_fid_alloc(exp, &op_data->op_fid2, op_data); + if (rc < 0) { + CERROR("Can't alloc new fid, rc %d\n", rc); + RETURN(rc); + } + } + size[REQ_REC_OFF + 1] = op_data->op_capa1 ? - sizeof(struct lustre_capa) : 0; + sizeof(struct lustre_capa) : 0; + if (data && datalen) { size[bufcount] = datalen; bufcount++; diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index fd6f504..f420f37 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1381,7 +1381,7 @@ static int mdc_fid_init(struct obd_export *exp) snprintf(prefix, MAX_OBD_NAME + 5, "srv-%s", exp->exp_obd->obd_name); - /* init client side sequence-manager */ + /* Init client side sequence-manager */ rc = seq_client_init(cli->cl_seq, exp, LUSTRE_SEQ_METADATA, prefix, NULL); @@ -1390,7 +1390,6 @@ static int mdc_fid_init(struct obd_export *exp) GOTO(out_free_seq, rc); RETURN(rc); - out_free_seq: OBD_FREE_PTR(cli->cl_seq); cli->cl_seq = NULL; @@ -1411,12 +1410,11 @@ static int mdc_fid_fini(struct obd_export *exp) RETURN(0); } -static int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid, - struct lu_placement_hint *hint) +int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid, + struct md_op_data *op_data) { struct client_obd *cli = &exp->exp_obd->u.cli; struct lu_client_seq *seq = cli->cl_seq; - ENTRY; RETURN(seq_client_alloc_fid(seq, fid)); } diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index fc8df95..58bf8da 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -3469,6 +3469,7 @@ static void mdt_fini(const struct lu_env *env, struct mdt_device *m) mdt_seq_fini(env, m); mdt_seq_fini_cli(m); mdt_fld_fini(env, m); + mdt_procfs_fini(m); ptlrpc_lprocfs_unregister_obd(d->ld_obd); lprocfs_obd_cleanup(d->ld_obd); @@ -3617,18 +3618,24 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m, rc = lu_site_init(s, &m->mdt_md_dev.md_lu_dev); if (rc) { - CERROR("can't init lu_site, rc %d\n", rc); + CERROR("Can't init lu_site, rc %d\n", rc); GOTO(err_free_site, rc); } lprocfs_init_vars(mdt, &lvars); rc = lprocfs_obd_setup(obd, lvars.obd_vars); if (rc) { - CERROR("can't init lprocfs, rc %d\n", rc); + CERROR("Can't init lprocfs, rc %d\n", rc); GOTO(err_fini_site, rc); } ptlrpc_lprocfs_register_obd(obd); + rc = mdt_procfs_init(m, dev); + if (rc) { + CERROR("Can't init MDT lprocfs, rc %d\n", rc); + GOTO(err_fini_proc, rc); + } + /* set server index */ LASSERT(num); s->ls_node_id = simple_strtol(num, NULL, 10); @@ -3636,7 +3643,7 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m, /* init the stack */ rc = mdt_stack_init(env, m, cfg); if (rc) { - CERROR("can't init device stack, rc %d\n", rc); + CERROR("Can't init device stack, rc %d\n", rc); GOTO(err_fini_proc, rc); } @@ -3725,6 +3732,7 @@ err_fini_fld: err_fini_stack: mdt_stack_fini(env, m, md2lu_dev(m->mdt_child)); err_fini_proc: + mdt_procfs_fini(m); lprocfs_obd_cleanup(obd); err_fini_site: lu_site_fini(s); diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index f861722..1cd6068 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -188,6 +188,9 @@ struct mdt_device { struct ptlrpc_thread mdt_ck_thread; struct lustre_capa_key mdt_capa_keys[2]; unsigned int mdt_capa_conf:1; + + cfs_proc_dir_entry_t *mdt_proc_entry; + struct lprocfs_stats *mdt_stats; }; /*XXX copied from mds_internal.h */ @@ -387,6 +390,9 @@ struct mdt_thread_info { struct txn_param mti_txn_param; struct lu_buf mti_buf; struct lustre_capa_key mti_capa_key; + + /* Time for stats */ + struct timeval mti_time; }; /* * Info allocated per-transaction. @@ -703,9 +709,31 @@ static inline ldlm_mode_t mdt_mdl_mode2dlm_mode(mdl_mode_t mode) return mdt_dlm_lock_modes[mode]; } -/* - * Capability - */ +/* lprocfs stuff */ +int mdt_procfs_init(struct mdt_device *mdt, const char *name); +int mdt_procfs_fini(struct mdt_device *mdt); + +void mdt_lprocfs_time_start(struct mdt_device *mdt, + struct timeval *start, int op); + +void mdt_lprocfs_time_end(struct mdt_device *mdt, + struct timeval *start, int op); + +enum { + LPROC_MDT_REINT_CREATE = 0, + LPROC_MDT_REINT_OPEN, + LPROC_MDT_REINT_LINK, + LPROC_MDT_REINT_UNLINK, + LPROC_MDT_REINT_RENAME, + LPROC_MDT_REINT_SETATTR, + LPROC_MDT_GETATTR, + LPROC_MDT_GETATTR_NAME, + LPROC_MDT_INTENT_GETATTR, + LPROC_MDT_INTENT_REINT, + LPROC_MDT_LAST +}; + +/* Capability */ int mdt_ck_thread_start(struct mdt_device *mdt); void mdt_ck_thread_stop(struct mdt_device *mdt); void mdt_ck_timer_callback(unsigned long castmeharder); diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index 00b2511..527c9b6 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -54,6 +54,95 @@ #include #include "mdt_internal.h" +static int mdt_procfs_init_stats(struct mdt_device *mdt, int num_stats) +{ + struct lprocfs_stats *stats; + int rc; + ENTRY; + + stats = lprocfs_alloc_stats(num_stats); + if (!stats) + RETURN(-ENOMEM); + + rc = lprocfs_register_stats(mdt->mdt_proc_entry, "stats", stats); + if (rc != 0) + GOTO(cleanup, rc); + + mdt->mdt_stats = stats; + + lprocfs_counter_init(mdt->mdt_stats, LPROC_MDT_REINT_CREATE, + LPROCFS_CNTR_AVGMINMAX, "reint_create", "time"); + lprocfs_counter_init(mdt->mdt_stats, LPROC_MDT_REINT_OPEN, + LPROCFS_CNTR_AVGMINMAX, "reint_open", "time"); + lprocfs_counter_init(mdt->mdt_stats, LPROC_MDT_REINT_LINK, + LPROCFS_CNTR_AVGMINMAX, "reint_link", "time"); + lprocfs_counter_init(mdt->mdt_stats, LPROC_MDT_REINT_UNLINK, + LPROCFS_CNTR_AVGMINMAX, "reint_unlink", "time"); + lprocfs_counter_init(mdt->mdt_stats, LPROC_MDT_REINT_SETATTR, + LPROCFS_CNTR_AVGMINMAX, "reint_setattr", "time"); + lprocfs_counter_init(mdt->mdt_stats, LPROC_MDT_REINT_RENAME, + LPROCFS_CNTR_AVGMINMAX, "reint_rename", "time"); + lprocfs_counter_init(mdt->mdt_stats, LPROC_MDT_GETATTR, + LPROCFS_CNTR_AVGMINMAX, "getattr", "time"); + lprocfs_counter_init(mdt->mdt_stats, LPROC_MDT_GETATTR_NAME, + LPROCFS_CNTR_AVGMINMAX, "getattr_name", "time"); + lprocfs_counter_init(mdt->mdt_stats, LPROC_MDT_INTENT_GETATTR, + LPROCFS_CNTR_AVGMINMAX, "intent_getattr", "time"); + lprocfs_counter_init(mdt->mdt_stats, LPROC_MDT_INTENT_REINT, + LPROCFS_CNTR_AVGMINMAX, "intent_reint", "time"); + EXIT; +cleanup: + if (rc) { + lprocfs_free_stats(stats); + mdt->mdt_stats = NULL; + } + return rc; +} + +int mdt_procfs_init(struct mdt_device *mdt, const char *name) +{ + struct lu_device *ld = &mdt->mdt_md_dev.md_lu_dev; + int rc; + ENTRY; + + LASSERT(name != NULL); + mdt->mdt_proc_entry = ld->ld_obd->obd_proc_entry; + LASSERT(mdt->mdt_proc_entry != NULL); + + rc = mdt_procfs_init_stats(mdt, LPROC_MDT_LAST); + return rc; +} + +int mdt_procfs_fini(struct mdt_device *mdt) +{ + if (mdt->mdt_stats) { + lprocfs_free_stats(mdt->mdt_stats); + mdt->mdt_stats = NULL; + } + if (mdt->mdt_proc_entry) + mdt->mdt_proc_entry = NULL; + RETURN(0); +} + +void mdt_lprocfs_time_start(struct mdt_device *mdt, + struct timeval *start, int op) +{ + do_gettimeofday(start); +} + +void mdt_lprocfs_time_end(struct mdt_device *mdt, + struct timeval *start, int op) +{ + struct timeval end; + long timediff; + + do_gettimeofday(&end); + timediff = cfs_timeval_sub(&end, start, NULL); + + if (mdt->mdt_stats) + lprocfs_counter_add(mdt->mdt_stats, op, timediff); + return; +} static int lprocfs_rd_identity_expire(char *page, char **start, off_t off, int count, int *eof, void *data) @@ -469,8 +558,9 @@ static inline void remove_newline(char *str) str[len - 1] = '\0'; } -/* FIXME: this macro is copied from lnet/libcfs/nidstring.c */ +/* XXX: This macro is copied from lnet/libcfs/nidstring.c */ #define LNET_NIDSTR_SIZE 32 /* size of each one (see below for usage) */ + static void do_process_nosquash_nids(struct mdt_device *m, char *buf) { struct rootsquash_info *rsi = m->mdt_rootsquash_info; diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 3c8297b..7cdf67e 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -712,25 +712,26 @@ static int mdt_cross_open(struct mdt_thread_info* info, int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) { - struct mdt_device *mdt = info->mti_mdt; - struct ptlrpc_request *req = mdt_info_req(info); - struct mdt_object *parent; - struct mdt_object *child; - struct mdt_lock_handle *lh; - struct ldlm_reply *ldlm_rep; - struct mdt_body *repbody; - struct lu_fid *child_fid = &info->mti_tmp_fid1; - struct md_attr *ma = &info->mti_attr; - struct lu_attr *la = &ma->ma_attr; - __u32 create_flags = info->mti_spec.sp_cr_flags; + struct mdt_device *mdt = info->mti_mdt; + struct ptlrpc_request *req = mdt_info_req(info); + struct mdt_object *parent; + struct mdt_object *child; + struct mdt_lock_handle *lh; + struct ldlm_reply *ldlm_rep; + struct mdt_body *repbody; + struct lu_fid *child_fid = &info->mti_tmp_fid1; + struct md_attr *ma = &info->mti_attr; + struct lu_attr *la = &ma->ma_attr; + __u32 create_flags = info->mti_spec.sp_cr_flags; struct mdt_reint_record *rr = &info->mti_rr; - int result; - int created = 0; + int result; + int created = 0; ENTRY; OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_PAUSE_OPEN | OBD_FAIL_ONCE, (obd_timeout + 1) / 4); + mdt_lprocfs_time_start(info->mti_mdt, &info->mti_time, LPROC_MDT_REINT_OPEN); repbody = req_capsule_server_get(&info->mti_pill, &RMF_MDT_BODY); ma->ma_lmm = req_capsule_server_get(&info->mti_pill, &RMF_MDT_MD); @@ -935,6 +936,8 @@ out: mdt_shrink_reply(info, DLM_REPLY_REC_OFF + 1, 1, 1); if (result) lustre_msg_set_transno(req->rq_repmsg, 0); + mdt_lprocfs_time_end(info->mti_mdt, &info->mti_time, + LPROC_MDT_REINT_OPEN); return result; } diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index 87971bb..13af10c 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -319,6 +319,9 @@ static int mdt_reint_create(struct mdt_thread_info *info, int rc; ENTRY; + mdt_lprocfs_time_start(info->mti_mdt, &info->mti_time, + LPROC_MDT_REINT_CREATE); + if (MDT_FAIL_CHECK(OBD_FAIL_MDS_REINT_CREATE)) RETURN(err_serious(-ESTALE)); @@ -344,6 +347,8 @@ static int mdt_reint_create(struct mdt_thread_info *info, default: rc = err_serious(-EOPNOTSUPP); } + mdt_lprocfs_time_end(info->mti_mdt, &info->mti_time, + LPROC_MDT_REINT_CREATE); RETURN(rc); } -- 1.8.3.1