From: Lai Siyao Date: Fri, 31 Jul 2020 18:09:06 +0000 (+0800) Subject: LU-13852 pcc: don't alloc FID in LLITE for pcc open X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=697da2dfdff61e00fafd3b20f03436ecc7e02385;p=fs%2Flustre-release.git LU-13852 pcc: don't alloc FID in LLITE for pcc open ll_lookup_it(IT_OPEN) always alloc FID on MDT0 for pcc open, but the open request is sent to MDT where the name hash points to, which may be different from the MDT where the FID is, which will trigger osp_md_create() assertion because file is created remotely. This FID allocation is not necessary, and it can be left to be done in lmv_intent_open() by LMV layer, because the MDT is chosen in LMV. Then when it's done, the FID allocated can be used to initialize PCC inode. Change assertion in osp_md_create() to error message and return error. Update sanity-sec 2a for this. Lustre-change: https://review.whamcloud.com/39568 Lustre-commit: 223728a97c397e6e6c91808dd36a2539705f00b8 Signed-off-by: Lai Siyao Change-Id: I3ccea3f9e7cca5083695c71135b9a5805f833b14 Reviewed-by: Yingjin Qian Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Reviewed-on: https://review.whamcloud.com/44455 Tested-by: jenkins Tested-by: Maloo --- diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 72fd9fc..033e4e7 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -893,8 +893,6 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, } if (pca && pca->pca_dataset) { - struct pcc_dataset *dataset = pca->pca_dataset; - OBD_ALLOC_PTR(lum); if (lum == NULL) GOTO(out, retval = ERR_PTR(-ENOMEM)); @@ -903,18 +901,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, lum->lmm_pattern = LOV_PATTERN_F_RELEASED | LOV_PATTERN_RAID0; op_data->op_data = lum; op_data->op_data_size = sizeof(*lum); - op_data->op_archive_id = dataset->pccd_rwid; - - rc = obd_fid_alloc(NULL, ll_i2mdexp(parent), &op_data->op_fid2, - op_data); - if (rc) - GOTO(out, retval = ERR_PTR(rc)); - - rc = pcc_inode_create(parent->i_sb, dataset, &op_data->op_fid2, - &pca->pca_dentry); - if (rc) - GOTO(out, retval = ERR_PTR(rc)); - + op_data->op_archive_id = pca->pca_dataset->pccd_rwid; it->it_flags |= MDS_OPEN_PCC; } @@ -949,6 +936,14 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, if (rc < 0) GOTO(out, retval = ERR_PTR(rc)); + if (pca && pca->pca_dataset) { + rc = pcc_inode_create(parent->i_sb, pca->pca_dataset, + &op_data->op_fid2, + &pca->pca_dentry); + if (rc) + GOTO(out, retval = ERR_PTR(rc)); + } + /* dir layout may change */ ll_unlock_md_op_lsm(op_data); rc = ll_lookup_it_finish(req, it, parent, &dentry, diff --git a/lustre/lmv/lmv_intent.c b/lustre/lmv/lmv_intent.c index de2b425..5a2212c 100644 --- a/lustre/lmv/lmv_intent.c +++ b/lustre/lmv/lmv_intent.c @@ -347,8 +347,7 @@ retry: op_data->op_mds = tgt->ltd_index; } else { LASSERT(fid_is_sane(&op_data->op_fid1)); - LASSERT(it->it_flags & MDS_OPEN_PCC || - fid_is_zero(&op_data->op_fid2)); + LASSERT(fid_is_zero(&op_data->op_fid2)); LASSERT(op_data->op_name != NULL); tgt = lmv_locate_tgt(lmv, op_data); @@ -358,8 +357,7 @@ retry: /* If it is ready to open the file by FID, do not need * allocate FID at all, otherwise it will confuse MDT */ - if ((it->it_op & IT_CREAT) && !(it->it_flags & MDS_OPEN_BY_FID || - it->it_flags & MDS_OPEN_PCC)) { + if ((it->it_op & IT_CREAT) && !(it->it_flags & MDS_OPEN_BY_FID)) { /* * For lookup(IT_CREATE) cases allocate new fid and setup FLD * for it. diff --git a/lustre/osp/osp_md_object.c b/lustre/osp/osp_md_object.c index b607b78..f7f686a 100644 --- a/lustre/osp/osp_md_object.c +++ b/lustre/osp/osp_md_object.c @@ -164,7 +164,12 @@ int osp_md_create(const struct lu_env *env, struct dt_object *dt, update = thandle_to_osp_update_request(th); LASSERT(update != NULL); - LASSERT(attr->la_valid & LA_TYPE); + if (!(attr->la_valid & LA_TYPE)) { + CERROR("%s: create type not specified: valid %llx\n", + dt->do_lu.lo_dev->ld_obd->obd_name, attr->la_valid); + GOTO(out, rc = -EINVAL); + } + rc = OSP_UPDATE_RPC_PACK(env, out_create_pack, update, lu_object_fid(&dt->do_lu), attr, hint, dof); if (rc != 0) diff --git a/lustre/tests/sanity-pcc.sh b/lustre/tests/sanity-pcc.sh index a1cbb87..7f3c6e4 100644 --- a/lustre/tests/sanity-pcc.sh +++ b/lustre/tests/sanity-pcc.sh @@ -522,7 +522,7 @@ test_2a() { copytool setup -m "$MOUNT" -a "$HSM_ARCHIVE_NUMBER" setup_pcc_mapping file=$DIR/$tdir/multiop - mkdir -p $DIR/$tdir + $LFS mkdir -i -1 -c $MDSCOUNT $DIR/$tdir rm -f $file do_facet $SINGLEAGT $LFS project -sp $project_id $DIR/$tdir ||