From 725f3f8eb96203b5679da46bfc4e6d22bf1cdf9c Mon Sep 17 00:00:00 2001 From: wang di Date: Sun, 26 Jan 2014 19:44:48 -0800 Subject: [PATCH] LU-2888 fid: still Use oi_id/oi_seq for log/lov object. Since llog are only used locally on MDS right now, so we will use oi_id/oi_seq to identfy the log, instead of trying to convert it to FID, to avoid confusion in ostid_to_fid/fid_to_ostid. Since pre-2.4 use {oi_id,oi_seq} for FIDs on MDT, which make it difficult to tell whether it is ostid or FID by only checking oi_seq, so this patch will separate lmm_oi/FID conversion from ostid_to_fid. Signed-off-by: wang di Change-Id: Ie17b11a8a07ed3a44e41d5e88529541cbd33dd2f Reviewed-on: http://review.whamcloud.com/6044 Reviewed-by: Andreas Dilger Tested-by: Hudson Tested-by: Maloo --- lustre/include/lustre/lustre_idl.h | 60 ++++++++++++++++++++++++++++++++++++++ lustre/include/lustre_log.h | 32 ++++++++------------ lustre/liblustre/tests/sanity.c | 8 ++--- lustre/lod/lod_lov.c | 8 +++-- lustre/lod/lod_object.c | 6 ++-- lustre/lov/lov_ea.c | 4 +-- lustre/lov/lov_merge.c | 19 +++++------- lustre/lov/lov_object.c | 7 ++++- lustre/lov/lov_pack.c | 4 +-- lustre/obdecho/echo_client.c | 12 ++++++-- lustre/ofd/ofd_io.c | 9 ++++-- lustre/ofd/ofd_obd.c | 40 +++++++++++++++++++------ lustre/ptlrpc/pack_generic.c | 14 ++++++--- lustre/utils/liblustreapi.c | 8 ++--- 14 files changed, 163 insertions(+), 68 deletions(-) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index aceaeba..6e285bf 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -1569,6 +1569,66 @@ struct lov_mds_md_v1 { /* LOV EA mds/wire data (little-endian) */ struct lov_ost_data_v1 lmm_objects[0]; /* per-stripe data */ }; +/** + * Sigh, because pre-2.4 uses + * struct lov_mds_md_v1 { + * ........ + * __u64 lmm_object_id; + * __u64 lmm_object_seq; + * ...... + * } + * to identify the LOV(MDT) object, and lmm_object_seq will + * be normal_fid, which make it hard to combine these conversion + * to ostid_to FID. so we will do lmm_oi/fid conversion separately + * + * We can tell the lmm_oi by this way, + * 1.8: lmm_object_id = {inode}, lmm_object_gr = 0 + * 2.1: lmm_object_id = {oid < 128k}, lmm_object_seq = FID_SEQ_NORMAL + * 2.4: lmm_oi.f_seq = FID_SEQ_NORMAL, lmm_oi.f_oid = {oid < 128k}, + * lmm_oi.f_ver = 0 + * + * But currently lmm_oi/lsm_oi does not have any "real" usages, + * except for printing some information, and the user can always + * get the real FID from LMA, besides this multiple case check might + * make swab more complicate. So we will keep using id/seq for lmm_oi. + */ + +static inline void fid_to_lmm_oi(const struct lu_fid *fid, + struct ost_id *oi) +{ + oi->oi.oi_id = fid_oid(fid); + oi->oi.oi_seq = fid_seq(fid); +} + +static inline void lmm_oi_set_seq(struct ost_id *oi, __u64 seq) +{ + oi->oi.oi_seq = seq; +} + +static inline __u64 lmm_oi_id(struct ost_id *oi) +{ + return oi->oi.oi_id; +} + +static inline __u64 lmm_oi_seq(struct ost_id *oi) +{ + return oi->oi.oi_seq; +} + +static inline void lmm_oi_le_to_cpu(struct ost_id *dst_oi, + struct ost_id *src_oi) +{ + dst_oi->oi.oi_id = le64_to_cpu(src_oi->oi.oi_id); + dst_oi->oi.oi_seq = le64_to_cpu(src_oi->oi.oi_seq); +} + +static inline void lmm_oi_cpu_to_le(struct ost_id *dst_oi, + struct ost_id *src_oi) +{ + dst_oi->oi.oi_id = cpu_to_le64(src_oi->oi.oi_id); + dst_oi->oi.oi_seq = cpu_to_le64(src_oi->oi.oi_seq); +} + /* extern void lustre_swab_lov_mds_md(struct lov_mds_md *llm); */ #define MAX_MD_SIZE (sizeof(struct lov_mds_md) + 4 * sizeof(struct lov_ost_data)) diff --git a/lustre/include/lustre_log.h b/lustre/include/lustre_log.h index e9d3f2c..7c1fc97 100644 --- a/lustre/include/lustre_log.h +++ b/lustre/include/lustre_log.h @@ -97,38 +97,30 @@ static inline void logid_to_fid(struct llog_logid *id, struct lu_fid *fid) /* For compatibility purposes we identify pre-OSD (~< 2.3.51 MDS) * logid's by non-zero ogen (inode generation) and convert them * into IGIF */ - if (id->lgl_ogen == 0) - ostid_to_fid(fid, &id->lgl_oi, 0); - else - lu_igif_build(fid, ostid_id(&id->lgl_oi), id->lgl_ogen); + if (id->lgl_ogen == 0) { + fid->f_seq = id->lgl_oi.oi.oi_seq; + fid->f_oid = id->lgl_oi.oi.oi_id; + fid->f_ver = 0; + } else { + lu_igif_build(fid, id->lgl_oi.oi.oi_id, id->lgl_ogen); + } } static inline void fid_to_logid(struct lu_fid *fid, struct llog_logid *id) { - if (fid_is_igif(fid)) { - /* See above lu_igif_build */ - ostid_set_id(&id->lgl_oi, fid->f_seq); - id->lgl_ogen = fid->f_oid; - } else { - fid_to_ostid(fid, &id->lgl_oi); - id->lgl_ogen = 0; - } + id->lgl_oi.oi.oi_seq = fid->f_seq; + id->lgl_oi.oi.oi_id = fid->f_oid; + id->lgl_ogen = 0; } static inline void logid_set_id(struct llog_logid *log_id, __u64 id) { - if (log_id->lgl_ogen == 0) - ostid_set_id(&log_id->lgl_oi, id); - else - log_id->lgl_oi.oi.oi_id = id; + log_id->lgl_oi.oi.oi_id = id; } static inline __u64 logid_id(struct llog_logid *log_id) { - if (log_id->lgl_ogen == 0) - return ostid_id(&log_id->lgl_oi); - else - return log_id->lgl_oi.oi.oi_id; + return log_id->lgl_oi.oi.oi_id; } struct llog_handle; diff --git a/lustre/liblustre/tests/sanity.c b/lustre/liblustre/tests/sanity.c index 9652a6b..814a75f 100644 --- a/lustre/liblustre/tests/sanity.c +++ b/lustre/liblustre/tests/sanity.c @@ -1257,9 +1257,9 @@ int t55(char *name) if (opt_verbose) { printf("lmm_magic: 0x%08X\n", lum->lmm_magic); printf("lmm_object_id: "LPX64"\n", - ostid_id(&lum->lmm_oi)); + lmm_oi_id(&lum->lmm_oi)); printf("lmm_object_seq: "LPX64"\n", - ostid_seq(&lum->lmm_oi)); + lmm_oi_seq(&lum->lmm_oi)); printf("lmm_stripe_count: %u\n", (int)lum->lmm_stripe_count); printf("lmm_stripe_size: %u\n", lum->lmm_stripe_size); printf("lmm_stripe_pattern: %x\n", lum->lmm_pattern); @@ -1325,9 +1325,9 @@ int t55(char *name) if (opt_verbose) { printf("lmm_magic: 0x%08X\n", lum->lmm_magic); printf("lmm_object_id: "LPX64"\n", - ostid_id(&lum->lmm_oi)); + lmm_oi_id(&lum->lmm_oi)); printf("lmm_object_seq: "LPX64"\n", - ostid_seq(&lum->lmm_oi)); + lmm_oi_seq(&lum->lmm_oi)); printf("lmm_stripe_count: %u\n", (int)lum->lmm_stripe_count); printf("lmm_stripe_size: %u\n", lum->lmm_stripe_size); printf("lmm_stripe_pattern: %x\n", lum->lmm_pattern); diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 9c8b751..fefa3c7 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -518,8 +518,8 @@ int lod_generate_and_set_lovea(const struct lu_env *env, lmm->lmm_magic = cpu_to_le32(magic); lmm->lmm_pattern = cpu_to_le32(LOV_PATTERN_RAID0); - fid_to_ostid(fid, &lmm->lmm_oi); - ostid_cpu_to_le(&lmm->lmm_oi, &lmm->lmm_oi); + fid_to_lmm_oi(fid, &lmm->lmm_oi); + lmm_oi_cpu_to_le(&lmm->lmm_oi, &lmm->lmm_oi); lmm->lmm_stripe_size = cpu_to_le32(lo->ldo_stripe_size); lmm->lmm_stripe_count = cpu_to_le16(lo->ldo_stripenr); lmm->lmm_layout_gen = 0; @@ -691,7 +691,9 @@ 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); - ostid_to_fid(&info->lti_fid, &info->lti_ostid, idx); + rc = ostid_to_fid(&info->lti_fid, &info->lti_ostid, idx); + if (rc != 0) + GOTO(out, rc); LASSERTF(fid_is_sane(&info->lti_fid), ""DFID" insane!\n", PFID(&info->lti_fid)); /* diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index 8fa06a6..bbbb3a2 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -393,7 +393,7 @@ static int lod_xattr_get(const struct lu_env *env, struct dt_object *dt, rc = sizeof(struct lov_user_md_v1); } else if (buf->lb_len >= sizeof(struct lov_user_md_v1)) { lum->lmm_magic = LOV_USER_MAGIC_V1; - ostid_set_seq(&lum->lmm_oi, FID_SEQ_LOV_DEFAULT); + lmm_oi_set_seq(&lum->lmm_oi, FID_SEQ_LOV_DEFAULT); lum->lmm_pattern = desc->ld_pattern; lum->lmm_stripe_size = desc->ld_default_stripe_size; lum->lmm_stripe_count = desc->ld_default_stripe_count; @@ -930,8 +930,8 @@ static int lod_declare_object_create(const struct lu_env *env, v3->lmm_magic = cpu_to_le32(LOV_MAGIC_V3); v3->lmm_pattern = cpu_to_le32(LOV_PATTERN_RAID0); - fid_to_ostid(lu_object_fid(&dt->do_lu), &v3->lmm_oi); - ostid_cpu_to_le(&v3->lmm_oi, &v3->lmm_oi); + fid_to_lmm_oi(lu_object_fid(&dt->do_lu), &v3->lmm_oi); + lmm_oi_cpu_to_le(&v3->lmm_oi, &v3->lmm_oi); v3->lmm_stripe_size = cpu_to_le32(lo->ldo_def_stripe_size); v3->lmm_stripe_count = cpu_to_le32(lo->ldo_def_stripenr); v3->lmm_stripe_offset = cpu_to_le16(lo->ldo_def_stripe_offset); diff --git a/lustre/lov/lov_ea.c b/lustre/lov/lov_ea.c index 9f7a423..06e4d9b 100644 --- a/lustre/lov/lov_ea.c +++ b/lustre/lov/lov_ea.c @@ -68,7 +68,7 @@ static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes, return -EINVAL; } - if (ostid_id(&lmm->lmm_oi) == 0) { + if (lmm_oi_id(&lmm->lmm_oi) == 0) { CERROR("zero object id\n"); lov_dump_lmm(D_WARNING, lmm); return -EINVAL; @@ -140,7 +140,7 @@ static void lsm_unpackmd_common(struct lov_stripe_md *lsm, * This supposes lov_mds_md_v1/v3 first fields are * are the same */ - ostid_le_to_cpu(&lmm->lmm_oi, &lsm->lsm_oi); + lmm_oi_le_to_cpu(&lsm->lsm_oi, &lmm->lmm_oi); lsm->lsm_stripe_size = le32_to_cpu(lmm->lmm_stripe_size); lsm->lsm_pattern = le32_to_cpu(lmm->lmm_pattern); lsm->lsm_layout_gen = le16_to_cpu(lmm->lmm_layout_gen); diff --git a/lustre/lov/lov_merge.c b/lustre/lov/lov_merge.c index 3607283..b302efa 100644 --- a/lustre/lov/lov_merge.c +++ b/lustre/lov/lov_merge.c @@ -63,17 +63,16 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm, obd_time current_ctime = lvb->lvb_ctime; int i; int rc = 0; - struct lu_fid fid = {0}; LASSERT_SPIN_LOCKED(&lsm->lsm_lock); #ifdef __KERNEL__ LASSERT(lsm->lsm_lock_owner == cfs_curproc_pid()); #endif - ostid_to_fid(&fid, &lsm->lsm_oi, 0); - CDEBUG(D_INODE, "MDT FID "DFID" initial value: s="LPU64" m="LPU64 - " a="LPU64" c="LPU64" b="LPU64"\n", PFID(&fid), lvb->lvb_size, - lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); + CDEBUG(D_INODE, "MDT ID "DOSTID" initial value: s="LPU64" m="LPU64 + " a="LPU64" c="LPU64" b="LPU64"\n", POSTID(&lsm->lsm_oi), + lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, + lvb->lvb_blocks); for (i = 0; i < lsm->lsm_stripe_count; i++) { struct lov_oinfo *loi = lsm->lsm_oinfo[i]; obd_size lov_size, tmpsize; @@ -103,8 +102,8 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm, if (loi->loi_lvb.lvb_ctime > current_ctime) current_ctime = loi->loi_lvb.lvb_ctime; - CDEBUG(D_INODE, "MDT FID "DFID" on OST[%u]: s="LPU64" m="LPU64 - " a="LPU64" c="LPU64" b="LPU64"\n", PFID(&fid), + CDEBUG(D_INODE, "MDT ID "DOSTID" on OST[%u]: s="LPU64" m="LPU64 + " a="LPU64" c="LPU64" b="LPU64"\n", POSTID(&lsm->lsm_oi), loi->loi_ost_idx, loi->loi_lvb.lvb_size, loi->loi_lvb.lvb_mtime, loi->loi_lvb.lvb_atime, loi->loi_lvb.lvb_ctime, loi->loi_lvb.lvb_blocks); @@ -131,7 +130,6 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm, int lov_merge_lvb(struct obd_export *exp, struct lov_stripe_md *lsm, struct ost_lvb *lvb, int kms_only) { - struct lu_fid fid = {0}; int rc; __u64 kms; @@ -142,9 +140,8 @@ int lov_merge_lvb(struct obd_export *exp, if (kms_only) lvb->lvb_size = kms; - ostid_to_fid(&fid, &lsm->lsm_oi, 0); - CDEBUG(D_INODE, "merged for FID "DFID" s="LPU64" m="LPU64" a="LPU64 - " c="LPU64" b="LPU64"\n", PFID(&fid), lvb->lvb_size, + CDEBUG(D_INODE, "merged for ID "DOSTID" s="LPU64" m="LPU64" a="LPU64 + " c="LPU64" b="LPU64"\n", POSTID(&lsm->lsm_oi), lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); RETURN(rc); } diff --git a/lustre/lov/lov_object.c b/lustre/lov/lov_object.c index ed13cbc..139399d 100644 --- a/lustre/lov/lov_object.c +++ b/lustre/lov/lov_object.c @@ -230,7 +230,11 @@ static int lov_init_raid0(const struct lu_env *env, struct lov_oinfo *oinfo = lsm->lsm_oinfo[i]; int ost_idx = oinfo->loi_ost_idx; - ostid_to_fid(ofid, &oinfo->loi_oi, oinfo->loi_ost_idx); + result = ostid_to_fid(ofid, &oinfo->loi_oi, + oinfo->loi_ost_idx); + if (result != 0) + GOTO(out, result); + subdev = lovsub2cl_dev(dev->ld_target[ost_idx]); subconf->u.coc_oinfo = oinfo; LASSERTF(subdev != NULL, "not init ost %d\n", ost_idx); @@ -250,6 +254,7 @@ static int lov_init_raid0(const struct lu_env *env, } } else result = -ENOMEM; +out: RETURN(result); } diff --git a/lustre/lov/lov_pack.c b/lustre/lov/lov_pack.c index c3ef8c0..d5f829c 100644 --- a/lustre/lov/lov_pack.c +++ b/lustre/lov/lov_pack.c @@ -59,7 +59,7 @@ static void lov_dump_lmm_common(int level, void *lmmp) struct lov_mds_md *lmm = lmmp; struct ost_id oi; - ostid_le_to_cpu(&lmm->lmm_oi, &oi); + lmm_oi_le_to_cpu(&oi, &lmm->lmm_oi); CDEBUG(level, "objid "DOSTID", magic 0x%08x, pattern %#x\n", POSTID(&oi), le32_to_cpu(lmm->lmm_magic), le32_to_cpu(lmm->lmm_pattern)); @@ -222,7 +222,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, /* lmmv1 and lmmv3 point to the same struct and have the * same first fields */ - ostid_cpu_to_le(&lsm->lsm_oi, &lmmv1->lmm_oi); + lmm_oi_cpu_to_le(&lmmv1->lmm_oi, &lsm->lsm_oi); lmmv1->lmm_stripe_size = cpu_to_le32(lsm->lsm_stripe_size); lmmv1->lmm_stripe_count = cpu_to_le16(stripe_count); lmmv1->lmm_pattern = cpu_to_le32(lsm->lsm_pattern); diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index cb89ac4..dfe1cee 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -1079,7 +1079,8 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, struct cl_object *obj; struct lu_fid *fid; int refcheck; - ENTRY; + int rc; + ENTRY; LASSERT(lsmp); lsm = *lsmp; @@ -1114,7 +1115,9 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, conf->eoc_md = lsmp; fid = &info->eti_fid; - ostid_to_fid(fid, &lsm->lsm_oi, 0); + rc = ostid_to_fid(fid, &lsm->lsm_oi, 0); + if (rc != 0) + GOTO(out, eco = ERR_PTR(rc)); /* In the function below, .hs_keycmp resolves to * lu_obj_hop_keycmp() */ @@ -2183,7 +2186,10 @@ static int echo_md_handler(struct echo_device *ed, int command, int stripe_count = (int)data->ioc_obdo2.o_misc; int stripe_index = (int)data->ioc_obdo2.o_stripe_idx; - ostid_to_fid(fid, &data->ioc_obdo1.o_oi, 0); + rc = ostid_to_fid(fid, &data->ioc_obdo1.o_oi, 0); + if (rc != 0) + break; + /* In the function below, .hs_keycmp resolves to * lu_obj_hop_keycmp() */ /* coverity[overrun-buffer-val] */ diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index 8655093..598a551 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -243,7 +243,10 @@ int ofd_preprw(const struct lu_env* env, int cmd, struct obd_export *exp, LASSERT(objcount == 1); LASSERT(obj->ioo_bufcnt > 0); - ostid_to_fid(&info->fti_fid, &oa->o_oi, 0); + rc = ostid_to_fid(&info->fti_fid, &oa->o_oi, 0); + if (unlikely(rc != 0)) + RETURN(rc); + if (cmd == OBD_BRW_WRITE) { rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oa->o_oi), capa, CAPA_OPC_OSS_WRITE); @@ -502,7 +505,9 @@ int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, LASSERT(npages > 0); - ostid_to_fid(&info->fti_fid, &oa->o_oi, 0); + rc = ostid_to_fid(&info->fti_fid, &oa->o_oi, 0); + if (unlikely(rc != 0)) + RETURN(rc); 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_obd.c b/lustre/ofd/ofd_obd.c index 1bc3ccd..ba5ff4d 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -589,7 +589,9 @@ static int ofd_get_info(const struct lu_env *env, struct obd_export *exp, } info = ofd_info_init(env, exp); - ostid_to_fid(&info->fti_fid, &fm_key->oa.o_oi, 0); + rc = ostid_to_fid(&info->fti_fid, &fm_key->oa.o_oi, 0); + if (rc != 0) + RETURN(rc); CDEBUG(D_INODE, "get FIEMAP of object "DFID"\n", PFID(&info->fti_fid)); @@ -642,12 +644,15 @@ static int ofd_get_info(const struct lu_env *env, struct obd_export *exp, if (IS_ERR(oseq)) GOTO(out_fini, rc = PTR_ERR(oseq)); - ostid_to_fid(fid, &oseq->os_oi, + rc = ostid_to_fid(fid, &oseq->os_oi, ofd->ofd_lut.lut_lsd.lsd_osd_index); + if (rc != 0) + GOTO(out_put, rc); CDEBUG(D_HA, "%s: LAST FID is "DFID"\n", ofd_name(ofd), PFID(fid)); *vallen = sizeof(*fid); +out_put: ofd_seq_put(&env, oseq); out_fini: lu_env_fini(&env); @@ -829,9 +834,11 @@ int ofd_setattr(const struct lu_env *env, struct obd_export *exp, info = ofd_info_init(env, exp); ofd_oti2info(info, oti); - ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0); - ost_fid_build_resid(&info->fti_fid, &info->fti_resid); + rc = ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0); + if (rc != 0) + RETURN(rc); + 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); if (rc) @@ -915,7 +922,9 @@ static int ofd_punch(const struct lu_env *env, struct obd_export *exp, info = ofd_info_init(env, exp); ofd_oti2info(info, oti); - ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0); + rc = ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0); + if (rc != 0) + RETURN(rc); ost_fid_build_resid(&info->fti_fid, &info->fti_resid); CDEBUG(D_INODE, "calling punch for object "DFID", valid = "LPX64 @@ -1058,7 +1067,12 @@ int ofd_destroy(const struct lu_env *env, struct obd_export *exp, while (count > 0) { int lrc; - ostid_to_fid(&info->fti_fid, &oa->o_oi, 0); + 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); if (lrc == -ENOENT) { CDEBUG(D_INODE, @@ -1094,6 +1108,7 @@ int ofd_destroy(const struct lu_env *env, struct obd_export *exp, info->fti_transno = 0; } ofd_info2oti(info, oti); +out: RETURN(rc); } @@ -1128,7 +1143,9 @@ static int ofd_orphans_destroy(const struct lu_env *env, for (ostid_set_id(&oi, last); ostid_id(&oi) > end_id; ostid_dec_id(&oi)) { - ostid_to_fid(&info->fti_fid, &oi, 0); + rc = ostid_to_fid(&info->fti_fid, &oi, 0); + if (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("error destroying precreated id "DOSTID": %d\n", @@ -1151,6 +1168,7 @@ static int ofd_orphans_destroy(const struct lu_env *env, ostid_set_id(&oa->o_oi, last); rc = 0; } +out_put: ofd_seq_put(env, oseq); RETURN(rc); } @@ -1346,7 +1364,9 @@ int ofd_getattr(const struct lu_env *env, struct obd_export *exp, info = ofd_info_init(env, exp); - ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0); + rc = ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0); + if (rc != 0) + GOTO(out, rc); rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oinfo->oi_oa->o_oi), oinfo_capa(oinfo), CAPA_OPC_META_READ); if (rc) @@ -1391,7 +1411,9 @@ static int ofd_sync(const struct lu_env *env, struct obd_export *exp, } info = ofd_info_init(env, exp); - ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0); + rc = ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0); + if (rc != 0) + GOTO(out, rc); rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oinfo->oi_oa->o_oi), oinfo_capa(oinfo), CAPA_OPC_OSS_TRUNC); diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 1182531..f2cd2bc 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -2150,20 +2150,26 @@ static void print_lum (struct lov_user_md *lum) CDEBUG(D_OTHER, "lov_user_md %p:\n", lum); CDEBUG(D_OTHER, "\tlmm_magic: %#x\n", lum->lmm_magic); CDEBUG(D_OTHER, "\tlmm_pattern: %#x\n", lum->lmm_pattern); - CDEBUG(D_OTHER, "\tlmm_object_id: "LPU64"\n", ostid_id(&lum->lmm_oi)); - CDEBUG(D_OTHER, "\tlmm_object_gr: "LPU64"\n", ostid_seq(&lum->lmm_oi)); + CDEBUG(D_OTHER, "\tlmm_object_id: "LPU64"\n", lmm_oi_id(&lum->lmm_oi)); + CDEBUG(D_OTHER, "\tlmm_object_gr: "LPU64"\n", lmm_oi_seq(&lum->lmm_oi)); CDEBUG(D_OTHER, "\tlmm_stripe_size: %#x\n", lum->lmm_stripe_size); CDEBUG(D_OTHER, "\tlmm_stripe_count: %#x\n", lum->lmm_stripe_count); CDEBUG(D_OTHER, "\tlmm_stripe_offset/lmm_layout_gen: %#x\n", lum->lmm_stripe_offset); } +static void lustre_swab_lmm_oi(struct ost_id *oi) +{ + __swab64s(&oi->oi.oi_id); + __swab64s(&oi->oi.oi_seq); +} + static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum) { ENTRY; __swab32s(&lum->lmm_magic); __swab32s(&lum->lmm_pattern); - lustre_swab_ost_id(&lum->lmm_oi); + lustre_swab_lmm_oi(&lum->lmm_oi); __swab32s(&lum->lmm_stripe_size); __swab16s(&lum->lmm_stripe_count); __swab16s(&lum->lmm_stripe_offset); @@ -2196,7 +2202,7 @@ void lustre_swab_lov_mds_md(struct lov_mds_md *lmm) CDEBUG(D_IOCTL, "swabbing lov_mds_md\n"); __swab32s(&lmm->lmm_magic); __swab32s(&lmm->lmm_pattern); - lustre_swab_ost_id(&lmm->lmm_oi); + lustre_swab_lmm_oi(&lmm->lmm_oi); __swab32s(&lmm->lmm_stripe_size); __swab16s(&lmm->lmm_stripe_count); __swab16s(&lmm->lmm_layout_gen); diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 7204833..79ba8db 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -2021,8 +2021,8 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path, char nl = is_dir ? ' ' : '\n'; int rc; - if (is_dir && ostid_seq(&lum->lmm_oi) == FID_SEQ_LOV_DEFAULT) { - ostid_set_seq_mdt0(&lum->lmm_oi); + if (is_dir && lmm_oi_seq(&lum->lmm_oi) == FID_SEQ_LOV_DEFAULT) { + lmm_oi_set_seq(&lum->lmm_oi, 0); if (verbose & VERBOSE_DETAIL) llapi_printf(LLAPI_MSG_NORMAL, "(Default) "); } @@ -2034,9 +2034,9 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path, llapi_printf(LLAPI_MSG_NORMAL, "lmm_magic: 0x%08X\n", lum->lmm_magic); llapi_printf(LLAPI_MSG_NORMAL, "lmm_seq: "LPX64"\n", - ostid_seq(&lum->lmm_oi)); + lmm_oi_seq(&lum->lmm_oi)); llapi_printf(LLAPI_MSG_NORMAL, "lmm_object_id: "LPX64"\n", - ostid_id(&lum->lmm_oi)); + lmm_oi_id(&lum->lmm_oi)); } if (verbose & VERBOSE_COUNT) { -- 1.8.3.1