From: wangdi Date: Mon, 25 Nov 2013 13:50:05 +0000 (-0800) Subject: LU-2775 osp: enable fid-on-OST only for DNE. X-Git-Tag: 2.3.62~49 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=2adc20013d9c2a5969a3154b0ca93ac007b1a4e2;p=fs%2Flustre-release.git LU-2775 osp: enable fid-on-OST only for DNE. 1. MDT0 will only create IDIF fids, so old clients, who only know IDIF, can still access files on MDT0. 2. Using fid_ostid_pack to pack the FID into ostid, otherwise IDIF will be packed wrongly and caused the panic on the OST0. 3. Add dd into compatible tests of conf-sanity.sh(32) to check OST fids on the upgrade FS. Signed-off-by: wang di Change-Id: Ic9322bd1c66e5fedec68c10aa2f300d5ecb3b6db Reviewed-on: http://review.whamcloud.com/5307 Tested-by: Hudson Reviewed-by: Andreas Dilger Reviewed-by: Fan Yong Reviewed-by: Alex Zhuravlev --- diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index ffa755e..0432325 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -354,6 +354,27 @@ struct hsm_attrs { }; extern void lustre_hsm_swab(struct hsm_attrs *attrs); +struct ost_id { + obd_id oi_id; + obd_seq oi_seq; +}; + +static inline void ostid_cpu_to_le(struct ost_id *src_oi, + struct ost_id *dst_oi) +{ + dst_oi->oi_id = cpu_to_le64(src_oi->oi_id); + dst_oi->oi_seq = cpu_to_le64(src_oi->oi_seq); +} + +static inline void ostid_le_to_cpu(struct ost_id *src_oi, + struct ost_id *dst_oi) +{ + dst_oi->oi_id = le64_to_cpu(src_oi->oi_id); + dst_oi->oi_seq = le64_to_cpu(src_oi->oi_seq); +} + +extern void lustre_swab_ost_id(struct ost_id *oid); + /** * fid constants */ @@ -535,11 +556,6 @@ static inline int fid_is_idif(const struct lu_fid *fid) return fid_seq_is_idif(fid_seq(fid)); } -struct ost_id { - obd_id oi_id; - obd_seq oi_seq; -}; - static inline int fid_is_local_file(const struct lu_fid *fid) { return fid_seq_is_local_file(fid_seq(fid)); @@ -661,7 +677,7 @@ static inline void ostid_idif_pack(const struct lu_fid *fid, } /* pack a non-IDIF FID into an ostid (id/seq) for the wire/disk */ -static inline void ostid_fid_pack(const struct lu_fid *fid, +static inline void ostid_normal_fid_pack(const struct lu_fid *fid, struct ost_id *ostid) { ostid->oi_seq = fid_seq(fid); @@ -672,17 +688,17 @@ static inline void ostid_fid_pack(const struct lu_fid *fid, static inline int fid_ostid_pack(const struct lu_fid *fid, struct ost_id *ostid) { - if (unlikely(fid_seq_is_igif(fid->f_seq))) { - CERROR("bad IGIF, "DFID"\n", PFID(fid)); - return -EBADF; - } + if (unlikely(fid_seq_is_igif(fid->f_seq))) { + CERROR("bad IGIF, "DFID"\n", PFID(fid)); + return -EBADF; + } - if (fid_is_idif(fid)) - ostid_idif_pack(fid, ostid); - else - ostid_fid_pack(fid, ostid); + if (fid_is_idif(fid)) + ostid_idif_pack(fid, ostid); + else + ostid_normal_fid_pack(fid, ostid); - return 0; + return 0; } /* extract OST sequence (group) from a wire ost_id (id/seq) pair */ diff --git a/lustre/include/lustre_req_layout.h b/lustre/include/lustre_req_layout.h index ce694a5..5387a14 100644 --- a/lustre/include/lustre_req_layout.h +++ b/lustre/include/lustre_req_layout.h @@ -317,6 +317,7 @@ extern struct req_msg_field RMF_NIOBUF_REMOTE; extern struct req_msg_field RMF_RCS; extern struct req_msg_field RMF_FIEMAP_KEY; extern struct req_msg_field RMF_FIEMAP_VAL; +extern struct req_msg_field RMF_OST_ID; /* MGS config read message format */ extern struct req_msg_field RMF_MGS_CONFIG_BODY; diff --git a/lustre/include/obd_ost.h b/lustre/include/obd_ost.h index feeb445..5a9961d 100644 --- a/lustre/include/obd_ost.h +++ b/lustre/include/obd_ost.h @@ -93,6 +93,6 @@ int osc_extent_blocking_cb(struct ldlm_lock *lock, int flag); #endif -#define POSTID LPU64":"LPU64 +#define POSTID LPU64":"LPX64 #endif diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h index 28c7d18e..29c9208 100644 --- a/lustre/ofd/ofd_internal.h +++ b/lustre/ofd/ofd_internal.h @@ -107,8 +107,7 @@ static inline void ofd_counter_incr(struct obd_export *exp, int opcode, struct ofd_seq { cfs_list_t os_list; - obd_id os_last_oid; - obd_seq os_seq; + struct ost_id os_oi; spinlock_t os_last_oid_lock; struct mutex os_create_lock; cfs_atomic_t os_refc; @@ -116,6 +115,9 @@ struct ofd_seq { unsigned long os_destroys_in_progress:1; }; +#define os_seq os_oi.oi_seq +#define os_last_oid os_oi.oi_id + struct ofd_device { struct dt_device ofd_dt_dev; struct dt_device *ofd_osd; diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index c20c071..5bd258f 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -630,36 +630,39 @@ static int ofd_get_info(const struct lu_env *env, struct obd_export *exp, *((__u32 *) val) = ofd->ofd_sync_lock_cancel; *vallen = sizeof(__u32); } else if (KEY_IS(KEY_LAST_FID)) { - struct lu_env env; - struct ofd_device *ofd = ofd_exp(exp); - struct ofd_seq *oseq; - struct lu_fid *last_fid = val; - int rc; - - if (last_fid == NULL) { - *vallen = sizeof(struct lu_fid); + struct lu_env env; + struct ofd_device *ofd = ofd_exp(exp); + struct ofd_seq *oseq; + struct ost_id *oid = val; + int rc; + + if (oid == NULL) { + *vallen = sizeof(struct ost_id); RETURN(0); } - if (*vallen < sizeof(*last_fid)) + if (*vallen < sizeof(*oid)) RETURN(-EOVERFLOW); rc = lu_env_init(&env, LCT_DT_THREAD); if (rc != 0) RETURN(rc); ofd_info_init(&env, exp); - fid_le_to_cpu(last_fid, last_fid); - oseq = ofd_seq_load(&env, ofd, fid_seq(last_fid)); + + ostid_le_to_cpu(oid, oid); + CDEBUG(D_HA, "Get LAST FID for seq "LPX64"\n", oid->oi_seq); + + oseq = ofd_seq_load(&env, ofd, oid->oi_seq); if (IS_ERR(oseq)) - GOTO(out_fid, rc = PTR_ERR(oseq)); + GOTO(out_fini, rc = PTR_ERR(oseq)); - last_fid->f_seq = oseq->os_seq; - last_fid->f_oid = oseq->os_last_oid; - fid_cpu_to_le(last_fid, last_fid); + CDEBUG(D_HA, "LAST FID is "POSTID"\n", oseq->os_last_oid, + oseq->os_seq); - *vallen = sizeof(*last_fid); + *oid = oseq->os_oi; + *vallen = sizeof(*oid); ofd_seq_put(&env, oseq); -out_fid: +out_fini: lu_env_fini(&env); } else { CERROR("Not supported key %s\n", (char*)key); diff --git a/lustre/osp/osp_precreate.c b/lustre/osp/osp_precreate.c index 1196991..405524cb 100644 --- a/lustre/osp/osp_precreate.c +++ b/lustre/osp/osp_precreate.c @@ -454,6 +454,7 @@ static int osp_precreate_send(const struct lu_env *env, struct osp_device *d) body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY); LASSERT(body); + *fid = d->opd_pre_last_created_fid; rc = osp_precreate_fids(env, d, fid, &grow); if (rc == 1) { /* Current seq has been used up*/ @@ -472,7 +473,7 @@ static int osp_precreate_send(const struct lu_env *env, struct osp_device *d) fid->f_seq = 0; } - ostid_fid_pack(fid, &body->oa.o_oi); + fid_ostid_pack(fid, &body->oa.o_oi); body->oa.o_valid = OBD_MD_FLGROUP; ptlrpc_request_set_replen(req); @@ -526,8 +527,10 @@ out_req: RETURN(rc); } -static int osp_get_lastfid_from_ost(struct osp_device *d) +static int osp_get_lastfid_from_ost(const struct lu_env *env, + struct osp_device *d) { + struct ost_id *oi = &osp_env_info(env)->osi_oi; struct ptlrpc_request *req = NULL; struct obd_import *imp; struct lu_fid *last_fid = &d->opd_last_used_fid; @@ -542,11 +545,11 @@ static int osp_get_lastfid_from_ost(struct osp_device *d) if (req == NULL) RETURN(-ENOMEM); - req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, - RCL_CLIENT, sizeof(KEY_LAST_FID)); + req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, RCL_CLIENT, + sizeof(KEY_LAST_FID)); - req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_VAL, - RCL_CLIENT, sizeof(*last_fid)); + req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_VAL, RCL_CLIENT, + sizeof(*oi)); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GET_INFO); if (rc) { @@ -558,9 +561,10 @@ static int osp_get_lastfid_from_ost(struct osp_device *d) memcpy(tmp, KEY_LAST_FID, sizeof(KEY_LAST_FID)); req->rq_no_delay = req->rq_no_resend = 1; - fid_cpu_to_le(last_fid, last_fid); + fid_ostid_pack(last_fid, oi); + ostid_cpu_to_le(oi, oi); tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_VAL); - memcpy(tmp, last_fid, sizeof(*last_fid)); + memcpy(tmp, oi, sizeof(*oi)); ptlrpc_request_set_replen(req); rc = ptlrpc_queue_wait(req); @@ -574,8 +578,14 @@ static int osp_get_lastfid_from_ost(struct osp_device *d) GOTO(out, rc); } - last_fid = req_capsule_server_get(&req->rq_pill, &RMF_FID); - if (last_fid == NULL || !fid_is_sane(last_fid)) { + oi = req_capsule_server_get(&req->rq_pill, &RMF_OST_ID); + if (oi == NULL) { + CERROR("%s: Got last_fid failed.\n", d->opd_obd->obd_name); + GOTO(out, rc = -EPROTO); + } + + rc = fid_ostid_unpack(last_fid, oi, d->opd_index); + if (rc != 0 || !fid_is_sane(last_fid)) { CERROR("%s: Got insane last_fid "DFID"\n", d->opd_obd->obd_name, PFID(last_fid)); GOTO(out, rc = -EPROTO); @@ -586,7 +596,7 @@ static int osp_get_lastfid_from_ost(struct osp_device *d) if (fid_oid(last_fid) > 0) d->opd_last_used_fid = *last_fid; - CDEBUG(D_HA, "%s: Got insane last_fid "DFID"\n", d->opd_obd->obd_name, + CDEBUG(D_HA, "%s: Got last_fid "DFID"\n", d->opd_obd->obd_name, PFID(last_fid)); out: @@ -646,7 +656,7 @@ static int osp_precreate_cleanup_orphans(struct lu_env *env, LASSERT(!fid_is_zero(last_fid)); if (fid_oid(&d->opd_last_used_fid) < 2) { /* lastfid looks strange... ask OST */ - rc = osp_get_lastfid_from_ost(d); + rc = osp_get_lastfid_from_ost(env, d); if (rc) GOTO(out, rc); } @@ -671,12 +681,8 @@ static int osp_precreate_cleanup_orphans(struct lu_env *env, body->oa.o_flags = OBD_FL_DELORPHAN; body->oa.o_valid = OBD_MD_FLFLAGS | OBD_MD_FLGROUP; - if (osp_is_fid_client(d)) - body->oa.o_seq = fid_seq(&d->opd_last_used_fid); - else - body->oa.o_seq = 0; - /* remove from NEXT after used one */ - body->oa.o_id = fid_oid(&d->opd_last_used_fid); + + fid_ostid_pack(&d->opd_last_used_fid, &body->oa.o_oi); ptlrpc_request_set_replen(req); @@ -840,7 +846,7 @@ static int osp_init_pre_fid(struct osp_device *osp) last_fid = &osi->osi_fid; fid_zero(last_fid); /* For a freshed fs, it will allocate a new sequence first */ - if (osp_is_fid_client(osp)) { + if (osp_is_fid_client(osp) && osp->opd_group != 0) { cli_seq = osp->opd_obd->u.cli.cl_seq; rc = seq_client_get_seq(&env, cli_seq, &last_fid->f_seq); if (rc != 0) { @@ -849,7 +855,7 @@ static int osp_init_pre_fid(struct osp_device *osp) GOTO(out, rc); } } else { - last_fid->f_seq = fid_idif_seq(1, osp->opd_index); + last_fid->f_seq = fid_idif_seq(0, osp->opd_index); } last_fid->f_oid = 1; last_fid->f_ver = 0; diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index e5a9617..562210e 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -133,7 +133,7 @@ static int ost_validate_obdo(struct obd_export *exp, struct obdo *oa, oa->o_id, oa->o_seq); return -EPROTO; } - ioobj_from_obdo(ioobj, oa); + ioobj_from_obdo(ioobj, oa); } return 0; } diff --git a/lustre/ptlrpc/layout.c b/lustre/ptlrpc/layout.c index 84642b6..0156712 100644 --- a/lustre/ptlrpc/layout.c +++ b/lustre/ptlrpc/layout.c @@ -592,7 +592,7 @@ static const struct req_msg_field *ost_get_last_id_server[] = { static const struct req_msg_field *ost_get_last_fid_server[] = { &RMF_PTLRPC_BODY, - &RMF_FID + &RMF_OST_ID }; static const struct req_msg_field *ost_get_fiemap_client[] = { @@ -1054,6 +1054,11 @@ struct req_msg_field RMF_FID = sizeof(struct lu_fid), lustre_swab_lu_fid, NULL); EXPORT_SYMBOL(RMF_FID); +struct req_msg_field RMF_OST_ID = + DEFINE_MSGF("ost_id", 0, + sizeof(struct ost_id), lustre_swab_ost_id, NULL); +EXPORT_SYMBOL(RMF_OST_ID); + struct req_msg_field RMF_FIEMAP_KEY = DEFINE_MSGF("fiemap", 0, sizeof(struct ll_fiemap_info_key), lustre_swab_fiemap, NULL); diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index b8e99fd..885f250 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -1726,11 +1726,17 @@ void lustre_swab_connect(struct obd_connect_data *ocd) CLASSERT(offsetof(typeof(*ocd), paddingF) != 0); } +void lustre_swab_ost_id(struct ost_id *oid) +{ + __swab64s(&oid->oi_id); + __swab64s(&oid->oi_seq); +} +EXPORT_SYMBOL(lustre_swab_ost_id); + void lustre_swab_obdo (struct obdo *o) { __swab64s (&o->o_valid); - __swab64s (&o->o_id); - __swab64s (&o->o_seq); + lustre_swab_ost_id(&o->o_oi); __swab64s (&o->o_parent_seq); __swab64s (&o->o_size); __swab64s (&o->o_mtime); diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 5aeec40..268a460 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -1565,6 +1565,15 @@ t32_test() { popd fi + dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || { + error_noexit "dd failed" + return 1 + } + rm -rf $tmp/mnt/lustre/tmp_file || { + error_noexit "rm failed" + return 1 + } + if $r test -f $tmp/sha1sums; then # LU-2393 - do both sorts on same node to ensure locale # is identical diff --git a/lustre/utils/req-layout.c b/lustre/utils/req-layout.c index 8081901..96ee60b 100644 --- a/lustre/utils/req-layout.c +++ b/lustre/utils/req-layout.c @@ -84,6 +84,7 @@ #define lustre_swab_mgs_config_res NULL #define lustre_swab_swap_layouts NULL #define lustre_swab_lu_fid NULL +#define lustre_swab_ost_id NULL #define lustre_swab_hsm_progress_kernel NULL #define lustre_swab_hsm_user_item NULL #define lustre_swab_hsm_user_state NULL