Whamcloud - gitweb
Allow GSS password to be passed to the test-framework in $GSS_PASS.
[fs/lustre-release.git] / lustre / lvfs / llog_cat.c
index 3837b4d..b7a5c8f 100644 (file)
@@ -39,7 +39,7 @@
 #endif
 
 #include <linux/lustre_log.h>
-#include <portals/list.h>
+#include <libcfs/list.h>
 
 /* Create a new log handle and add it to the open list.
  * This log handle will be closed when all of the records in it are removed.
@@ -56,7 +56,7 @@ static struct llog_handle *llog_cat_new_log(struct llog_handle *cathandle,
         ENTRY;
 
         llh = cathandle->lgh_hdr;
-        bitmap_size = sizeof(llh->llh_bitmap) * 8;
+        bitmap_size = LLOG_BITMAP_SIZE(llh);
 
         index = (cathandle->lgh_last_idx + 1) % bitmap_size;
 
@@ -223,13 +223,15 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle,
         loghandle = cathandle->u.chd.chd_current_log;
         if (loghandle) {
                 struct llog_log_hdr *llh = loghandle->lgh_hdr;
-                if (loghandle->lgh_last_idx < (sizeof(llh->llh_bitmap)*8) - 1 &&
+                down_write(&loghandle->lgh_lock);
+                if (loghandle->lgh_last_idx < (LLOG_BITMAP_SIZE(llh) - 1) &&
                     (!logcookie ||
                      !(llog_cookie_get_flags(logcookie) & LLOG_COOKIE_REPLAY) ||
                      EQ_LOGID(loghandle->lgh_id, logcookie->lgc_lgl))) {
-                        down_write(&loghandle->lgh_lock);
                         up_read(&cathandle->lgh_lock);
                         RETURN(loghandle);
+                } else {
+                        up_write(&loghandle->lgh_lock);
                 }
         }
 
@@ -252,13 +254,15 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle,
         loghandle = cathandle->u.chd.chd_current_log;
         if (loghandle) {
                 struct llog_log_hdr *llh = loghandle->lgh_hdr;
-                if (loghandle->lgh_last_idx < (sizeof(llh->llh_bitmap)*8) - 1 &&
+                down_write(&loghandle->lgh_lock);
+                if (loghandle->lgh_last_idx < (LLOG_BITMAP_SIZE(llh) - 1) &&
                     (!logcookie ||
                      !(llog_cookie_get_flags(logcookie) & LLOG_COOKIE_REPLAY) ||
                      EQ_LOGID(loghandle->lgh_id, logcookie->lgc_lgl))) {
-                        down_write(&loghandle->lgh_lock);
                         up_write(&cathandle->lgh_lock);
                         RETURN(loghandle);
+                } else {
+                        up_write(&loghandle->lgh_lock);
                 }
         }
 
@@ -485,7 +489,7 @@ int llog_cat_set_first_idx(struct llog_handle *cathandle, int index)
         int i, bitmap_size, idx;
         ENTRY;
 
-        bitmap_size = sizeof(llh->llh_bitmap) * 8;
+        bitmap_size = LLOG_BITMAP_SIZE(llh);
         if (llh->llh_cat_idx == cpu_to_le32(index - 1)) {
                 idx = le32_to_cpu(llh->llh_cat_idx) + 1;
                 llh->llh_cat_idx = cpu_to_le32(idx);
@@ -621,8 +625,7 @@ int llog_catalog_cleanup(struct llog_ctxt *ctxt)
         cathandle = ctxt->loc_handle;
         if (cathandle)
                 llog_cat_put(ctxt->loc_handle);
-//        OBD_FREE(ctxt, sizeof(*ctxt));
+
         return 0;
 }
 EXPORT_SYMBOL(llog_catalog_cleanup);