From 88025e16f9b316577ec17ec046381c0694c1d27a Mon Sep 17 00:00:00 2001 From: wang di Date: Fri, 7 Mar 2014 12:30:02 -0800 Subject: [PATCH] LU-4653 fid: only compare non-IDIF seq in lu_fid_diff Because it will pack OST index into IDIF FID in 2.6, and in 2.4/2.5, the OST index in IDIF FID is always 0. So we only compare non-IDIF sequence in lu_fid_diff. Signed-off-by: wang di Change-Id: I430210819c1cd7257094f51ef364f50d5291361c Reviewed-on: http://review.whamcloud.com/9560 Tested-by: Jenkins Reviewed-by: Fan Yong Tested-by: Maloo Reviewed-by: Mike Pershin Reviewed-by: Andreas Dilger --- lustre/osp/osp_internal.h | 27 ++++++++++++++++++++++++++- lustre/osp/osp_precreate.c | 29 ++++++----------------------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/lustre/osp/osp_internal.h b/lustre/osp/osp_internal.h index 1291374..f2f2a2c 100644 --- a/lustre/osp/osp_internal.h +++ b/lustre/osp/osp_internal.h @@ -394,9 +394,34 @@ static inline struct seq_server_site *osp_seq_site(struct osp_device *osp) #define osp_get_rpc_lock(lck, it) mdc_get_rpc_lock(lck, it) #define osp_put_rpc_lock(lck, it) mdc_put_rpc_lock(lck, it) +static inline int osp_fid_diff(const struct lu_fid *fid1, + const struct lu_fid *fid2) +{ + /* In 2.6+ ost_idx is packed into IDIF FID, while in 2.4 and 2.5 IDIF + * is always FID_SEQ_IDIF(0x100000000ULL), which does not include OST + * index in the seq. So we can not compare IDIF FID seq here */ + if (fid_is_idif(fid1) && fid_is_idif(fid2)) { + __u32 ost_idx1 = fid_idif_ost_idx(fid1); + __u32 ost_idx2 = fid_idif_ost_idx(fid2); + + LASSERTF(ost_idx1 == 0 || ost_idx2 == 0 || ost_idx1 == ost_idx2, + "fid1: "DFID", fid2: "DFID"\n", PFID(fid1), + PFID(fid2)); + + return fid_idif_id(fid1->f_seq, fid1->f_oid, 0) - + fid_idif_id(fid2->f_seq, fid2->f_oid, 0); + } + + LASSERTF(fid_seq(fid1) == fid_seq(fid2), "fid1:"DFID + ", fid2:"DFID"\n", PFID(fid1), PFID(fid2)); + + return fid_oid(fid1) - fid_oid(fid2); +} + + static inline void osp_update_last_fid(struct osp_device *d, struct lu_fid *fid) { - int diff = lu_fid_diff(fid, &d->opd_last_used_fid); + int diff = osp_fid_diff(fid, &d->opd_last_used_fid); /* * we might have lost precreated objects due to VBR and precreate * orphans, the gap in objid can be calculated properly only here diff --git a/lustre/osp/osp_precreate.c b/lustre/osp/osp_precreate.c index 6eb22c7..321c4fb 100644 --- a/lustre/osp/osp_precreate.c +++ b/lustre/osp/osp_precreate.c @@ -200,25 +200,8 @@ void osp_statfs_need_now(struct osp_device *d) static inline int osp_objs_precreated(const struct lu_env *env, struct osp_device *osp) { - struct lu_fid *fid1 = &osp->opd_pre_last_created_fid; - struct lu_fid *fid2 = &osp->opd_pre_used_fid; - - LASSERTF(fid_seq(fid1) == fid_seq(fid2), - "Created fid"DFID" Next fid "DFID"\n", PFID(fid1), PFID(fid2)); - - if (fid_is_idif(fid1)) { - struct ost_id *oi1 = &osp_env_info(env)->osi_oi; - struct ost_id *oi2 = &osp_env_info(env)->osi_oi2; - - LASSERT(fid_is_idif(fid1) && fid_is_idif(fid2)); - fid_to_ostid(fid1, oi1); - fid_to_ostid(fid2, oi2); - LASSERT(ostid_id(oi1) >= ostid_id(oi2)); - - return ostid_id(oi1) - ostid_id(oi2); - } - - return fid_oid(fid1) - fid_oid(fid2); + return osp_fid_diff(&osp->opd_pre_last_created_fid, + &osp->opd_pre_used_fid); } static inline int osp_precreate_near_empty_nolock(const struct lu_env *env, @@ -490,11 +473,11 @@ static int osp_precreate_send(const struct lu_env *env, struct osp_device *d) GOTO(out_req, rc = -EPROTO); ostid_to_fid(fid, &body->oa.o_oi, d->opd_index); - LASSERTF(lu_fid_diff(fid, &d->opd_pre_used_fid) > 0, + LASSERTF(osp_fid_diff(fid, &d->opd_pre_used_fid) > 0, "reply fid "DFID" pre used fid "DFID"\n", PFID(fid), PFID(&d->opd_pre_used_fid)); - diff = lu_fid_diff(fid, &d->opd_pre_last_created_fid); + diff = osp_fid_diff(fid, &d->opd_pre_last_created_fid); spin_lock(&d->opd_pre_lock); if (diff < grow) { @@ -696,7 +679,7 @@ static int osp_precreate_cleanup_orphans(struct lu_env *env, ostid_to_fid(last_fid, &body->oa.o_oi, d->opd_index); spin_lock(&d->opd_pre_lock); - diff = lu_fid_diff(&d->opd_last_used_fid, last_fid); + diff = osp_fid_diff(&d->opd_last_used_fid, last_fid); if (diff > 0) { d->opd_pre_grow_count = OST_MIN_PRECREATE + diff; d->opd_pre_last_created_fid = d->opd_last_used_fid; @@ -1149,7 +1132,7 @@ int osp_precreate_get_fid(const struct lu_env *env, struct osp_device *d, /* grab next id from the pool */ spin_lock(&d->opd_pre_lock); - LASSERTF(lu_fid_diff(&d->opd_pre_used_fid, + LASSERTF(osp_fid_diff(&d->opd_pre_used_fid, &d->opd_pre_last_created_fid) < 0, "next fid "DFID" last created fid "DFID"\n", PFID(&d->opd_pre_used_fid), -- 1.8.3.1