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))
/* 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;
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);
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);
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;
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));
/*
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;
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);
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;
* 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);
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;
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);
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;
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);
}
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);
}
} else
result = -ENOMEM;
+out:
RETURN(result);
}
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));
/* 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);
struct cl_object *obj;
struct lu_fid *fid;
int refcheck;
- ENTRY;
+ int rc;
+ ENTRY;
LASSERT(lsmp);
lsm = *lsmp;
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() */
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] */
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);
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 */
}
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));
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);
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)
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
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,
info->fti_transno = 0;
}
ofd_info2oti(info, oti);
+out:
RETURN(rc);
}
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",
ostid_set_id(&oa->o_oi, last);
rc = 0;
}
+out_put:
ofd_seq_put(env, oseq);
RETURN(rc);
}
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)
}
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);
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);
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);
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) ");
}
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) {