Whamcloud - gitweb
Branch: b_new_cmd
authorwangdi <wangdi>
Tue, 24 Oct 2006 11:50:28 +0000 (11:50 +0000)
committerwangdi <wangdi>
Tue, 24 Oct 2006 11:50:28 +0000 (11:50 +0000)
we should update cat log hdr only after we successfully create the new log,
otherwise the index will be wrong, when disk full, which maybe cause lbug later

lustre/obdclass/llog_cat.c

index 55039cc..6c61ff6 100644 (file)
@@ -65,21 +65,10 @@ static struct llog_handle *llog_cat_new_log(struct llog_handle *cathandle)
         if (llh->llh_cat_idx == index) {
                 CERROR("no free catalog slots for log...\n");
                 RETURN(ERR_PTR(-ENOSPC));
-        } else {
-                if (index == 0)
-                        index = 1;
-                if (ext2_set_bit(index, llh->llh_bitmap)) {
-                        CERROR("argh, index %u already set in log bitmap?\n",
-                               index);
-                        LBUG(); /* should never happen */
-                }
-                cathandle->lgh_last_idx = index;
-                llh->llh_count++;
-                llh->llh_tail.lrt_index = index;
         }
-
         rc = llog_create(cathandle->lgh_ctxt, &loghandle, NULL, NULL);
-        if (rc)
+        if (rc) 
                 RETURN(ERR_PTR(rc));
 
         rc = llog_init_handle(loghandle,
@@ -88,6 +77,16 @@ static struct llog_handle *llog_cat_new_log(struct llog_handle *cathandle)
         if (rc)
                 GOTO(out_destroy, rc);
 
+        if (index == 0)
+                index = 1;
+        if (ext2_set_bit(index, llh->llh_bitmap)) {
+                CERROR("argh, index %u already set in log bitmap?\n",
+                       index);
+                LBUG(); /* should never happen */
+        }
+        cathandle->lgh_last_idx = index;
+        llh->llh_count++;
+        llh->llh_tail.lrt_index = index;
         CDEBUG(D_HA, "new recovery log "LPX64":%x for index %u of catalog "
                LPX64"\n", loghandle->lgh_id.lgl_oid, loghandle->lgh_id.lgl_ogen,
                index, cathandle->lgh_id.lgl_oid);