Whamcloud - gitweb
Added ll_recover_lost_found_objs to .cvsignore
[fs/lustre-release.git] / lustre / obdclass / llog_cat.c
index dafcb23..fdc7248 100644 (file)
@@ -181,7 +181,7 @@ int llog_cat_id2handle(struct llog_handle *cathandle, struct llog_handle **res,
         if (!rc) {
                 loghandle->u.phd.phd_cat_handle = cathandle;
                 loghandle->u.phd.phd_cookie.lgc_lgl = cathandle->lgh_id;
-                loghandle->u.phd.phd_cookie.lgc_index = 
+                loghandle->u.phd.phd_cookie.lgc_index =
                         loghandle->lgh_hdr->llh_cat_idx;
         }
 
@@ -293,6 +293,8 @@ int llog_cat_add_rec(struct llog_handle *cathandle, struct llog_rec_hdr *rec,
                 RETURN(PTR_ERR(loghandle));
         /* loghandle is already locked by llog_cat_current_log() for us */
         rc = llog_write_rec(loghandle, rec, reccookie, 1, buf, -1);
+        if (rc < 0)
+                CERROR("llog_write_rec %d: lh=%p\n", rc, loghandle);
         up_write(&loghandle->lgh_lock);
         if (rc == -ENOSPC) {
                 /* to create a new plain log */
@@ -317,7 +319,7 @@ EXPORT_SYMBOL(llog_cat_add_rec);
  * Assumes caller has already pushed us into the kernel context.
  */
 int llog_cat_cancel_records(struct llog_handle *cathandle, int count,
-                        struct llog_cookie *cookies)
+                            struct llog_cookie *cookies)
 {
         int i, index, rc = 0;
         ENTRY;
@@ -382,14 +384,29 @@ int llog_cat_process_cb(struct llog_handle *cat_llh, struct llog_rec_hdr *rec,
                 RETURN(rc);
         }
 
-        rc = llog_process(llh, d->lpd_cb, d->lpd_data, NULL);
+        if (rec->lrh_index < d->lpd_startcat)
+                /* Skip processing of the logs until startcat */
+                RETURN(0);
+
+        if (d->lpd_startidx > 0) {
+                struct llog_process_cat_data cd;
+
+                cd.lpcd_first_idx = d->lpd_startidx;
+                cd.lpcd_last_idx = 0;
+                rc = llog_process(llh, d->lpd_cb, d->lpd_data, &cd);
+                /* Continue processing the next log from idx 0 */
+                d->lpd_startidx = 0;
+        } else {
+                rc = llog_process(llh, d->lpd_cb, d->lpd_data, NULL);
+        }
+
         RETURN(rc);
 }
 
-int llog_cat_process(struct llog_handle *cat_llh, llog_cb_t cb, void *data)
+int llog_cat_process(struct llog_handle *cat_llh, llog_cb_t cb, void *data,
+                     int startcat, int startidx)
 {
         struct llog_process_data d;
-        struct llog_process_cat_data cd;
         struct llog_log_hdr *llh = cat_llh->lgh_hdr;
         int rc;
         ENTRY;
@@ -397,8 +414,12 @@ int llog_cat_process(struct llog_handle *cat_llh, llog_cb_t cb, void *data)
         LASSERT(llh->llh_flags & LLOG_F_IS_CAT);
         d.lpd_data = data;
         d.lpd_cb = cb;
+        d.lpd_startcat = startcat;
+        d.lpd_startidx = startidx;
 
         if (llh->llh_cat_idx > cat_llh->lgh_last_idx) {
+                struct llog_process_cat_data cd;
+
                 CWARN("catlog "LPX64" crosses index zero\n",
                       cat_llh->lgh_id.lgl_oid);
 
@@ -425,7 +446,7 @@ int llog_cat_process_thread(void *data)
         struct llog_process_cat_args *args = data;
         struct llog_ctxt *ctxt = args->lpca_ctxt;
         struct llog_handle *llh = NULL;
-        void  *cb = args->lpca_cb;
+        llog_cb_t cb = args->lpca_cb;
         struct llog_logid logid;
         int rc;
         ENTRY;
@@ -445,15 +466,16 @@ int llog_cat_process_thread(void *data)
         }
 
         if (cb) {
-                rc = llog_cat_process(llh, (llog_cb_t)cb, NULL);
-                if (rc != LLOG_PROC_BREAK)
+                rc = llog_cat_process(llh, cb, NULL, 0, 0);
+                if (rc != LLOG_PROC_BREAK && rc != 0)
                         CERROR("llog_cat_process() failed %d\n", rc);
+                cb(llh, NULL, NULL);
         } else {
                 CWARN("No callback function for recovery\n");
         }
 
-        /* 
-         * Make sure that all cached data is sent. 
+        /*
+         * Make sure that all cached data is sent.
          */
         llog_sync(ctxt, NULL);
         GOTO(release_llh, rc);