#define DEBUG_SUBSYSTEM S_LOG
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_class.h>
}
down_write(&cathandle->lgh_lock);
- list_add(&loghandle->u.phd.phd_entry, &cathandle->u.chd.chd_head);
+ list_add_tail(&loghandle->u.phd.phd_entry, &cathandle->u.chd.chd_head);
up_write(&cathandle->lgh_lock);
loghandle->u.phd.phd_cat_handle = cathandle;
CERROR("%s: cannot find handle for llog "DOSTID": %d\n",
cat_llh->lgh_ctxt->loc_obd->obd_name,
POSTID(&lir->lid_id.lgl_oi), rc);
+ if (rc == -ENOENT || rc == -ESTALE) {
+ /* After a server crash, a stub of index
+ * record in catlog could be kept, because
+ * plain log destroy + catlog index record
+ * deletion are not atomic. So we end up with
+ * an index but no actual record. Destroy the
+ * index and move on. */
+ rc = llog_cat_cleanup(env, cat_llh, NULL,
+ rec->lrh_index);
+ }
+
RETURN(rc);
}
CERROR("%s: cannot find handle for llog "DOSTID": %d\n",
cat_llh->lgh_ctxt->loc_obd->obd_name,
POSTID(&lir->lid_id.lgl_oi), rc);
+ if (rc == -ENOENT || rc == -ESTALE) {
+ /* After a server crash, a stub of index
+ * record in catlog could be kept, because
+ * plain log destroy + catlog index record
+ * deletion are not atomic. So we end up with
+ * an index but no actual record. Destroy the
+ * index and move on. */
+ rc = llog_cat_cleanup(env, cat_llh, NULL,
+ rec->lrh_index);
+ }
+
RETURN(rc);
}