Whamcloud - gitweb
LU-2657 recovery: don't delete objects
authorNiu Yawei <niu@whamcloud.com>
Wed, 30 Jan 2013 02:24:04 +0000 (21:24 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 20 Feb 2013 02:36:10 +0000 (21:36 -0500)
In mds_lov_update_objids(), when an data object id gap is
detected during recovery, it'll delete all the objects in
the gap, which isn't quite correct, because we can't guarantee
that the id is always increased by the transno order,
furthermore, that could also bring big trouble when the
lov_objid file was removed manually (to rebuild the corrupted
lov_objid file).

Fix type defect in filter_recov_log_unlink_cb(), where
oa->o_id should be increased by each loop cycle.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: I7553614f30fe60675b8dab405d9100cb63069b23
Reviewed-on: http://review.whamcloud.com/5206
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mds/mds_lov.c
lustre/obdfilter/filter_log.c

index 5519395..ca69f13 100644 (file)
@@ -271,44 +271,11 @@ int mds_lov_prepare_objids(struct obd_device *obd, struct lov_mds_md *lmm)
 }
 EXPORT_SYMBOL(mds_lov_prepare_objids);
 
-/*
- * write llog orphan record about lost ost object,
- * Special lsm is allocated with single stripe, caller should deallocated it
- * after use
- */
-static int mds_log_lost_precreated(struct obd_device *obd,
-                                   struct lov_stripe_md **lsmp, int *stripes,
-                                   obd_id id, obd_count count, int idx)
-{
-        struct lov_stripe_md *lsm = *lsmp;
-        int rc;
-        ENTRY;
-
-        if (*lsmp == NULL) {
-                rc = obd_alloc_memmd(obd->u.mds.mds_lov_exp, &lsm);
-                if (rc < 0)
-                        RETURN(rc);
-                /* need only one stripe, save old value */
-                *stripes = lsm->lsm_stripe_count;
-                lsm->lsm_stripe_count = 1;
-                *lsmp = lsm;
-        }
-
-        lsm->lsm_oinfo[0]->loi_id = id;
-        lsm->lsm_oinfo[0]->loi_seq = mdt_to_obd_objseq(obd->u.mds.mds_id);
-        lsm->lsm_oinfo[0]->loi_ost_idx = idx;
-
-        rc = mds_log_op_orphan(obd, lsm, count);
-        RETURN(rc);
-}
-
 void mds_lov_update_objids(struct obd_device *obd, struct lov_mds_md *lmm)
 {
         struct mds_obd *mds = &obd->u.mds;
         int j;
         struct lov_ost_data_v1 *obj;
-        struct lov_stripe_md *lsm = NULL;
-        int stripes = 0;
         int count;
         ENTRY;
 
@@ -344,24 +311,17 @@ void mds_lov_update_objids(struct obd_device *obd, struct lov_mds_md *lmm)
                        " - new "LPU64" old "LPU64"\n", i, id, data[idx]);
                 if (id > data[idx]) {
                         int lost = id - data[idx] - 1;
-                        /* we might have lost precreated objects due to VBR */
                         if (lost > 0 && obd->obd_recovering) {
-                                CDEBUG(D_HA, "Gap in objids is %u\n", lost);
-                                if (!obd->obd_version_recov)
-                                        CERROR("Unexpected gap in objids\n");
-                                /* lsm is allocated if NULL */
-                                mds_log_lost_precreated(obd, &lsm, &stripes,
-                                                        data[idx]+1, lost, i);
+                                CDEBUG(obd->obd_version_recov ? D_HA:D_WARNING,
+                                       "Gap in objids for OST%d, "
+                                       "next id on disk: "LPU64", "
+                                       "id to be allocated: "LPU64", "
+                                       "lost: %d\n", i, data[idx], id, lost);
                         }
                         data[idx] = id;
                         cfs_bitmap_set(mds->mds_lov_page_dirty, page);
                 }
         }
-        if (lsm) {
-                /* restore stripes number */
-                lsm->lsm_stripe_count = stripes;
-                obd_free_memmd(mds->mds_lov_exp, &lsm);
-        }
         EXIT;
         return;
 }
index a03bd26..3e89517 100644 (file)
@@ -159,7 +159,6 @@ static int filter_recov_log_unlink_cb(struct llog_ctxt *ctxt,
         struct obd_export *exp = ctxt->loc_obd->obd_self_export;
         struct llog_unlink_rec *lur;
         struct obdo *oa;
-        obd_id oid;
         obd_count count;
         int rc = 0;
         ENTRY;
@@ -173,7 +172,6 @@ static int filter_recov_log_unlink_cb(struct llog_ctxt *ctxt,
         oa->o_seq = lur->lur_oseq;
         oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
         oa->o_lcookie = *cookie;
-        oid = oa->o_id;
         /* objid gap may require to destroy several objects in row */
         count = lur->lur_count + 1;
 
@@ -189,14 +187,14 @@ static int filter_recov_log_unlink_cb(struct llog_ctxt *ctxt,
                 rc = filter_destroy(exp, oa, NULL, NULL, NULL, NULL);
                 if (rc == 0)
                         CDEBUG(D_RPCTRACE, "object "LPU64" is destroyed\n",
-                               oid);
+                               oa->o_id);
                 else if (rc != -ENOENT)
                         CEMERG("error destroying object "LPU64": %d\n",
-                               oid, rc);
+                               oa->o_id, rc);
                 else
                         rc = 0;
                 count--;
-                oid++;
+                oa->o_id++;
         }
         OBDO_FREE(oa);