Whamcloud - gitweb
- fixes to the api's
authorbraam <braam>
Mon, 8 Sep 2003 04:07:01 +0000 (04:07 +0000)
committerbraam <braam>
Mon, 8 Sep 2003 04:07:01 +0000 (04:07 +0000)
lustre/include/linux/lvfs.h
lustre/obdclass/llog.c
lustre/obdclass/llog_cat.c
lustre/obdclass/llog_lvfs.c

index 17d876f..722f600 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __LVFS_H__
 #define __LVFS_H__
 
-#if defined __LINUX__ && defined __KERNEL__
+#if defined __KERNEL__
 #include <linux/lvfs_linux.h>
 #endif 
 
index 21058ea..cea4987 100644 (file)
@@ -60,6 +60,7 @@ struct llog_handle *llog_alloc_handle(void)
 }
 EXPORT_SYMBOL(llog_alloc_handle);
 
+
 void llog_free_handle(struct llog_handle *loghandle)
 {
         if (!loghandle)
@@ -71,46 +72,28 @@ void llog_free_handle(struct llog_handle *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)
 {
@@ -183,9 +166,8 @@ int llog_write_header(struct llog_handle *loghandle, int size)
         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);
index 4180ab2..024c78f 100644 (file)
@@ -148,6 +148,8 @@ out:
         RETURN(rc);
 }
 
+
+
 /* Assumes caller has already pushed us into the kernel context. */
 int llog_cat_init(struct llog_handle *cathandle, struct obd_uuid *tgtuuid)
 {
index 57957e0..394207d 100644 (file)
 #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);
@@ -147,7 +148,8 @@ int llog_lvfs_write_record(struct llog_handle *loghandle,
                         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;