From: Mikhal Pershin Date: Tue, 5 Dec 2017 20:10:02 +0000 (+0300) Subject: LU-10318 dom: support DATA_VERSION IO type X-Git-Tag: 2.10.59~57 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=1e7fc14bbf48f7e89876cbaa609972981e343944 LU-10318 dom: support DATA_VERSION IO type add support for DATA_VERSION IO type, return from MDT data version and layout version if requested by CLIO. Also ensure that version is changed on punch and write operations. This fixes HSM archive with DOM files. Change-Id: Id7b63697ffc48c889370638682625ea04a0348c5 Signed-off-by: Mikhail Pershin Reviewed-on: https://review.whamcloud.com/30449 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lu_target.h b/lustre/include/lu_target.h index 25e75f8..948d01b 100644 --- a/lustre/include/lu_target.h +++ b/lustre/include/lu_target.h @@ -431,6 +431,7 @@ void tgt_io_thread_done(struct ptlrpc_thread *thread); int tgt_mdt_data_lock(struct ldlm_namespace *ns, struct ldlm_res_id *res_id, struct lustre_handle *lh, int mode, __u64 *flags); +void tgt_mdt_data_unlock(struct lustre_handle *lh, enum ldlm_mode mode); int tgt_extent_lock(struct ldlm_namespace *ns, struct ldlm_res_id *res_id, __u64 start, __u64 end, struct lustre_handle *lh, int mode, __u64 *flags); diff --git a/lustre/include/uapi/linux/lustre/lustre_idl.h b/lustre/include/uapi/linux/lustre/lustre_idl.h index f73ae38..017931c9 100644 --- a/lustre/include/uapi/linux/lustre/lustre_idl.h +++ b/lustre/include/uapi/linux/lustre/lustre_idl.h @@ -1731,7 +1731,7 @@ struct mdt_body { __s64 mbo_atime; __s64 mbo_ctime; __u64 mbo_blocks; /* XID, in the case of MDS_READPAGE */ - __u64 mbo_ioepoch; + __u64 mbo_version; /* was mbo_ioepoch before 2.11 */ __u64 mbo_t_state; /* transient file state defined in * enum md_transient_state * was "ino" until 2.4.0 */ @@ -1744,7 +1744,7 @@ struct mdt_body { __u32 mbo_flags; /* LUSTRE_*_FL file attributes */ __u32 mbo_rdev; __u32 mbo_nlink; /* #bytes to read in the case of MDS_READPAGE */ - __u32 mbo_unused2; /* was "generation" until 2.4.0 */ + __u32 mbo_layout_gen; /* was "generation" until 2.4.0 */ __u32 mbo_suppgid; __u32 mbo_eadatasize; __u32 mbo_aclsize; diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index f4675e8..ea3282f 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -490,9 +490,8 @@ struct fsxattr { static inline bool lov_pattern_supported(__u32 pattern) { - return pattern == LOV_PATTERN_RAID0 || - pattern == LOV_PATTERN_MDT || - pattern == (LOV_PATTERN_RAID0 | LOV_PATTERN_F_RELEASED); + return (pattern & ~LOV_PATTERN_F_RELEASED) == LOV_PATTERN_RAID0 || + (pattern & ~LOV_PATTERN_F_RELEASED) == LOV_PATTERN_MDT; } #define LOV_MAXPOOLNAME 15 diff --git a/lustre/mdc/mdc_dev.c b/lustre/mdc/mdc_dev.c index 444f919..0ebc4ef 100644 --- a/lustre/mdc/mdc_dev.c +++ b/lustre/mdc/mdc_dev.c @@ -1138,6 +1138,124 @@ int mdc_io_fsync_start(const struct lu_env *env, RETURN(result); } +struct mdc_data_version_args { + struct osc_io *dva_oio; +}; + +static int +mdc_data_version_interpret(const struct lu_env *env, struct ptlrpc_request *req, + void *arg, int rc) +{ + struct mdc_data_version_args *dva = arg; + struct osc_io *oio = dva->dva_oio; + const struct mdt_body *body; + + ENTRY; + if (rc < 0) + GOTO(out, rc); + + body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); + if (body == NULL) + GOTO(out, rc = -EPROTO); + + /* Prepare OBDO from mdt_body for CLIO */ + oio->oi_oa.o_valid = body->mbo_valid; + oio->oi_oa.o_flags = body->mbo_flags; + oio->oi_oa.o_data_version = body->mbo_version; + oio->oi_oa.o_layout_version = body->mbo_layout_gen; + EXIT; +out: + oio->oi_cbarg.opc_rc = rc; + complete(&oio->oi_cbarg.opc_sync); + return 0; +} + +static int mdc_io_data_version_start(const struct lu_env *env, + const struct cl_io_slice *slice) +{ + struct cl_data_version_io *dv = &slice->cis_io->u.ci_data_version; + struct osc_io *oio = cl2osc_io(env, slice); + struct osc_async_cbargs *cbargs = &oio->oi_cbarg; + struct osc_object *obj = cl2osc(slice->cis_obj); + struct obd_export *exp = osc_export(obj); + struct ptlrpc_request *req; + struct mdt_body *body; + struct mdc_data_version_args *dva; + int rc; + + ENTRY; + + memset(&oio->oi_oa, 0, sizeof(oio->oi_oa)); + oio->oi_oa.o_oi.oi_fid = *lu_object_fid(osc2lu(obj)); + oio->oi_oa.o_valid = OBD_MD_FLID; + + init_completion(&cbargs->opc_sync); + + req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR); + if (req == NULL) + RETURN(-ENOMEM); + + rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR); + if (rc < 0) { + ptlrpc_request_free(req); + RETURN(rc); + } + + body = req_capsule_client_get(&req->rq_pill, &RMF_MDT_BODY); + body->mbo_fid1 = *lu_object_fid(osc2lu(obj)); + body->mbo_valid = OBD_MD_FLID; + /* Indicate that data version is needed */ + body->mbo_valid |= OBD_MD_FLDATAVERSION; + body->mbo_flags = 0; + + if (dv->dv_flags & (LL_DV_RD_FLUSH | LL_DV_WR_FLUSH)) { + body->mbo_valid |= OBD_MD_FLFLAGS; + body->mbo_flags |= OBD_FL_SRVLOCK; + if (dv->dv_flags & LL_DV_WR_FLUSH) + body->mbo_flags |= OBD_FL_FLUSH; + } + + req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, 0); + req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER, 0); + ptlrpc_request_set_replen(req); + + req->rq_interpret_reply = mdc_data_version_interpret; + CLASSERT(sizeof(*dva) <= sizeof(req->rq_async_args)); + dva = ptlrpc_req_async_args(req); + dva->dva_oio = oio; + + ptlrpcd_add_req(req); + + RETURN(0); +} + +static void mdc_io_data_version_end(const struct lu_env *env, + const struct cl_io_slice *slice) +{ + struct cl_data_version_io *dv = &slice->cis_io->u.ci_data_version; + struct osc_io *oio = cl2osc_io(env, slice); + struct osc_async_cbargs *cbargs = &oio->oi_cbarg; + + ENTRY; + wait_for_completion(&cbargs->opc_sync); + + if (cbargs->opc_rc != 0) { + slice->cis_io->ci_result = cbargs->opc_rc; + } else { + slice->cis_io->ci_result = 0; + if (!(oio->oi_oa.o_valid & + (OBD_MD_LAYOUT_VERSION | OBD_MD_FLDATAVERSION))) + slice->cis_io->ci_result = -ENOTSUPP; + + if (oio->oi_oa.o_valid & OBD_MD_LAYOUT_VERSION) + dv->dv_layout_version = oio->oi_oa.o_layout_version; + if (oio->oi_oa.o_valid & OBD_MD_FLDATAVERSION) + dv->dv_data_version = oio->oi_oa.o_data_version; + } + + EXIT; +} + static struct cl_io_operations mdc_io_ops = { .op = { [CIT_READ] = { @@ -1157,10 +1275,9 @@ static struct cl_io_operations mdc_io_ops = { .cio_start = mdc_io_setattr_start, .cio_end = osc_io_setattr_end, }, - /* no support for data version so far */ [CIT_DATA_VERSION] = { - .cio_start = NULL, - .cio_end = NULL, + .cio_start = mdc_io_data_version_start, + .cio_end = mdc_io_data_version_end, }, [CIT_FAULT] = { .cio_iter_init = osc_io_iter_init, diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 7bdbc11..201421c 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -720,7 +720,6 @@ int mdc_set_open_replay_data(struct obd_export *exp, } rec->cr_fid2 = body->mbo_fid1; - rec->cr_ioepoch = body->mbo_ioepoch; rec->cr_old_handle.cookie = body->mbo_handle.cookie; open_req->rq_replay_cb = mdc_replay_open; if (!fid_is_sane(&body->mbo_fid1)) { diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 8ff002c..267f469f 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -1304,6 +1304,12 @@ static int mdt_getattr(struct tgt_session_info *tsi) LASSERT(obj != NULL); LASSERT(lu_object_assert_exists(&obj->mot_obj)); + /* Special case for Data-on-MDT files to get data version */ + if (unlikely(reqbody->mbo_valid & OBD_MD_FLDATAVERSION)) { + rc = mdt_data_version_get(tsi); + GOTO(out, rc); + } + /* Unlike intent case where we need to pre-fill out buffers early on * in intent policy for ldlm reasons, here we can have a much better * guess at EA size by just reading it from disk. @@ -1313,7 +1319,6 @@ static int mdt_getattr(struct tgt_session_info *tsi) /* No easy way to know how long is the symlink, but it cannot * be more than PATH_MAX, so we allocate +1 */ rc = PATH_MAX + 1; - /* A special case for fs ROOT: getattr there might fetch * default EA for entire fs, not just for this dir! */ @@ -1357,12 +1362,12 @@ static int mdt_getattr(struct tgt_session_info *tsi) info->mti_cross_ref = !!(reqbody->mbo_valid & OBD_MD_FLCROSSREF); rc = mdt_getattr_internal(info, obj, 0); - EXIT; + EXIT; out_shrink: - mdt_client_compatibility(info); - rc2 = mdt_fix_reply(info); - if (rc == 0) - rc = rc2; + mdt_client_compatibility(info); + rc2 = mdt_fix_reply(info); + if (rc == 0) + rc = rc2; out: mdt_thread_info_fini(info); return rc; diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index f12fb79..75e159e 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -639,31 +639,34 @@ static inline int mdt_lmm_dom_entry(struct lov_mds_md *lmm) { struct lov_comp_md_v1 *comp_v1; struct lov_mds_md *v1; + __u32 off; int i; - if (lmm->lmm_magic == LOV_MAGIC_COMP_V1) { - comp_v1 = (struct lov_comp_md_v1 *)lmm; - v1 = (struct lov_mds_md *)((char *)comp_v1 + - comp_v1->lcm_entries[0].lcme_offset); - /* DoM entry is the first entry always */ - if (lov_pattern(v1->lmm_pattern) != LOV_PATTERN_MDT) - return LMM_NO_DOM; - - for (i = 1; i < comp_v1->lcm_entry_count; i++) { - int j; - - v1 = (struct lov_mds_md *)((char *)comp_v1 + - comp_v1->lcm_entries[i].lcme_offset); - for (j = 0; j < v1->lmm_stripe_count; j++) { - /* if there is any object on OST */ - if (v1->lmm_objects[j].l_ost_idx != - (__u32)-1UL) - return LMM_DOM_OST; - } + if (le32_to_cpu(lmm->lmm_magic) != LOV_MAGIC_COMP_V1) + return LMM_NO_DOM; + + comp_v1 = (struct lov_comp_md_v1 *)lmm; + off = le32_to_cpu(comp_v1->lcm_entries[0].lcme_offset); + v1 = (struct lov_mds_md *)((char *)comp_v1 + off); + + /* DoM entry is the first entry always */ + if (lov_pattern(le32_to_cpu(v1->lmm_pattern)) != LOV_PATTERN_MDT) + return LMM_NO_DOM; + + for (i = 1; i < le16_to_cpu(comp_v1->lcm_entry_count); i++) { + int j; + + off = le32_to_cpu(comp_v1->lcm_entries[i].lcme_offset); + v1 = (struct lov_mds_md *)((char *)comp_v1 + off); + + for (j = 0; j < le16_to_cpu(v1->lmm_stripe_count); j++) { + /* if there is any object on OST */ + if (le32_to_cpu(v1->lmm_objects[j].l_ost_idx) != + (__u32)-1UL) + return LMM_DOM_OST; } - return LMM_DOM_ONLY; } - return LMM_NO_DOM; + return LMM_DOM_ONLY; } static inline bool mdt_lmm_is_flr(struct lov_mds_md *lmm) @@ -1253,6 +1256,7 @@ bool mdt_dom_client_has_lock(struct mdt_thread_info *info, const struct lu_fid *fid); void mdt_hp_brw(struct tgt_session_info *tsi); void mdt_hp_punch(struct tgt_session_info *tsi); +int mdt_data_version_get(struct tgt_session_info *tsi); /* grants */ long mdt_grant_connect(const struct lu_env *env, struct obd_export *exp, diff --git a/lustre/mdt/mdt_io.c b/lustre/mdt/mdt_io.c index 637f5ee..dfeb102 100644 --- a/lustre/mdt/mdt_io.c +++ b/lustre/mdt/mdt_io.c @@ -574,6 +574,7 @@ retry: GOTO(out_stop, rc); } + tgt_vbr_obj_set(env, dob); rc = dt_trans_start(env, dt, th); if (rc) GOTO(out_stop, rc); @@ -1236,3 +1237,98 @@ bool mdt_dom_client_has_lock(struct mdt_thread_info *info, return rc; } +/** + * MDT request handler for OST_GETATTR RPC. + * + * This is data-specific request to get object and layout versions under + * IO lock. It is reliable only for Data-on-MDT files. + * + * \param[in] tsi target session environment for this request + * + * \retval 0 if successful + * \retval negative value on error + */ +int mdt_data_version_get(struct tgt_session_info *tsi) +{ + struct mdt_thread_info *mti = mdt_th_info(tsi->tsi_env); + struct mdt_device *mdt = mti->mti_mdt; + struct mdt_body *repbody; + struct mdt_object *mo = mti->mti_object; + struct lov_comp_md_v1 *comp; + struct lustre_handle lh = { 0 }; + __u64 flags = 0; + __s64 version; + enum ldlm_mode lock_mode = LCK_PR; + bool srvlock; + int rc; + + ENTRY; + + req_capsule_set_size(tsi->tsi_pill, &RMF_MDT_MD, RCL_SERVER, 0); + req_capsule_set_size(tsi->tsi_pill, &RMF_ACL, RCL_SERVER, 0); + rc = req_capsule_server_pack(tsi->tsi_pill); + if (unlikely(rc != 0)) + RETURN(err_serious(rc)); + + repbody = req_capsule_server_get(tsi->tsi_pill, &RMF_MDT_BODY); + if (repbody == NULL) + RETURN(-ENOMEM); + + srvlock = tsi->tsi_mdt_body->mbo_valid & OBD_MD_FLFLAGS && + tsi->tsi_mdt_body->mbo_flags & OBD_FL_SRVLOCK; + + if (srvlock) { + if (unlikely(tsi->tsi_mdt_body->mbo_flags & OBD_FL_FLUSH)) + lock_mode = LCK_PW; + + fid_build_reg_res_name(&tsi->tsi_fid, &tsi->tsi_resid); + rc = tgt_mdt_data_lock(mdt->mdt_namespace, &tsi->tsi_resid, + &lh, lock_mode, &flags); + if (rc != 0) + RETURN(rc); + } + + if (!mdt_object_exists(mo)) + GOTO(out, rc = -ENOENT); + if (mdt_object_remote(mo)) + GOTO(out, rc = -EREMOTE); + if (!S_ISREG(lu_object_attr(&mo->mot_obj))) + GOTO(out, rc = -EBADF); + + /* Get version first */ + version = dt_version_get(tsi->tsi_env, mdt_obj2dt(mo)); + if (version && version != -EOPNOTSUPP) { + repbody->mbo_valid |= OBD_MD_FLDATAVERSION; + /* re-use mbo_ioepoch to transfer version */ + repbody->mbo_version = version; + } + + /* Read layout to get its version */ + rc = mdt_big_xattr_get(mti, mo, XATTR_NAME_LOV); + if (rc == -ENODATA) /* File has no layout yet */ + GOTO(out, rc = 0); + else if (rc < 0) + GOTO(out, rc); + + comp = mti->mti_buf.lb_buf; + if (le32_to_cpu(comp->lcm_magic) != LOV_MAGIC_COMP_V1) { + CDEBUG(D_INFO, DFID" has no composite layout", + PFID(&tsi->tsi_fid)); + GOTO(out, rc = -ESTALE); + } + + CDEBUG(D_INODE, DFID": layout version: %u\n", + PFID(&tsi->tsi_fid), le32_to_cpu(comp->lcm_layout_gen)); + + repbody->mbo_valid |= OBD_MD_LAYOUT_VERSION; + /* re-use mbo_rdev for that */ + repbody->mbo_layout_gen = le32_to_cpu(comp->lcm_layout_gen); + rc = 0; +out: + if (srvlock) + tgt_mdt_data_unlock(&lh, lock_mode); + + repbody->mbo_valid |= OBD_MD_FLFLAGS; + repbody->mbo_flags = OBD_FL_FLUSH; + RETURN(rc); +} diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 4781872..d09ea4e 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -1871,7 +1871,7 @@ void lustre_swab_mdt_body (struct mdt_body *b) __swab64s(&b->mbo_atime); __swab64s(&b->mbo_ctime); __swab64s(&b->mbo_blocks); - __swab64s(&b->mbo_ioepoch); + __swab64s(&b->mbo_version); __swab64s(&b->mbo_t_state); __swab32s(&b->mbo_fsuid); __swab32s(&b->mbo_fsgid); @@ -1882,7 +1882,7 @@ void lustre_swab_mdt_body (struct mdt_body *b) __swab32s(&b->mbo_flags); __swab32s(&b->mbo_rdev); __swab32s(&b->mbo_nlink); - CLASSERT(offsetof(typeof(*b), mbo_unused2) != 0); + __swab32s(&b->mbo_layout_gen); __swab32s(&b->mbo_suppgid); __swab32s(&b->mbo_eadatasize); __swab32s(&b->mbo_aclsize); diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index d6b1219..0ce53d0 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -774,10 +774,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lustre_msg_v2, lm_buflens[0])); LASSERTF((int)sizeof(((struct lustre_msg_v2 *)0)->lm_buflens[0]) == 4, "found %lld\n", (long long)(int)sizeof(((struct lustre_msg_v2 *)0)->lm_buflens[0])); - LASSERTF(LUSTRE_MSG_MAGIC_V2 == 0x0BD00BD3, "found 0x%.8x\n", - LUSTRE_MSG_MAGIC_V2); - LASSERTF(LUSTRE_MSG_MAGIC_V2_SWABBED == 0xD30BD00B, "found 0x%.8x\n", - LUSTRE_MSG_MAGIC_V2_SWABBED); + LASSERTF(LUSTRE_MSG_MAGIC_V2 == 0x0bd00bd3UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_MSG_MAGIC_V2); + LASSERTF(LUSTRE_MSG_MAGIC_V2_SWABBED == 0xd30bd00bUL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_MSG_MAGIC_V2_SWABBED); /* Checks for struct ptlrpc_body */ LASSERTF((int)sizeof(struct ptlrpc_body_v3) == 184, "found %lld\n", @@ -992,22 +992,22 @@ void lustre_assert_wire_constants(void) (long long)DLM_REPLY_REC_OFF); LASSERTF(MSG_PTLRPC_HEADER_OFF == 31, "found %lld\n", (long long)MSG_PTLRPC_HEADER_OFF); - LASSERTF(PTLRPC_MSG_VERSION == 0x00000003, "found 0x%.8x\n", - PTLRPC_MSG_VERSION); - LASSERTF(LUSTRE_VERSION_MASK == 0xffff0000, "found 0x%.8x\n", - LUSTRE_VERSION_MASK); - LASSERTF(LUSTRE_OBD_VERSION == 0x00010000, "found 0x%.8x\n", - LUSTRE_OBD_VERSION); - LASSERTF(LUSTRE_MDS_VERSION == 0x00020000, "found 0x%.8x\n", - LUSTRE_MDS_VERSION); - LASSERTF(LUSTRE_OST_VERSION == 0x00030000, "found 0x%.8x\n", - LUSTRE_OST_VERSION); - LASSERTF(LUSTRE_DLM_VERSION == 0x00040000, "found 0x%.8x\n", - LUSTRE_DLM_VERSION); - LASSERTF(LUSTRE_LOG_VERSION == 0x00050000, "found 0x%.8x\n", - LUSTRE_LOG_VERSION); - LASSERTF(LUSTRE_MGS_VERSION == 0x00060000, "found 0x%.8x\n", - LUSTRE_MGS_VERSION); + LASSERTF(PTLRPC_MSG_VERSION == 0x00000003UL, "found 0x%.8xUL\n", + (unsigned)PTLRPC_MSG_VERSION); + LASSERTF(LUSTRE_VERSION_MASK == 0xffff0000UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_VERSION_MASK); + LASSERTF(LUSTRE_OBD_VERSION == 0x00010000UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_OBD_VERSION); + LASSERTF(LUSTRE_MDS_VERSION == 0x00020000UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_MDS_VERSION); + LASSERTF(LUSTRE_OST_VERSION == 0x00030000UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_OST_VERSION); + LASSERTF(LUSTRE_DLM_VERSION == 0x00040000UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_DLM_VERSION); + LASSERTF(LUSTRE_LOG_VERSION == 0x00050000UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_LOG_VERSION); + LASSERTF(LUSTRE_MGS_VERSION == 0x00060000UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_MGS_VERSION); LASSERTF(MSGHDR_AT_SUPPORT == 1, "found %lld\n", (long long)MSGHDR_AT_SUPPORT); LASSERTF(MSGHDR_CKSUM_INCOMPAT18 == 2, "found %lld\n", @@ -2199,6 +2199,37 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct ll_fid *)0)->f_type) == 4, "found %lld\n", (long long)(int)sizeof(((struct ll_fid *)0)->f_type)); + LASSERTF(MDS_CHECK_SPLIT == 0x00000001UL, "found 0x%.8xUL\n", + (unsigned)MDS_CHECK_SPLIT); + LASSERTF(MDS_CROSS_REF == 0x00000002UL, "found 0x%.8xUL\n", + (unsigned)MDS_CROSS_REF); + LASSERTF(MDS_VTX_BYPASS == 0x00000004UL, "found 0x%.8xUL\n", + (unsigned)MDS_VTX_BYPASS); + LASSERTF(MDS_PERM_BYPASS == 0x00000008UL, "found 0x%.8xUL\n", + (unsigned)MDS_PERM_BYPASS); + LASSERTF(MDS_QUOTA_IGNORE == 0x00000020UL, "found 0x%.8xUL\n", + (unsigned)MDS_QUOTA_IGNORE); + LASSERTF(MDS_KEEP_ORPHAN == 0x00000080UL, "found 0x%.8xUL\n", + (unsigned)MDS_KEEP_ORPHAN); + LASSERTF(MDS_RECOV_OPEN == 0x00000100UL, "found 0x%.8xUL\n", + (unsigned)MDS_RECOV_OPEN); + LASSERTF(MDS_DATA_MODIFIED == 0x00000200UL, "found 0x%.8xUL\n", + (unsigned)MDS_DATA_MODIFIED); + LASSERTF(MDS_CREATE_VOLATILE == 0x00000400UL, "found 0x%.8xUL\n", + (unsigned)MDS_CREATE_VOLATILE); + LASSERTF(MDS_OWNEROVERRIDE == 0x00000800UL, "found 0x%.8xUL\n", + (unsigned)MDS_OWNEROVERRIDE); + LASSERTF(MDS_HSM_RELEASE == 0x00001000UL, "found 0x%.8xUL\n", + (unsigned)MDS_HSM_RELEASE); + LASSERTF(MDS_CLOSE_LAYOUT_SWAP == 0x00004000UL, "found 0x%.8xUL\n", + (unsigned)MDS_CLOSE_LAYOUT_SWAP); + LASSERTF(MDS_CLOSE_LAYOUT_MERGE == 0x00008000UL, "found 0x%.8xUL\n", + (unsigned)MDS_CLOSE_LAYOUT_MERGE); + LASSERTF(MDS_CLOSE_RESYNC_DONE == 0x00010000UL, "found 0x%.8xUL\n", + (unsigned)MDS_CLOSE_RESYNC_DONE); + LASSERTF(MDS_CLOSE_LAYOUT_SPLIT == 0x00020000UL, "found 0x%.8xUL\n", + (unsigned)MDS_CLOSE_LAYOUT_SPLIT); + /* Checks for struct mdt_body */ LASSERTF((int)sizeof(struct mdt_body) == 216, "found %lld\n", (long long)(int)sizeof(struct mdt_body)); @@ -2238,6 +2269,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct mdt_body, mbo_blocks)); LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_blocks) == 8, "found %lld\n", (long long)(int)sizeof(((struct mdt_body *)0)->mbo_blocks)); + LASSERTF((int)offsetof(struct mdt_body, mbo_version) == 88, "found %lld\n", + (long long)(int)offsetof(struct mdt_body, mbo_version)); + LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_version) == 8, "found %lld\n", + (long long)(int)sizeof(((struct mdt_body *)0)->mbo_version)); LASSERTF((int)offsetof(struct mdt_body, mbo_t_state) == 96, "found %lld\n", (long long)(int)offsetof(struct mdt_body, mbo_t_state)); LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_t_state) == 8, "found %lld\n", @@ -2278,10 +2313,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct mdt_body, mbo_nlink)); LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_nlink) == 4, "found %lld\n", (long long)(int)sizeof(((struct mdt_body *)0)->mbo_nlink)); - LASSERTF((int)offsetof(struct mdt_body, mbo_unused2) == 140, "found %lld\n", - (long long)(int)offsetof(struct mdt_body, mbo_unused2)); - LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_unused2) == 4, "found %lld\n", - (long long)(int)sizeof(((struct mdt_body *)0)->mbo_unused2)); + LASSERTF((int)offsetof(struct mdt_body, mbo_layout_gen) == 140, "found %lld\n", + (long long)(int)offsetof(struct mdt_body, mbo_layout_gen)); + LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_layout_gen) == 4, "found %lld\n", + (long long)(int)sizeof(((struct mdt_body *)0)->mbo_layout_gen)); LASSERTF((int)offsetof(struct mdt_body, mbo_suppgid) == 144, "found %lld\n", (long long)(int)offsetof(struct mdt_body, mbo_suppgid)); LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_suppgid) == 4, "found %lld\n", @@ -5253,12 +5288,14 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lfsck_request, lr_padding_3)); LASSERTF((int)sizeof(((struct lfsck_request *)0)->lr_padding_3) == 8, "found %lld\n", (long long)(int)sizeof(((struct lfsck_request *)0)->lr_padding_3)); +#ifdef HAVE_SERVER_SUPPORT LASSERTF(LFSCK_TYPE_SCRUB == 0x00000000UL, "found 0x%.8xUL\n", (unsigned)LFSCK_TYPE_SCRUB); LASSERTF(LFSCK_TYPE_LAYOUT == 0x00000001UL, "found 0x%.8xUL\n", (unsigned)LFSCK_TYPE_LAYOUT); LASSERTF(LFSCK_TYPE_NAMESPACE == 0x00000004UL, "found 0x%.8xUL\n", (unsigned)LFSCK_TYPE_NAMESPACE); +#endif LASSERTF(LE_LASTID_REBUILDING == 1, "found %lld\n", (long long)LE_LASTID_REBUILDING); LASSERTF(LE_LASTID_REBUILT == 2, "found %lld\n", @@ -5390,3 +5427,4 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct llog_update_record *)0)->lur_update_rec) == 32, "found %lld\n", (long long)(int)sizeof(((struct llog_update_record *)0)->lur_update_rec)); } + diff --git a/lustre/target/tgt_handler.c b/lustre/target/tgt_handler.c index 3e0b9cb..e7c96bb 100644 --- a/lustre/target/tgt_handler.c +++ b/lustre/target/tgt_handler.c @@ -1591,7 +1591,9 @@ EXPORT_SYMBOL(tgt_io_thread_done); int tgt_mdt_data_lock(struct ldlm_namespace *ns, struct ldlm_res_id *res_id, struct lustre_handle *lh, int mode, __u64 *flags) { - union ldlm_policy_data policy; + union ldlm_policy_data policy = { + .l_inodebits.bits = MDS_INODELOCK_DOM, + }; int rc; ENTRY; @@ -1600,9 +1602,6 @@ int tgt_mdt_data_lock(struct ldlm_namespace *ns, struct ldlm_res_id *res_id, LASSERT(ns != NULL); LASSERT(!lustre_handle_is_used(lh)); - policy.l_inodebits.bits = MDS_INODELOCK_DOM | MDS_INODELOCK_UPDATE; - policy.l_inodebits.try_bits = 0; - rc = ldlm_cli_enqueue_local(ns, res_id, LDLM_IBITS, &policy, mode, flags, ldlm_blocking_ast, ldlm_completion_ast, ldlm_glimpse_ast, @@ -1612,6 +1611,13 @@ int tgt_mdt_data_lock(struct ldlm_namespace *ns, struct ldlm_res_id *res_id, } EXPORT_SYMBOL(tgt_mdt_data_lock); +void tgt_mdt_data_unlock(struct lustre_handle *lh, enum ldlm_mode mode) +{ + LASSERT(lustre_handle_is_used(lh)); + ldlm_lock_decref(lh, mode); +} +EXPORT_SYMBOL(tgt_mdt_data_unlock); + /** * Helper function for getting server side [start, start+count] DLM lock * if asked by client. diff --git a/lustre/tests/sanity-hsm.sh b/lustre/tests/sanity-hsm.sh index b01f065..c6841e9 100755 --- a/lustre/tests/sanity-hsm.sh +++ b/lustre/tests/sanity-hsm.sh @@ -1093,7 +1093,7 @@ test_1b() { echo "verify restored state: " check_hsm_flags $f "0x00000009" && echo "pass" } -run_test 1b "Archive, Release & Restore composite file" +run_test 1b "Archive, Release and Restore composite file" test_1c() { mkdir -p $DIR/$tdir @@ -1139,6 +1139,36 @@ test_1c() { } run_test 1c "Check setting archive-id in lfs hsm_set" +test_1d() { + mkdir -p $DIR/$tdir + $LFS setstripe -E 1M -L mdt -E -1 -c 2 $DIR/$tdir || + error "failed to set default stripe" + local f=$DIR/$tdir/$tfile + rm -f $f + + dd if=/dev/urandom of=$f bs=1M count=1 conv=sync || + error "failed to create file" + local fid=$(path2fid $f) + + copytool setup + + echo "archive $f" + $LFS hsm_archive $f || error "could not archive file" + wait_request_state $fid ARCHIVE SUCCEED + + echo "release $f" + $LFS hsm_release $f || error "could not release file" + echo "verify released state: " + check_hsm_flags $f "0x0000000d" && echo "pass" + + echo "restore $f" + $LFS hsm_restore $f || error "could not restore file" + wait_request_state $fid RESTORE SUCCEED + echo "verify restored state: " + check_hsm_flags $f "0x00000009" && echo "pass" +} +run_test 1d "Archive, Release and Restore DoM file" + test_2() { local f=$DIR/$tdir/$tfile diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index 1ffd199..9b0e15c 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -379,8 +379,8 @@ check_lustre_msg_v2(void) CHECK_MEMBER(lustre_msg_v2, lm_padding_3); CHECK_MEMBER(lustre_msg_v2, lm_buflens[0]); - CHECK_DEFINE_X(LUSTRE_MSG_MAGIC_V2); - CHECK_DEFINE_X(LUSTRE_MSG_MAGIC_V2_SWABBED); + CHECK_VALUE_X(LUSTRE_MSG_MAGIC_V2); + CHECK_VALUE_X(LUSTRE_MSG_MAGIC_V2_SWABBED); } static void @@ -450,14 +450,14 @@ check_ptlrpc_body(void) CHECK_VALUE(DLM_REPLY_REC_OFF); CHECK_VALUE(MSG_PTLRPC_HEADER_OFF); - CHECK_DEFINE_X(PTLRPC_MSG_VERSION); - CHECK_DEFINE_X(LUSTRE_VERSION_MASK); - CHECK_DEFINE_X(LUSTRE_OBD_VERSION); - CHECK_DEFINE_X(LUSTRE_MDS_VERSION); - CHECK_DEFINE_X(LUSTRE_OST_VERSION); - CHECK_DEFINE_X(LUSTRE_DLM_VERSION); - CHECK_DEFINE_X(LUSTRE_LOG_VERSION); - CHECK_DEFINE_X(LUSTRE_MGS_VERSION); + CHECK_VALUE_X(PTLRPC_MSG_VERSION); + CHECK_VALUE_X(LUSTRE_VERSION_MASK); + CHECK_VALUE_X(LUSTRE_OBD_VERSION); + CHECK_VALUE_X(LUSTRE_MDS_VERSION); + CHECK_VALUE_X(LUSTRE_OST_VERSION); + CHECK_VALUE_X(LUSTRE_DLM_VERSION); + CHECK_VALUE_X(LUSTRE_LOG_VERSION); + CHECK_VALUE_X(LUSTRE_MGS_VERSION); CHECK_VALUE(MSGHDR_AT_SUPPORT); CHECK_VALUE(MSGHDR_CKSUM_INCOMPAT18); @@ -1040,6 +1040,7 @@ check_mdt_body(void) CHECK_MEMBER(mdt_body, mbo_atime); CHECK_MEMBER(mdt_body, mbo_ctime); CHECK_MEMBER(mdt_body, mbo_blocks); + CHECK_MEMBER(mdt_body, mbo_version); CHECK_MEMBER(mdt_body, mbo_t_state); CHECK_MEMBER(mdt_body, mbo_fsuid); CHECK_MEMBER(mdt_body, mbo_fsgid); @@ -1050,7 +1051,7 @@ check_mdt_body(void) CHECK_MEMBER(mdt_body, mbo_flags); CHECK_MEMBER(mdt_body, mbo_rdev); CHECK_MEMBER(mdt_body, mbo_nlink); - CHECK_MEMBER(mdt_body, mbo_unused2); + CHECK_MEMBER(mdt_body, mbo_layout_gen); CHECK_MEMBER(mdt_body, mbo_suppgid); CHECK_MEMBER(mdt_body, mbo_eadatasize); CHECK_MEMBER(mdt_body, mbo_aclsize); @@ -2421,11 +2422,11 @@ static void check_lfsck_request(void) CHECK_MEMBER(lfsck_request, lr_padding_1); CHECK_MEMBER(lfsck_request, lr_padding_2); CHECK_MEMBER(lfsck_request, lr_padding_3); - + printf("#ifdef HAVE_SERVER_SUPPORT\n"); CHECK_VALUE_X(LFSCK_TYPE_SCRUB); CHECK_VALUE_X(LFSCK_TYPE_LAYOUT); CHECK_VALUE_X(LFSCK_TYPE_NAMESPACE); - + printf("#endif\n"); CHECK_VALUE(LE_LASTID_REBUILDING); CHECK_VALUE(LE_LASTID_REBUILT); CHECK_VALUE(LE_PHASE1_DONE); diff --git a/lustre/utils/wirehdr.c b/lustre/utils/wirehdr.c index 34199bf..baa59d4 100644 --- a/lustre/utils/wirehdr.c +++ b/lustre/utils/wirehdr.c @@ -36,8 +36,10 @@ #include #include +#ifdef HAVE_SERVER_SUPPORT #include #include +#endif #define LASSERT(cond) if (!(cond)) { printf("failed " #cond "\n"); ret = 1; } #define LASSERTF(cond, fmt, ...) if (!(cond)) { printf("failed '" #cond "'" fmt, ## __VA_ARGS__);ret = 1;} diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index d01d8f7..59b1516 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -795,10 +795,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lustre_msg_v2, lm_buflens[0])); LASSERTF((int)sizeof(((struct lustre_msg_v2 *)0)->lm_buflens[0]) == 4, "found %lld\n", (long long)(int)sizeof(((struct lustre_msg_v2 *)0)->lm_buflens[0])); - LASSERTF(LUSTRE_MSG_MAGIC_V2 == 0x0BD00BD3, "found 0x%.8x\n", - LUSTRE_MSG_MAGIC_V2); - LASSERTF(LUSTRE_MSG_MAGIC_V2_SWABBED == 0xD30BD00B, "found 0x%.8x\n", - LUSTRE_MSG_MAGIC_V2_SWABBED); + LASSERTF(LUSTRE_MSG_MAGIC_V2 == 0x0bd00bd3UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_MSG_MAGIC_V2); + LASSERTF(LUSTRE_MSG_MAGIC_V2_SWABBED == 0xd30bd00bUL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_MSG_MAGIC_V2_SWABBED); /* Checks for struct ptlrpc_body */ LASSERTF((int)sizeof(struct ptlrpc_body_v3) == 184, "found %lld\n", @@ -1013,22 +1013,22 @@ void lustre_assert_wire_constants(void) (long long)DLM_REPLY_REC_OFF); LASSERTF(MSG_PTLRPC_HEADER_OFF == 31, "found %lld\n", (long long)MSG_PTLRPC_HEADER_OFF); - LASSERTF(PTLRPC_MSG_VERSION == 0x00000003, "found 0x%.8x\n", - PTLRPC_MSG_VERSION); - LASSERTF(LUSTRE_VERSION_MASK == 0xffff0000, "found 0x%.8x\n", - LUSTRE_VERSION_MASK); - LASSERTF(LUSTRE_OBD_VERSION == 0x00010000, "found 0x%.8x\n", - LUSTRE_OBD_VERSION); - LASSERTF(LUSTRE_MDS_VERSION == 0x00020000, "found 0x%.8x\n", - LUSTRE_MDS_VERSION); - LASSERTF(LUSTRE_OST_VERSION == 0x00030000, "found 0x%.8x\n", - LUSTRE_OST_VERSION); - LASSERTF(LUSTRE_DLM_VERSION == 0x00040000, "found 0x%.8x\n", - LUSTRE_DLM_VERSION); - LASSERTF(LUSTRE_LOG_VERSION == 0x00050000, "found 0x%.8x\n", - LUSTRE_LOG_VERSION); - LASSERTF(LUSTRE_MGS_VERSION == 0x00060000, "found 0x%.8x\n", - LUSTRE_MGS_VERSION); + LASSERTF(PTLRPC_MSG_VERSION == 0x00000003UL, "found 0x%.8xUL\n", + (unsigned)PTLRPC_MSG_VERSION); + LASSERTF(LUSTRE_VERSION_MASK == 0xffff0000UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_VERSION_MASK); + LASSERTF(LUSTRE_OBD_VERSION == 0x00010000UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_OBD_VERSION); + LASSERTF(LUSTRE_MDS_VERSION == 0x00020000UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_MDS_VERSION); + LASSERTF(LUSTRE_OST_VERSION == 0x00030000UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_OST_VERSION); + LASSERTF(LUSTRE_DLM_VERSION == 0x00040000UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_DLM_VERSION); + LASSERTF(LUSTRE_LOG_VERSION == 0x00050000UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_LOG_VERSION); + LASSERTF(LUSTRE_MGS_VERSION == 0x00060000UL, "found 0x%.8xUL\n", + (unsigned)LUSTRE_MGS_VERSION); LASSERTF(MSGHDR_AT_SUPPORT == 1, "found %lld\n", (long long)MSGHDR_AT_SUPPORT); LASSERTF(MSGHDR_CKSUM_INCOMPAT18 == 2, "found %lld\n", @@ -2290,6 +2290,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct mdt_body, mbo_blocks)); LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_blocks) == 8, "found %lld\n", (long long)(int)sizeof(((struct mdt_body *)0)->mbo_blocks)); + LASSERTF((int)offsetof(struct mdt_body, mbo_version) == 88, "found %lld\n", + (long long)(int)offsetof(struct mdt_body, mbo_version)); + LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_version) == 8, "found %lld\n", + (long long)(int)sizeof(((struct mdt_body *)0)->mbo_version)); LASSERTF((int)offsetof(struct mdt_body, mbo_t_state) == 96, "found %lld\n", (long long)(int)offsetof(struct mdt_body, mbo_t_state)); LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_t_state) == 8, "found %lld\n", @@ -2330,10 +2334,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct mdt_body, mbo_nlink)); LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_nlink) == 4, "found %lld\n", (long long)(int)sizeof(((struct mdt_body *)0)->mbo_nlink)); - LASSERTF((int)offsetof(struct mdt_body, mbo_unused2) == 140, "found %lld\n", - (long long)(int)offsetof(struct mdt_body, mbo_unused2)); - LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_unused2) == 4, "found %lld\n", - (long long)(int)sizeof(((struct mdt_body *)0)->mbo_unused2)); + LASSERTF((int)offsetof(struct mdt_body, mbo_layout_gen) == 140, "found %lld\n", + (long long)(int)offsetof(struct mdt_body, mbo_layout_gen)); + LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_layout_gen) == 4, "found %lld\n", + (long long)(int)sizeof(((struct mdt_body *)0)->mbo_layout_gen)); LASSERTF((int)offsetof(struct mdt_body, mbo_suppgid) == 144, "found %lld\n", (long long)(int)offsetof(struct mdt_body, mbo_suppgid)); LASSERTF((int)sizeof(((struct mdt_body *)0)->mbo_suppgid) == 4, "found %lld\n",