}
EXPORT_SYMBOL(llog_alloc_handle);
+
void llog_free_handle(struct llog_handle *loghandle)
{
if (!loghandle)
}
EXPORT_SYMBOL(llog_free_handle);
-int llog_buf2reclen(int len)
-{
- int size;
-
- size = sizeof(struct llog_rec_hdr) + size_round(len) + sizeof(__u32);
- return size;
-}
-/* Remove a log entry from the catalog.
- * Assumes caller has already pushed us into the kernel context and is locking.
- */
-int llog_delete_log(struct llog_handle *cathandle,struct llog_handle *loghandle)
+int llog_cancel_rec(struct llog_handle *loghandle, int index)
{
- struct llog_cookie *lgc = &loghandle->lgh_log_cat_cookie;
- int catindex = lgc->lgc_index;
- struct llog_log_hdr *llh = cathandle->lgh_hdr;
- loff_t offset = 0;
+ struct llog_log_hdr *llh = loghandle->lgh_hdr;
int rc = 0;
ENTRY;
- CDEBUG(D_HA, "log "LPX64":%x empty, closing\n",
- lgc->lgc_lgl.lgl_oid, lgc->lgc_lgl.lgl_ogen);
+ CDEBUG(D_HA, "canceling %d in log "LPX64"\n",
+ index, loghandle->lgh_id.lgl_oid);
- if (!ext2_clear_bit(catindex, llh->llh_bitmap)) {
- CERROR("catalog index %u already clear?\n", catindex);
+ if (!ext2_clear_bit(index, llh->llh_bitmap)) {
+ CERROR("catalog index %u already clear?\n", index);
LBUG();
} else {
- rc = lustre_fwrite(cathandle->lgh_file, llh, sizeof(*llh),
- &offset);
-
- if (rc != sizeof(*llh)) {
- CERROR("log %u cancel error: rc %d\n", catindex, rc);
- if (rc >= 0)
- rc = -EIO;
- } else
- rc = 0;
+ rc = llog_write_rec(loghandle, &llh->llh_hdr, NULL, 0, NULL, 0);
+ if (rc)
+ CERROR("failure re-writing header %d\n", rc);
+ LASSERT(rc == 0);
}
RETURN(rc);
}
-EXPORT_SYMBOL(llog_delete_log);
+
int llog_process_log(struct llog_handle *loghandle, llog_cb_t cb, void *data)
{
llh->llh_bitmap_offset = offsetof(typeof(*llh), llh_bitmap);
/* write the header record in the log */
- rc = llog_write_record(loghandle, &llh, NULL, NULL, 0);
+ rc = llog_write_rec(loghandle, &llh->llh_hdr, NULL, 0, NULL, 0);
if (rc > 0)
rc = 0;
RETURN(rc);
}
-EXPORT_SYMBOL(llog_write_header);
#include <linux/obd_class.h>
#include <linux/lustre_log.h>
#include <portals/list.h>
-
+#include <linux/lvfs.h>
static int llog_lvfs_pad(struct l_file *file, int len, int index)
{
struct llog_rec_hdr rec;
struct llog_rec_tail tail;
+ int rc;
ENTRY;
LASSERT(len >= LLOG_MIN_REC_SIZE && (len & 0xf) == 0);
RETURN(-EINVAL);
rc = llog_lvfs_write_blob(file, llh, NULL, 0);
- if (rc)
+ /* we are done if we only write the header or on error */
+ if (rc || idx == 0)
RETURN(rc);
saved_offset = sizeof(*llh) + idx * rec->lrh_len;