From 5dca0371d2ce9c4f54c31a9c88223a4eed77ecde Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Mon, 8 Oct 2012 14:33:29 +0800 Subject: [PATCH] LU-2041 oi: keep oi mapping cache consistency Sometimes the local ID of the per RPC thread OI mappig cache may be changed, but the FID of such OI mapping cache has not been updated, which will cause the RPC thread finds some unexpected object with the given FID, should be fixed. Signed-off-by: Fan Yong Change-Id: I90cc01601925ada08e0f021ba49e3310f10aed35 Reviewed-on: http://review.whamcloud.com/4208 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Liang Zhen Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin --- lustre/osd-ldiskfs/osd_handler.c | 25 +++++++++++++++---------- lustre/osd-ldiskfs/osd_scrub.c | 11 ++++++++--- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 2cf7076..1ebf741 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -287,7 +287,7 @@ osd_iget_verify(struct osd_thread_info *info, struct osd_device *dev, CDEBUG(D_LFSCK, "inconsistent obj: "DFID", %lu, "DFID"\n", PFID(&lma->lma_self_fid), inode->i_ino, PFID(fid)); iput(inode); - return ERR_PTR(EREMCHG); + return ERR_PTR(-EREMCHG); } return inode; @@ -319,15 +319,18 @@ static int osd_fid_lookup(const struct lu_env *env, struct osd_object *obj, info = osd_oti_get(env); LASSERT(info); oic = &info->oti_cache; - id = &oic->oic_lid; if (OBD_FAIL_CHECK(OBD_FAIL_OST_ENOENT)) RETURN(-ENOENT); /* Search order: 1. per-thread cache. */ if (lu_fid_eq(fid, &oic->oic_fid)) { + id = &oic->oic_lid; goto iget; - } else if (!cfs_list_empty(&scrub->os_inconsistent_items)) { + } + + id = &info->oti_id; + if (!cfs_list_empty(&scrub->os_inconsistent_items)) { /* Search order: 2. OI scrub pending list. */ result = osd_oii_lookup(dev, fid, id); if (result == 0) @@ -3328,7 +3331,7 @@ static int osd_ea_add_rec(const struct lu_env *env, struct osd_object *pobj, return rc; } -static int +static void osd_consistency_check(struct osd_thread_info *oti, struct osd_device *dev, struct osd_idmap_cache *oic) { @@ -3340,15 +3343,15 @@ osd_consistency_check(struct osd_thread_info *oti, struct osd_device *dev, ENTRY; if (!fid_is_norm(fid) && !fid_is_igif(fid)) - RETURN(0); + RETURN_EXIT; again: rc = osd_oi_lookup(oti, dev, fid, id); if (rc != 0 && rc != -ENOENT) - RETURN(rc); + RETURN_EXIT; if (rc == 0 && osd_id_eq(id, &oic->oic_lid)) - RETURN(0); + RETURN_EXIT; if (thread_is_running(&scrub->os_thread)) { rc = osd_oii_insert(dev, oic, rc == -ENOENT); @@ -3359,7 +3362,7 @@ again: if (unlikely(rc == -EAGAIN)) goto again; - RETURN(rc); + RETURN_EXIT; } if (!dev->od_noscrub && ++once == 1) { @@ -3374,7 +3377,7 @@ again: goto again; } - RETURN(0); + EXIT; } /** @@ -4159,8 +4162,10 @@ static inline int osd_it_ea_rec(const struct lu_env *env, if (!fid_is_sane(fid)) { rc = osd_ea_fid_get(env, obj, ino, fid, &oic->oic_lid); - if (rc != 0) + if (rc != 0) { + fid_zero(&oic->oic_fid); RETURN(rc); + } } else { osd_id_gen(&oic->oic_lid, ino, OSD_OII_NOGEN); } diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index 352cdb8..e6eca1e 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -385,12 +385,15 @@ iget: GOTO(out, rc = -ENOMEM); } - if (ops == DTO_INDEX_UPDATE) + if (ops == DTO_INDEX_UPDATE) { rc = iam_update(jh, bag, (const struct iam_key *)oi_fid, (struct iam_rec *)oi_id, ipd); - else + } else { rc = iam_insert(jh, bag, (const struct iam_key *)oi_fid, (struct iam_rec *)oi_id, ipd); + if (rc == -EEXIST) + rc = 1; + } osd_ipd_put(info->oti_env, bag, ipd); ldiskfs_journal_stop(jh); if (rc == 0) { @@ -403,11 +406,13 @@ iget: GOTO(out, rc); out: - if (rc != 0) { + if (rc < 0) { sf->sf_items_failed++; if (sf->sf_pos_first_inconsistent == 0 || sf->sf_pos_first_inconsistent > lid->oii_ino) sf->sf_pos_first_inconsistent = lid->oii_ino; + } else { + rc = 0; } if (ops == DTO_INDEX_INSERT) { -- 1.8.3.1