From: Fan Yong Date: Sun, 24 Nov 2013 08:59:00 +0000 (+0800) Subject: LU-3569 ofd: packing ost_idx in IDIF X-Git-Tag: 2.5.54~12 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=da12d3ba35bbb86c8e5860a5ed161a55f01b69d5;hp=e02e613f411d4273c9c1c99ee88121e641ddb4c2 LU-3569 ofd: packing ost_idx in IDIF For a normal FID, we can know on which target the related object is allocated via querying FLDB; but it is not true for an IDIF. To locate the OST via the given IDIF, when the IDIF is generated, we pack the OST index in it. Then for any given FID, in spite of it is a normal FID or not, we has the method to know which target it belongs to. That is useful for LFSCK. For old IDIF, the OST index is not part of the IDIF, means that different OSTs may have the same IDIFs, that may cause the IFID in LMA does not match the read FID. Under such case, we need to make some compatible check to avoid to trigger unexpected. tgt_validate_obdo() converts the ostid contained in the RPC body to fid and changes the "struct ost_id" union, then the users can access ost_id::oi_fid directly without call ostid_to_fid() again. It also contains some other fixing and cleanup. Test-Parameters: testlist=sanity-scrub Signed-off-by: wang di Signed-off-by: Fan Yong Change-Id: I228f2f6cd9310193a1724046cee15e3b2103c8e2 Reviewed-on: http://review.whamcloud.com/7053 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev --- diff --git a/lustre/include/lu_target.h b/lustre/include/lu_target.h index 9d952bf..d4a814e 100644 --- a/lustre/include/lu_target.h +++ b/lustre/include/lu_target.h @@ -103,6 +103,7 @@ struct tgt_session_info { struct lu_object *tsi_corpus; struct lu_fid tsi_fid; + struct lu_fid tsi_fid2; struct ldlm_res_id tsi_resid; /* object affected by VBR, for last_rcvd_update */ diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 370899c..4b1f06f 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -634,7 +634,7 @@ static inline obd_seq ostid_seq(const struct ost_id *ostid) if (fid_seq_is_mdt0(ostid->oi.oi_seq)) return FID_SEQ_OST_MDT0; - if (fid_seq_is_default(ostid->oi.oi_seq)) + if (unlikely(fid_seq_is_default(ostid->oi.oi_seq))) return FID_SEQ_LOV_DEFAULT; if (fid_is_idif(&ostid->oi_fid)) @@ -646,9 +646,12 @@ static inline obd_seq ostid_seq(const struct ost_id *ostid) /* extract OST objid from a wire ost_id (id/seq) pair */ static inline obd_id ostid_id(const struct ost_id *ostid) { - if (fid_seq_is_mdt0(ostid_seq(ostid))) + if (fid_seq_is_mdt0(ostid->oi.oi_seq)) return ostid->oi.oi_id & IDIF_OID_MASK; + if (unlikely(fid_seq_is_default(ostid->oi.oi_seq))) + return ostid->oi.oi_id; + if (fid_is_idif(&ostid->oi_fid)) return fid_idif_id(fid_seq(&ostid->oi_fid), fid_oid(&ostid->oi_fid), 0); @@ -691,13 +694,23 @@ static inline void ostid_set_seq_llog(struct ost_id *oi) */ static inline void ostid_set_id(struct ost_id *oi, __u64 oid) { - if (fid_seq_is_mdt0(ostid_seq(oi))) { + if (fid_seq_is_mdt0(oi->oi.oi_seq)) { if (oid >= IDIF_MAX_OID) { CERROR("Bad "LPU64" to set "DOSTID"\n", oid, POSTID(oi)); return; } oi->oi.oi_id = oid; + } else if (fid_is_idif(&oi->oi_fid)) { + if (oid >= IDIF_MAX_OID) { + CERROR("Bad "LPU64" to set "DOSTID"\n", + oid, POSTID(oi)); + return; + } + oi->oi_fid.f_seq = fid_idif_seq(oid, + fid_idif_ost_idx(&oi->oi_fid)); + oi->oi_fid.f_oid = oid; + oi->oi_fid.f_ver = oid >> 48; } else { if (oid > OBIF_MAX_OID) { CERROR("Bad "LPU64" to set "DOSTID"\n", @@ -708,25 +721,31 @@ static inline void ostid_set_id(struct ost_id *oi, __u64 oid) } } -static inline void ostid_inc_id(struct ost_id *oi) +static inline int fid_set_id(struct lu_fid *fid, __u64 oid) { - if (fid_seq_is_mdt0(ostid_seq(oi))) { - if (unlikely(ostid_id(oi) + 1 > IDIF_MAX_OID)) { - CERROR("Bad inc "DOSTID"\n", POSTID(oi)); - return; + if (unlikely(fid_seq_is_igif(fid->f_seq))) { + CERROR("bad IGIF, "DFID"\n", PFID(fid)); + return -EBADF; + } + + if (fid_is_idif(fid)) { + if (oid >= IDIF_MAX_OID) { + CERROR("Bad "LPU64" to set "DFID"\n", + oid, PFID(fid)); + return -EBADF; } - oi->oi.oi_id++; + fid->f_seq = fid_idif_seq(oid, fid_idif_ost_idx(fid)); + fid->f_oid = oid; + fid->f_ver = oid >> 48; } else { - oi->oi_fid.f_oid++; + if (oid > OBIF_MAX_OID) { + CERROR("Bad "LPU64" to set "DFID"\n", + oid, PFID(fid)); + return -EBADF; + } + fid->f_oid = oid; } -} - -static inline void ostid_dec_id(struct ost_id *oi) -{ - if (fid_seq_is_mdt0(ostid_seq(oi))) - oi->oi.oi_id--; - else - oi->oi_fid.f_oid--; + return 0; } /** @@ -738,36 +757,41 @@ static inline void ostid_dec_id(struct ost_id *oi) * struct lu_fid fields without loss. For reference see: * http://arch.lustre.org/index.php?title=Interoperability_fids_zfs */ -static inline int ostid_to_fid(struct lu_fid *fid, struct ost_id *ostid, +static inline int ostid_to_fid(struct lu_fid *fid, const struct ost_id *ostid, __u32 ost_idx) { + obd_seq seq = ostid_seq(ostid); + if (ost_idx > 0xffff) { CERROR("bad ost_idx, "DOSTID" ost_idx:%u\n", POSTID(ostid), ost_idx); return -EBADF; } - if (fid_seq_is_mdt0(ostid_seq(ostid))) { + if (fid_seq_is_mdt0(seq)) { + obd_id oid = ostid_id(ostid); + /* This is a "legacy" (old 1.x/2.early) OST object in "group 0" * that we map into the IDIF namespace. It allows up to 2^48 * objects per OST, as this is the object namespace that has * been in production for years. This can handle create rates * of 1M objects/s/OST for 9 years, or combinations thereof. */ - if (ostid_id(ostid) >= IDIF_MAX_OID) { + if (oid >= IDIF_MAX_OID) { CERROR("bad MDT0 id, "DOSTID" ost_idx:%u\n", POSTID(ostid), ost_idx); return -EBADF; } - fid->f_seq = fid_idif_seq(ostid_id(ostid), ost_idx); + fid->f_seq = fid_idif_seq(oid, ost_idx); /* truncate to 32 bits by assignment */ - fid->f_oid = ostid_id(ostid); + fid->f_oid = oid; /* in theory, not currently used */ - fid->f_ver = ostid_id(ostid) >> 48; - } else /* if (fid_seq_is_idif(seq) || fid_seq_is_norm(seq)) */ { - /* This is either an IDIF object, which identifies objects across - * all OSTs, or a regular FID. The IDIF namespace maps legacy - * OST objects into the FID namespace. In both cases, we just - * pass the FID through, no conversion needed. */ + fid->f_ver = oid >> 48; + } else if (likely(!fid_seq_is_default(seq))) + /* if (fid_seq_is_idif(seq) || fid_seq_is_norm(seq)) */ { + /* This is either an IDIF object, which identifies objects across + * all OSTs, or a regular FID. The IDIF namespace maps legacy + * OST objects into the FID namespace. In both cases, we just + * pass the FID through, no conversion needed. */ if (ostid->oi_fid.f_ver != 0) { CERROR("bad MDT0 id, "DOSTID" ost_idx:%u\n", POSTID(ostid), ost_idx); @@ -776,7 +800,7 @@ static inline int ostid_to_fid(struct lu_fid *fid, struct ost_id *ostid, *fid = ostid->oi_fid; } - return 0; + return 0; } /* pack any OST FID into an ostid (id/seq) for the wire/disk */ @@ -1619,6 +1643,11 @@ static inline void lmm_oi_set_seq(struct ost_id *oi, __u64 seq) oi->oi.oi_seq = seq; } +static inline void lmm_oi_set_id(struct ost_id *oi, __u64 oid) +{ + oi->oi.oi_id = oid; +} + static inline __u64 lmm_oi_id(struct ost_id *oi) { return oi->oi.oi_id; diff --git a/lustre/include/lustre_fid.h b/lustre/include/lustre_fid.h index 8e815b4..0978092 100644 --- a/lustre/include/lustre_fid.h +++ b/lustre/include/lustre_fid.h @@ -311,10 +311,10 @@ static inline int fid_seq_in_fldb(__u64 seq) fid_seq_is_root(seq) || fid_seq_is_dot(seq); } -static inline void lu_last_id_fid(struct lu_fid *fid, __u64 seq) +static inline void lu_last_id_fid(struct lu_fid *fid, __u64 seq, __u32 ost_idx) { if (fid_seq_is_mdt0(seq)) { - fid->f_seq = fid_idif_seq(0, 0); + fid->f_seq = fid_idif_seq(0, ost_idx); } else { LASSERTF(fid_seq_is_norm(seq) || fid_seq_is_echo(seq) || fid_seq_is_idif(seq), LPX64"\n", seq); @@ -598,19 +598,6 @@ static inline void ostid_build_res_name(struct ost_id *oi, } } -static inline void ostid_res_name_to_id(struct ost_id *oi, - struct ldlm_res_id *name) -{ - if (fid_seq_is_mdt0(name->name[LUSTRE_RES_ID_SEQ_OFF])) { - /* old resid */ - ostid_set_seq(oi, name->name[LUSTRE_RES_ID_VER_OID_OFF]); - ostid_set_id(oi, name->name[LUSTRE_RES_ID_SEQ_OFF]); - } else { - /* new resid */ - fid_extract_from_res_name(&oi->oi_fid, name); - } -} - /** * Return true if the resource is for the object identified by this id & group. */ @@ -644,14 +631,15 @@ static inline void ost_fid_build_resid(const struct lu_fid *fid, } static inline void ost_fid_from_resid(struct lu_fid *fid, - const struct ldlm_res_id *name) + const struct ldlm_res_id *name, + int ost_idx) { if (fid_seq_is_mdt0(name->name[LUSTRE_RES_ID_VER_OID_OFF])) { /* old resid */ struct ost_id oi; ostid_set_seq(&oi, name->name[LUSTRE_RES_ID_VER_OID_OFF]); ostid_set_id(&oi, name->name[LUSTRE_RES_ID_SEQ_OFF]); - ostid_to_fid(fid, &oi, 0); + ostid_to_fid(fid, &oi, ost_idx); } else { /* new resid */ fid_extract_from_res_name(fid, name); diff --git a/lustre/lfsck/lfsck_engine.c b/lustre/lfsck/lfsck_engine.c index 041e7f4..e55c04f 100644 --- a/lustre/lfsck/lfsck_engine.c +++ b/lustre/lfsck/lfsck_engine.c @@ -93,6 +93,64 @@ static void lfsck_close_dir(const struct lu_env *env, lfsck_object_put(env, dir_obj); } +static int lfsck_update_lma(const struct lu_env *env, + struct lfsck_instance *lfsck, struct dt_object *obj) +{ + struct lfsck_thread_info *info = lfsck_env_info(env); + struct lfsck_bookmark *bk = &lfsck->li_bookmark_ram; + struct dt_device *dt = lfsck->li_bottom; + struct lustre_mdt_attrs *lma = &info->lti_lma; + struct lu_buf *buf; + struct thandle *th; + int fl; + int rc; + ENTRY; + + if (bk->lb_param & LPF_DRYRUN) + RETURN(0); + + buf = lfsck_buf_get(env, info->lti_lma_old, LMA_OLD_SIZE); + rc = dt_xattr_get(env, obj, buf, XATTR_NAME_LMA, BYPASS_CAPA); + if (rc < 0) { + if (rc != -ENODATA) + RETURN(rc); + + fl = LU_XATTR_CREATE; + lustre_lma_init(lma, lfsck_dto2fid(obj), LMAC_FID_ON_OST, 0); + } else { + if (rc != LMA_OLD_SIZE && rc != sizeof(struct lustre_mdt_attrs)) + RETURN(-EINVAL); + + fl = LU_XATTR_REPLACE; + lustre_lma_swab(lma); + lustre_lma_init(lma, lfsck_dto2fid(obj), + lma->lma_compat | LMAC_FID_ON_OST, + lma->lma_incompat); + } + lustre_lma_swab(lma); + + th = dt_trans_create(env, dt); + if (IS_ERR(th)) + RETURN(PTR_ERR(th)); + + buf = lfsck_buf_get(env, lma, sizeof(*lma)); + rc = dt_declare_xattr_set(env, obj, buf, XATTR_NAME_LMA, fl, th); + if (rc != 0) + GOTO(stop, rc); + + rc = dt_trans_start(env, dt, th); + if (rc != 0) + GOTO(stop, rc); + + rc = dt_xattr_set(env, obj, buf, XATTR_NAME_LMA, fl, th, BYPASS_CAPA); + + GOTO(stop, rc); + +stop: + dt_trans_stop(env, dt, th); + return rc; +} + static int lfsck_master_dir_engine(const struct lu_env *env, struct lfsck_instance *lfsck) { @@ -192,11 +250,14 @@ static int lfsck_master_oit_engine(const struct lu_env *env, struct lu_fid *fid = &info->lti_fid; struct lfsck_bookmark *bk = &lfsck->li_bookmark_ram; struct ptlrpc_thread *thread = &lfsck->li_thread; + __u32 idx = + lfsck_dev_idx(lfsck->li_bottom); int rc; ENTRY; do { struct dt_object *target; + bool update_lma = false; if (lfsck->li_di_dir != NULL) { rc = lfsck_master_dir_engine(env, lfsck); @@ -226,12 +287,27 @@ static int lfsck_master_oit_engine(const struct lu_env *env, rc = iops->rec(env, di, (struct dt_rec *)fid, 0); if (rc != 0) { lfsck_fail(env, lfsck, true); - if (bk->lb_param & LPF_FAILOUT) + if (rc < 0 && bk->lb_param & LPF_FAILOUT) RETURN(rc); else goto checkpoint; } + if (fid_is_idif(fid)) { + __u32 idx1 = fid_idif_ost_idx(fid); + + LASSERT(!lfsck->li_master); + + /* It is an old format device, update the LMA. */ + if (idx != idx1) { + struct ost_id *oi = &info->lti_oi; + + fid_to_ostid(fid, oi); + ostid_to_fid(fid, oi, idx); + update_lma = true; + } + } + target = lfsck_object_find(env, lfsck, fid); if (target == NULL) { goto checkpoint; @@ -245,8 +321,12 @@ static int lfsck_master_oit_engine(const struct lu_env *env, /* XXX: Currently, skip remote object, the consistency for * remote object will be processed in LFSCK phase III. */ - if (dt_object_exists(target) && !dt_object_remote(target)) - rc = lfsck_exec_oit(env, lfsck, target); + if (dt_object_exists(target) && !dt_object_remote(target)) { + if (update_lma) + rc = lfsck_update_lma(env, lfsck, target); + if (rc == 0) + rc = lfsck_exec_oit(env, lfsck, target); + } lfsck_object_put(env, target); if (rc != 0 && bk->lb_param & LPF_FAILOUT) RETURN(rc); diff --git a/lustre/lfsck/lfsck_internal.h b/lustre/lfsck/lfsck_internal.h index 56cdff0..3d02d34 100644 --- a/lustre/lfsck/lfsck_internal.h +++ b/lustre/lfsck/lfsck_internal.h @@ -42,6 +42,7 @@ #include #include #include +#include #define HALF_SEC (HZ >> 1) #define LFSCK_CHECKPOINT_INTERVAL 60 @@ -352,6 +353,12 @@ struct lfsck_thread_info { struct lu_fid lti_fid; struct lu_fid lti_fid2; struct lu_attr lti_la; + struct ost_id lti_oi; + union { + struct lustre_mdt_attrs lti_lma; + /* old LMA for compatibility */ + char lti_lma_old[LMA_OLD_SIZE]; + }; /* lti_ent and lti_key must be conjoint, * then lti_ent::lde_name will be lti_key. */ struct lu_dirent lti_ent; @@ -544,4 +551,9 @@ static inline void lfsck_object_put(const struct lu_env *env, lu_object_put(env, &obj->do_lu); } +static inline mdsno_t lfsck_dev_idx(struct dt_device *dev) +{ + return dev->dd_lu_dev.ld_site->ld_seq_site->ss_node_id; +} + #endif /* _LFSCK_INTERNAL_H */ diff --git a/lustre/lfsck/lfsck_lib.c b/lustre/lfsck/lfsck_lib.c index 0da2614..a4c963c 100644 --- a/lustre/lfsck/lfsck_lib.c +++ b/lustre/lfsck/lfsck_lib.c @@ -85,11 +85,6 @@ const char *lfsck_param_names[] = { NULL }; -static inline mdsno_t lfsck_dev_idx(struct dt_device *dev) -{ - return dev->dd_lu_dev.ld_site->ld_seq_site->ss_node_id; -} - static inline void lfsck_component_get(struct lfsck_component *com) { atomic_inc(&com->lc_ref); diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 038e0df..e60ba8b 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -717,7 +717,7 @@ int lod_initialize_objects(const struct lu_env *env, struct lod_object *lo, for (i = 0; i < lo->ldo_stripenr; i++) { ostid_le_to_cpu(&objs[i].l_ost_oi, &info->lti_ostid); - idx = le64_to_cpu(objs[i].l_ost_idx); + idx = le32_to_cpu(objs[i].l_ost_idx); rc = ostid_to_fid(&info->lti_fid, &info->lti_ostid, idx); if (rc != 0) GOTO(out, rc); diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index 8fbb322..6179e4d 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -391,6 +391,7 @@ static int lod_xattr_get(const struct lu_env *env, struct dt_object *dt, } else if (buf->lb_len >= sizeof(*lum)) { lum->lmm_magic = cpu_to_le32(LOV_USER_MAGIC_V1); lmm_oi_set_seq(&lum->lmm_oi, FID_SEQ_LOV_DEFAULT); + lmm_oi_set_id(&lum->lmm_oi, 0); lmm_oi_cpu_to_le(&lum->lmm_oi, &lum->lmm_oi); lum->lmm_pattern = cpu_to_le32(desc->ld_pattern); lum->lmm_stripe_size = cpu_to_le32( diff --git a/lustre/obdclass/llog_swab.c b/lustre/obdclass/llog_swab.c index f509874..e5af8a7 100644 --- a/lustre/obdclass/llog_swab.c +++ b/lustre/obdclass/llog_swab.c @@ -72,7 +72,8 @@ EXPORT_SYMBOL(lustre_swab_lu_fid); void lustre_swab_ost_id(struct ost_id *oid) { - if (fid_seq_is_mdt0(oid->oi.oi_seq)) { + if (fid_seq_is_mdt0(oid->oi.oi_seq) || + fid_seq_is_default(oid->oi.oi_seq)) { __swab64s(&oid->oi.oi_id); __swab64s(&oid->oi.oi_seq); } else { @@ -82,7 +83,7 @@ void lustre_swab_ost_id(struct ost_id *oid) EXPORT_SYMBOL(lustre_swab_ost_id); void lustre_swab_llog_id(struct llog_logid *log_id) -{ +{ __swab64s(&log_id->lgl_oi.oi.oi_id); __swab64s(&log_id->lgl_oi.oi.oi_seq); __swab32s(&log_id->lgl_ogen); diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index ba493de..21b124c 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -872,6 +872,10 @@ int ofd_get_info_hdl(struct tgt_session_info *tsi) if (rc) RETURN(err_serious(rc)); + *fid = fm_key->oa.o_oi.oi_fid; + + CDEBUG(D_INODE, "get FIEMAP of object "DFID"\n", PFID(fid)); + replylen = fiemap_count_to_size(fm_key->fiemap.fm_extent_count); req_capsule_set_size(tsi->tsi_pill, &RMF_FIEMAP_VAL, RCL_SERVER, replylen); @@ -884,12 +888,6 @@ int ofd_get_info_hdl(struct tgt_session_info *tsi) if (fiemap == NULL) RETURN(-ENOMEM); - rc = ostid_to_fid(fid, &fm_key->oa.o_oi, 0); - if (rc != 0) - RETURN(rc); - - CDEBUG(D_INODE, "get FIEMAP of object "DFID"\n", PFID(fid)); - *fiemap = fm_key->fiemap; rc = ofd_fiemap_get(tsi->tsi_env, ofd, fid, fiemap); @@ -1319,6 +1317,8 @@ static int ofd_destroy_hdl(struct tgt_session_info *tsi) struct ost_body *repbody; struct ofd_device *ofd = ofd_exp(tsi->tsi_exp); struct ofd_thread_info *fti = tsi2ofd_info(tsi); + struct lu_fid *fid = &fti->fti_fid; + obd_id oid; obd_count count; int rc = 0; @@ -1339,8 +1339,11 @@ static int ofd_destroy_hdl(struct tgt_session_info *tsi) ldlm_request_cancel(tgt_ses_req(tsi), dlm, 0); } + *fid = body->oa.o_oi.oi_fid; + oid = ostid_id(&body->oa.o_oi); + LASSERT(oid != 0); + repbody = req_capsule_server_get(tsi->tsi_pill, &RMF_OST_BODY); - repbody->oa.o_oi = body->oa.o_oi; /* check that o_misc makes sense */ if (body->oa.o_valid & OBD_MD_FLOBJCOUNT) @@ -1350,37 +1353,39 @@ static int ofd_destroy_hdl(struct tgt_session_info *tsi) CDEBUG(D_HA, "%s: Destroy object "DOSTID" count %d\n", ofd_name(ofd), POSTID(&body->oa.o_oi), count); + while (count > 0) { int lrc; - lrc = ostid_to_fid(&fti->fti_fid, &repbody->oa.o_oi, 0); - if (lrc != 0) { - if (rc == 0) - rc = lrc; - GOTO(out, rc); - } - lrc = ofd_destroy_by_fid(tsi->tsi_env, ofd, &fti->fti_fid, 0); + lrc = ofd_destroy_by_fid(tsi->tsi_env, ofd, fid, 0); if (lrc == -ENOENT) { CDEBUG(D_INODE, "%s: destroying non-existent object "DFID"\n", - ofd_name(ofd), PFID(&fti->fti_fid)); + ofd_name(ofd), PFID(fid)); /* rewrite rc with -ENOENT only if it is 0 */ if (rc == 0) rc = lrc; } else if (lrc != 0) { CERROR("%s: error destroying object "DFID": %d\n", - ofd_name(ofd), PFID(&fti->fti_fid), - rc); + ofd_name(ofd), PFID(fid), lrc); rc = lrc; } + count--; - ostid_inc_id(&repbody->oa.o_oi); + oid++; + lrc = fid_set_id(fid, oid); + if (unlikely(lrc != 0 && count > 0)) + GOTO(out, rc = lrc); } ofd_counter_incr(tsi->tsi_exp, LPROC_OFD_STATS_DESTROY, tsi->tsi_jobid, 1); + + GOTO(out, rc); + out: - RETURN(rc); + fid_to_ostid(fid, &repbody->oa.o_oi); + return rc; } static int ofd_statfs_hdl(struct tgt_session_info *tsi) diff --git a/lustre/ofd/ofd_fs.c b/lustre/ofd/ofd_fs.c index 77f5170..8a2a8a5 100644 --- a/lustre/ofd/ofd_fs.c +++ b/lustre/ofd/ofd_fs.c @@ -277,7 +277,7 @@ struct ofd_seq *ofd_seq_load(const struct lu_env *env, struct ofd_device *ofd, if (oseq == NULL) RETURN(ERR_PTR(-ENOMEM)); - lu_last_id_fid(&info->fti_fid, seq); + lu_last_id_fid(&info->fti_fid, seq, ofd->ofd_lut.lut_lsd.lsd_osd_index); memset(&info->fti_attr, 0, sizeof(info->fti_attr)); info->fti_attr.la_valid = LA_MODE; info->fti_attr.la_mode = S_IFREG | S_IRUGO | S_IWUSR; diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index e8e41b9..c21c903 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -253,10 +253,7 @@ int ofd_preprw(const struct lu_env *env, int cmd, struct obd_export *exp, LASSERT(objcount == 1); LASSERT(obj->ioo_bufcnt > 0); - rc = ostid_to_fid(&info->fti_fid, &oa->o_oi, 0); - if (unlikely(rc != 0)) - RETURN(rc); - + info->fti_fid = oa->o_oi.oi_fid; if (cmd == OBD_BRW_WRITE) { rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oa->o_oi), capa, CAPA_OPC_OSS_WRITE); @@ -584,9 +581,7 @@ int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, LASSERT(npages > 0); - rc = ostid_to_fid(&info->fti_fid, &oa->o_oi, 0); - if (unlikely(rc != 0)) - RETURN(rc); + info->fti_fid = oa->o_oi.oi_fid; if (cmd == OBD_BRW_WRITE) { /* Don't update timestamps if this write is older than a * setattr which modifies the timestamps. b=10150 */ diff --git a/lustre/ofd/ofd_lvb.c b/lustre/ofd/ofd_lvb.c index 9f0c403..8fedc75 100644 --- a/lustre/ofd/ofd_lvb.c +++ b/lustre/ofd/ofd_lvb.c @@ -87,7 +87,8 @@ static int ofd_lvbo_init(struct ldlm_resource *res) res->lr_lvb_len = sizeof(*lvb); info = ofd_info_init(&env, NULL); - ost_fid_from_resid(&info->fti_fid, &res->lr_name); + ost_fid_from_resid(&info->fti_fid, &res->lr_name, + ofd->ofd_lut.lut_lsd.lsd_osd_index); fo = ofd_object_find(&env, ofd, &info->fti_fid); if (IS_ERR(fo)) GOTO(out_lvb, rc = PTR_ERR(fo)); @@ -224,7 +225,8 @@ static int ofd_lvbo_update(struct ldlm_resource *res, disk_update: /* Update the LVB from the disk inode */ - ost_fid_from_resid(&info->fti_fid, &res->lr_name); + ost_fid_from_resid(&info->fti_fid, &res->lr_name, + ofd->ofd_lut.lut_lsd.lsd_osd_index); fo = ofd_object_find(&env, ofd, &info->fti_fid); if (IS_ERR(fo)) GOTO(out_env, rc = PTR_ERR(fo)); diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index 61e6baf..599d9f5 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -582,7 +582,8 @@ static int ofd_get_info(const struct lu_env *env, struct obd_export *exp, GOTO(out, rc = 0); } - rc = ostid_to_fid(&fid, &fm_key->oa.o_oi, 0); + rc = ostid_to_fid(&fid, &fm_key->oa.o_oi, + ofd->ofd_lut.lut_lsd.lsd_osd_index); if (rc != 0) GOTO(out, rc); CDEBUG(D_INODE, "get FIEMAP of object "DFID"\n", @@ -632,7 +633,7 @@ static int ofd_get_info(const struct lu_env *env, struct obd_export *exp, GOTO(out, rc = PTR_ERR(oseq)); rc = ostid_to_fid(fid, &oseq->os_oi, - ofd->ofd_lut.lut_lsd.lsd_osd_index); + ofd->ofd_lut.lut_lsd.lsd_osd_index); if (rc != 0) GOTO(out_put, rc); @@ -819,10 +820,7 @@ int ofd_setattr(const struct lu_env *env, struct obd_export *exp, info = ofd_info_init(env, exp); ofd_oti2info(info, oti); - rc = ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0); - if (rc != 0) - RETURN(rc); - + info->fti_fid = oinfo->oi_oa->o_oi.oi_fid; ost_fid_build_resid(&info->fti_fid, &info->fti_resid); rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oa->o_oi), oinfo_capa(oinfo), CAPA_OPC_META_WRITE); @@ -908,9 +906,7 @@ static int ofd_punch(const struct lu_env *env, struct obd_export *exp, info = ofd_info_init(env, exp); ofd_oti2info(info, oti); - rc = ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0); - if (rc != 0) - RETURN(rc); + info->fti_fid = oinfo->oi_oa->o_oi.oi_fid; ost_fid_build_resid(&info->fti_fid, &info->fti_resid); CDEBUG(D_INODE, "calling punch for object "DFID", valid = "LPX64 @@ -1025,6 +1021,8 @@ int ofd_destroy(const struct lu_env *env, struct obd_export *exp, { struct ofd_device *ofd = ofd_exp(exp); struct ofd_thread_info *info; + struct lu_fid *fid; + obd_id oid; obd_count count; int rc = 0; @@ -1032,10 +1030,15 @@ int ofd_destroy(const struct lu_env *env, struct obd_export *exp, info = ofd_info_init(env, exp); ofd_oti2info(info, oti); + fid = &info->fti_fid; if (!(oa->o_valid & OBD_MD_FLGROUP)) ostid_set_seq_mdt0(&oa->o_oi); + *fid = oa->o_oi.oi_fid; + oid = ostid_id(&oa->o_oi); + LASSERT(oid != 0); + /* check that o_misc makes sense */ if (oa->o_valid & OBD_MD_FLOBJCOUNT) count = oa->o_misc; @@ -1044,96 +1047,109 @@ int ofd_destroy(const struct lu_env *env, struct obd_export *exp, CDEBUG(D_INODE, "%s: Destroy object "DOSTID" count %d\n", ofd_name(ofd), POSTID(&oa->o_oi), count); + while (count > 0) { int lrc; - lrc = ostid_to_fid(&info->fti_fid, &oa->o_oi, 0); - if (lrc != 0) { - if (rc == 0) - rc = lrc; - GOTO(out, rc); - } - lrc = ofd_destroy_by_fid(env, ofd, &info->fti_fid, 0); + lrc = ofd_destroy_by_fid(env, ofd, fid, 0); if (lrc == -ENOENT) { CDEBUG(D_INODE, "%s: destroying non-existent object "DFID"\n", - ofd_obd(ofd)->obd_name, PFID(&info->fti_fid)); + ofd_obd(ofd)->obd_name, PFID(fid)); /* rewrite rc with -ENOENT only if it is 0 */ if (rc == 0) rc = lrc; } else if (lrc != 0) { CERROR("%s: error destroying object "DFID": %d\n", - ofd_obd(ofd)->obd_name, PFID(&info->fti_fid), + ofd_obd(ofd)->obd_name, PFID(fid), rc); rc = lrc; } + count--; - ostid_inc_id(&oa->o_oi); + oid++; + lrc = fid_set_id(fid, oid); + if (unlikely(lrc != 0 && count > 0)) + GOTO(out, rc = lrc); } - ofd_info2oti(info, oti); + GOTO(out, rc); + out: - RETURN(rc); + ofd_info2oti(info, oti); + fid_to_ostid(fid, &oa->o_oi); + return rc; } int ofd_orphans_destroy(const struct lu_env *env, struct obd_export *exp, struct ofd_device *ofd, struct obdo *oa) { - struct ofd_thread_info *info = ofd_info(env); + struct ofd_thread_info *info = ofd_info(env); + struct lu_fid *fid = &info->fti_fid; + struct ost_id *oi = &oa->o_oi; + struct ofd_seq *oseq; + obd_seq seq = ostid_seq(oi); + obd_id end_id = ostid_id(oi); obd_id last; + obd_id oid; int skip_orphan; - int rc = 0; - struct ost_id oi = oa->o_oi; - __u64 end_id = ostid_id(&oa->o_oi); - struct ofd_seq *oseq; - + int rc = 0; ENTRY; - oseq = ofd_seq_get(ofd, ostid_seq(&oa->o_oi)); + oseq = ofd_seq_get(ofd, seq); if (oseq == NULL) { CERROR("%s: Can not find seq for "DOSTID"\n", - ofd_name(ofd), POSTID(&oa->o_oi)); + ofd_name(ofd), POSTID(oi)); RETURN(-EINVAL); } + *fid = oi->oi_fid; + last = ofd_seq_last_oid(oseq); + oid = last; + LASSERT(exp != NULL); skip_orphan = !!(exp_connect_flags(exp) & OBD_CONNECT_SKIP_ORPHAN); - last = ofd_seq_last_oid(oseq); LCONSOLE(D_INFO, "%s: deleting orphan objects from "DOSTID - " to "DOSTID"\n", ofd_name(ofd), ostid_seq(&oa->o_oi), - end_id + 1, ostid_seq(&oa->o_oi), last); + " to "DOSTID"\n", ofd_name(ofd), seq, end_id + 1, seq, last); - for (ostid_set_id(&oi, last); ostid_id(&oi) > end_id; - ostid_dec_id(&oi)) { - rc = ostid_to_fid(&info->fti_fid, &oi, 0); - if (rc != 0) + while (oid > end_id) { + rc = fid_set_id(fid, oid); + if (unlikely(rc != 0)) GOTO(out_put, rc); - rc = ofd_destroy_by_fid(env, ofd, &info->fti_fid, 1); - if (rc && rc != -ENOENT) /* this is pretty fatal... */ - CEMERG("%s: error destroying precreated id "DOSTID - ": rc = %d\n", ofd_name(ofd), POSTID(&oi), rc); + + rc = ofd_destroy_by_fid(env, ofd, fid, 1); + if (rc != 0 && rc != -ENOENT) /* this is pretty fatal... */ + CEMERG("%s: error destroying precreated id "DFID + ": rc = %d\n", ofd_name(ofd), PFID(fid), rc); + + oid--; if (!skip_orphan) { - ofd_seq_last_oid_set(oseq, ostid_id(&oi) - 1); + ofd_seq_last_oid_set(oseq, oid); /* update last_id on disk periodically so that if we * restart * we don't need to re-scan all of the just * deleted objects. */ - if ((ostid_id(&oi) & 511) == 0) + if ((oid & 511) == 0) ofd_seq_last_oid_write(env, ofd, oseq); } } + CDEBUG(D_HA, "%s: after destroy: set last_id to "DOSTID"\n", - ofd_obd(ofd)->obd_name, POSTID(&oa->o_oi)); + ofd_obd(ofd)->obd_name, seq, oid); + if (!skip_orphan) { rc = ofd_seq_last_oid_write(env, ofd, oseq); } else { /* don't reuse orphan object, return last used objid */ - ostid_set_id(&oa->o_oi, last); + ostid_set_id(oi, last); rc = 0; } + + GOTO(out_put, rc); + out_put: ofd_seq_put(env, oseq); - RETURN(rc); + return rc; } int ofd_create(const struct lu_env *env, struct obd_export *exp, @@ -1343,9 +1359,7 @@ int ofd_getattr(const struct lu_env *env, struct obd_export *exp, info = ofd_info_init(env, exp); - rc = ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0); - if (rc != 0) - GOTO(out, rc); + info->fti_fid = oinfo->oi_oa->o_oi.oi_fid; rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oinfo->oi_oa->o_oi), oinfo_capa(oinfo), CAPA_OPC_META_READ); if (rc) @@ -1398,10 +1412,7 @@ static int ofd_sync(const struct lu_env *env, struct obd_export *exp, } info = ofd_info_init(env, exp); - rc = ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0); - if (rc != 0) - GOTO(out, rc); - + info->fti_fid = oinfo->oi_oa->o_oi.oi_fid; rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oinfo->oi_oa->o_oi), oinfo_capa(oinfo), CAPA_OPC_OSS_TRUNC); if (rc) @@ -1461,7 +1472,8 @@ static int ofd_ioc_get_obj_version(const struct lu_env *env, ostid_set_seq(&ostid, *(__u64 *)data->ioc_inlbuf4); ostid_set_id(&ostid, *(__u64 *)data->ioc_inlbuf3); - rc = ostid_to_fid(&fid, &ostid, 0); + rc = ostid_to_fid(&fid, &ostid, + ofd->ofd_lut.lut_lsd.lsd_osd_index); if (rc != 0) GOTO(out, rc); } else { diff --git a/lustre/ofd/ofd_objects.c b/lustre/ofd/ofd_objects.c index 22c6580..ee9ebe2 100644 --- a/lustre/ofd/ofd_objects.c +++ b/lustre/ofd/ofd_objects.c @@ -152,6 +152,7 @@ int ofd_precreate_objects(const struct lu_env *env, struct ofd_device *ofd, struct dt_object *next; struct thandle *th; struct ofd_object **batch; + struct lu_fid *fid = &info->fti_fid; obd_id tmp; int rc; int i; @@ -194,12 +195,13 @@ int ofd_precreate_objects(const struct lu_env *env, struct ofd_device *ofd, info->fti_attr.la_mtime = 0; info->fti_attr.la_ctime = 0; + LASSERT(id != 0); + /* prepare objects */ - ostid_set_seq(&info->fti_ostid, ostid_seq(&oseq->os_oi)); + *fid = *lu_object_fid(&oseq->os_lastid_obj->do_lu); for (i = 0; i < nr; i++) { - ostid_set_id(&info->fti_ostid, id + i); - rc = ostid_to_fid(&info->fti_fid, &info->fti_ostid, 0); - if (rc) { + rc = fid_set_id(fid, id + i); + if (rc != 0) { if (i == 0) GOTO(out, rc); @@ -207,7 +209,7 @@ int ofd_precreate_objects(const struct lu_env *env, struct ofd_device *ofd, break; } - fo = ofd_object_find(env, ofd, &info->fti_fid); + fo = ofd_object_find(env, ofd, fid); if (IS_ERR(fo)) { if (i == 0) GOTO(out, rc = PTR_ERR(fo)); @@ -242,7 +244,7 @@ int ofd_precreate_objects(const struct lu_env *env, struct ofd_device *ofd, /* object may exist being re-created by write replay */ CDEBUG(D_INODE, "object "LPX64"/"LPX64" exists: " DFID"\n", ostid_seq(&oseq->os_oi), id, - PFID(&info->fti_fid)); + PFID(lu_object_fid(&fo->ofo_obj.do_lu))); continue; } @@ -262,7 +264,7 @@ int ofd_precreate_objects(const struct lu_env *env, struct ofd_device *ofd, GOTO(trans_stop, rc); CDEBUG(D_OTHER, "%s: create new object "DFID" nr %d\n", - ofd_name(ofd), PFID(&info->fti_fid), nr); + ofd_name(ofd), PFID(fid), nr); for (i = 0; i < nr; i++) { fo = batch[i]; diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 4644b9d..7339837 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -318,6 +318,32 @@ int osd_get_idif(struct osd_thread_info *info, struct inode *inode, return rc; } +static int osd_lma_self_repair(struct osd_thread_info *info, + struct osd_device *osd, struct inode *inode, + const struct lu_fid *fid, __u32 compat) +{ + handle_t *jh; + int rc; + + LASSERT(current->journal_info == NULL); + + jh = osd_journal_start_sb(osd_sb(osd), LDISKFS_HT_MISC, + osd_dto_credits_noquota[DTO_XATTR_SET]); + if (IS_ERR(jh)) { + rc = PTR_ERR(jh); + CWARN("%s: cannot start journal for lma_self_repair: rc = %d\n", + osd_name(osd), rc); + return rc; + } + + rc = osd_ea_fid_set(info, inode, fid, compat, 0); + if (rc != 0) + CWARN("%s: cannot self repair the LMA: rc = %d\n", + osd_name(osd), rc); + ldiskfs_journal_stop(jh); + return rc; +} + static int osd_check_lma(const struct lu_env *env, struct osd_object *obj) { struct osd_thread_info *info = osd_oti_get(env); @@ -326,6 +352,7 @@ static int osd_check_lma(const struct lu_env *env, struct osd_object *obj) struct inode *inode = obj->oo_inode; struct dentry *dentry = &info->oti_obj_dentry; struct lu_fid *fid = NULL; + const struct lu_fid *rfid = lu_object_fid(&obj->oo_dt.do_lu); int rc; ENTRY; @@ -335,40 +362,18 @@ static int osd_check_lma(const struct lu_env *env, struct osd_object *obj) CLASSERT(LMA_OLD_SIZE >= sizeof(*lma)); rc = __osd_xattr_get(inode, dentry, XATTR_NAME_LMA, info->oti_mdt_attrs_old, LMA_OLD_SIZE); - if (rc == -ENODATA && !fid_is_igif(lu_object_fid(&obj->oo_dt.do_lu)) && - osd->od_check_ff) { + if (rc == -ENODATA && !fid_is_igif(rfid) && osd->od_check_ff) { fid = &lma->lma_self_fid; rc = osd_get_idif(info, inode, dentry, fid); if ((rc > 0) || (rc == -ENODATA && osd->od_lma_self_repair)) { - handle_t *jh; - /* For the given OST-object, if it has neither LMA nor * FID in XATTR_NAME_FID, then the given FID (which is * contained in the @obj, from client RPC for locating * the OST-object) is trusted. We use it to generate * the LMA. */ - - LASSERT(current->journal_info == NULL); - - jh = osd_journal_start_sb(osd_sb(osd), LDISKFS_HT_MISC, - osd_dto_credits_noquota[DTO_XATTR_SET]); - if (IS_ERR(jh)) { - CWARN("%s: cannot start journal for " - "lma_self_repair: rc = %ld\n", - osd_name(osd), PTR_ERR(jh)); - RETURN(0); - } - - rc = osd_ea_fid_set(info, inode, - lu_object_fid(&obj->oo_dt.do_lu), - fid_is_on_ost(info, osd, - lu_object_fid(&obj->oo_dt.do_lu), - OI_CHECK_FLD) ? - LMAC_FID_ON_OST : 0, 0); - if (rc != 0) - CWARN("%s: cannot self repair the LMA: " - "rc = %d\n", osd_name(osd), rc); - ldiskfs_journal_stop(jh); + osd_lma_self_repair(info, osd, inode, rfid, + fid_is_on_ost(info, osd, fid, OI_CHECK_FLD) ? + LMAC_FID_ON_OST : 0); RETURN(0); } } @@ -387,19 +392,39 @@ static int osd_check_lma(const struct lu_env *env, struct osd_object *obj) CWARN("%s: unsupported incompat LMA feature(s) %#x for " "fid = "DFID", ino = %lu\n", osd_name(osd), lma->lma_incompat & ~LMA_INCOMPAT_SUPP, - PFID(lu_object_fid(&obj->oo_dt.do_lu)), - inode->i_ino); + PFID(rfid), inode->i_ino); rc = -EOPNOTSUPP; } else if (!(lma->lma_compat & LMAC_NOT_IN_OI)) { fid = &lma->lma_self_fid; } } - if (fid != NULL && - unlikely(!lu_fid_eq(lu_object_fid(&obj->oo_dt.do_lu), fid))) { + if (fid != NULL && unlikely(!lu_fid_eq(rfid, fid))) { + if (fid_is_idif(rfid) && fid_is_idif(fid)) { + struct ost_id *oi = &info->oti_ostid; + struct lu_fid *fid1 = &info->oti_fid3; + __u32 idx = fid_idif_ost_idx(rfid); + + /* For old IDIF, the OST index is not part of the IDIF, + * Means that different OSTs may have the same IDIFs. + * Under such case, we need to make some compatible + * check to make sure to trigger OI scrub properly. */ + if (idx != 0 && fid_idif_ost_idx(fid) == 0) { + /* Given @rfid is new, LMA is old. */ + fid_to_ostid(fid, oi); + ostid_to_fid(fid1, oi, idx); + if (lu_fid_eq(fid1, rfid)) { + if (osd->od_lma_self_repair) + osd_lma_self_repair(info, osd, + inode, rfid, + LMAC_FID_ON_OST); + RETURN(0); + } + } + } + CDEBUG(D_INODE, "%s: FID "DFID" != self_fid "DFID"\n", - osd_name(osd), PFID(lu_object_fid(&obj->oo_dt.do_lu)), - PFID(&lma->lma_self_fid)); + osd_name(osd), PFID(rfid), PFID(fid)); rc = -EREMCHG; } diff --git a/lustre/target/tgt_handler.c b/lustre/target/tgt_handler.c index 376f345..14a474f 100644 --- a/lustre/target/tgt_handler.c +++ b/lustre/target/tgt_handler.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "tgt_internal.h" @@ -130,43 +131,53 @@ static int tgt_mdt_body_unpack(struct tgt_session_info *tsi, __u32 flags) */ int tgt_validate_obdo(struct tgt_session_info *tsi, struct obdo *oa) { - int rc; - + struct ost_id *oi = &oa->o_oi; + obd_seq seq = ostid_seq(oi); + obd_id id = ostid_id(oi); + int rc; ENTRY; if (unlikely(!(exp_connect_flags(tsi->tsi_exp) & OBD_CONNECT_FID) && - fid_seq_is_echo(oa->o_oi.oi.oi_seq))) { + fid_seq_is_echo(seq))) { /* Sigh 2.[123] client still sends echo req with oi_id = 0 * during create, and we will reset this to 1, since this * oi_id is basically useless in the following create process, * but oi_id == 0 will make it difficult to tell whether it is * real FID or ost_id. */ - oa->o_oi.oi_fid.f_oid = oa->o_oi.oi.oi_id ?: 1; - oa->o_oi.oi_fid.f_seq = FID_SEQ_ECHO; - oa->o_oi.oi_fid.f_ver = 0; + oi->oi_fid.f_seq = FID_SEQ_ECHO; + oi->oi_fid.f_oid = id ?: 1; + oi->oi_fid.f_ver = 0; } else { - if (unlikely((oa->o_valid & OBD_MD_FLID && - ostid_id(&oa->o_oi) == 0))) + struct lu_fid *fid = &tsi->tsi_fid2; + + if (unlikely((oa->o_valid & OBD_MD_FLID) && id == 0)) GOTO(out, rc = -EPROTO); /* Note: this check might be forced in 2.5 or 2.6, i.e. * all of the requests are required to setup FLGROUP */ if (unlikely(!(oa->o_valid & OBD_MD_FLGROUP))) { - ostid_set_seq_mdt0(&oa->o_oi); + ostid_set_seq_mdt0(oi); oa->o_valid |= OBD_MD_FLGROUP; + seq = ostid_seq(oi); } - if (unlikely(!(fid_seq_is_idif(ostid_seq(&oa->o_oi)) || - fid_seq_is_mdt0(ostid_seq(&oa->o_oi)) || - fid_seq_is_norm(ostid_seq(&oa->o_oi)) || - fid_seq_is_echo(ostid_seq(&oa->o_oi))))) + if (unlikely(!(fid_seq_is_idif(seq) || fid_seq_is_mdt0(seq) || + fid_seq_is_norm(seq) || fid_seq_is_echo(seq)))) GOTO(out, rc = -EPROTO); + + rc = ostid_to_fid(fid, oi, tsi->tsi_tgt->lut_lsd.lsd_osd_index); + if (unlikely(rc != 0)) + GOTO(out, rc); + + oi->oi_fid = *fid; } + RETURN(0); + out: CERROR("%s: client %s sent bad object "DOSTID": rc = %d\n", tgt_name(tsi->tsi_tgt), obd_export_nid2str(tsi->tsi_exp), - ostid_seq(&oa->o_oi), ostid_id(&oa->o_oi), rc); + seq, id, rc); return rc; } EXPORT_SYMBOL(tgt_validate_obdo); @@ -251,6 +262,7 @@ static int tgt_ost_body_unpack(struct tgt_session_info *tsi, __u32 flags) } tsi->tsi_ost_body = body; + tsi->tsi_fid = body->oa.o_oi.oi_fid; if (req_capsule_has_field(pill, &RMF_OBD_IOOBJ, RCL_CLIENT)) { rc = tgt_io_data_unpack(tsi, &body->oa.o_oi); @@ -269,16 +281,6 @@ static int tgt_ost_body_unpack(struct tgt_session_info *tsi, __u32 flags) } } - rc = ostid_to_fid(&tsi->tsi_fid, &body->oa.o_oi, 0); - if (rc != 0) - RETURN(rc); - - if (!fid_is_sane(&tsi->tsi_fid)) { - CERROR("%s: invalid FID: "DFID"\n", tgt_name(tsi->tsi_tgt), - PFID(&tsi->tsi_fid)); - RETURN(-EINVAL); - } - ost_fid_build_resid(&tsi->tsi_fid, &tsi->tsi_resid); /* @@ -1167,7 +1169,8 @@ int tgt_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, if (unlikely(rc != 0)) RETURN(rc); - ost_fid_from_resid(&fid, &lock->l_resource->lr_name); + ost_fid_from_resid(&fid, &lock->l_resource->lr_name, + tgt->lut_lsd.lsd_osd_index); obj = dt_locate(&env, tgt->lut_bottom, &fid); if (IS_ERR(obj)) GOTO(err_env, rc = PTR_ERR(obj));