Whamcloud - gitweb
LU-1302 llog: structures changes, llog_thread_info
[fs/lustre-release.git] / lustre / obdclass / llog_obd.c
index 04b994c..aa9c3c0 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,6 +26,8 @@
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 
 #define DEBUG_SUBSYSTEM S_LOG
 
 
 #define DEBUG_SUBSYSTEM S_LOG
 
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
-
 #ifndef __KERNEL__
 #include <liblustre.h>
 #endif
 #ifndef __KERNEL__
 #include <liblustre.h>
 #endif
@@ -136,7 +132,7 @@ int llog_cleanup(struct llog_ctxt *ctxt)
         /* 
          * Banlance the ctxt get when calling llog_cleanup()
          */
         /* 
          * Banlance the ctxt get when calling llog_cleanup()
          */
-        LASSERT(cfs_atomic_read(&ctxt->loc_refcount) < 0x5a5a5a);
+        LASSERT(cfs_atomic_read(&ctxt->loc_refcount) < LI_POISON);
         LASSERT(cfs_atomic_read(&ctxt->loc_refcount) > 1);
         llog_ctxt_put(ctxt);
 
         LASSERT(cfs_atomic_read(&ctxt->loc_refcount) > 1);
         llog_ctxt_put(ctxt);
 
@@ -177,7 +173,7 @@ int llog_setup_named(struct obd_device *obd,  struct obd_llog_group *olg,
         ctxt->loc_olg = olg;
         ctxt->loc_idx = index;
         ctxt->loc_logops = op;
         ctxt->loc_olg = olg;
         ctxt->loc_idx = index;
         ctxt->loc_logops = op;
-        cfs_sema_init(&ctxt->loc_sem, 1);
+        cfs_mutex_init(&ctxt->loc_mutex);
         ctxt->loc_exp = class_export_get(disk_obd->obd_self_export);
         ctxt->loc_flags = LLOG_CTXT_FLAG_UNINITIALIZED;
 
         ctxt->loc_exp = class_export_get(disk_obd->obd_self_export);
         ctxt->loc_flags = LLOG_CTXT_FLAG_UNINITIALIZED;
 
@@ -235,7 +231,7 @@ int llog_setup(struct obd_device *obd,  struct obd_llog_group *olg,
 }
 EXPORT_SYMBOL(llog_setup);
 
 }
 EXPORT_SYMBOL(llog_setup);
 
-int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp)
+int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp, int flags)
 {
         int rc = 0;
         ENTRY;
 {
         int rc = 0;
         ENTRY;
@@ -244,7 +240,7 @@ int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp)
                 RETURN(0);
 
         if (CTXTP(ctxt, sync))
                 RETURN(0);
 
         if (CTXTP(ctxt, sync))
-                rc = CTXTP(ctxt, sync)(ctxt, exp);
+               rc = CTXTP(ctxt, sync)(ctxt, exp, flags);
 
         RETURN(rc);
 }
 
         RETURN(rc);
 }
@@ -316,6 +312,10 @@ static int cat_cancel_cb(struct llog_handle *cathandle,
         if (rc) {
                 CERROR("Cannot find handle for log "LPX64"\n",
                        lir->lid_id.lgl_oid);
         if (rc) {
                 CERROR("Cannot find handle for log "LPX64"\n",
                        lir->lid_id.lgl_oid);
+                if (rc == -ENOENT) {
+                        index = rec->lrh_index;
+                        goto cat_cleanup;
+                }
                 RETURN(rc);
         }
 
                 RETURN(rc);
         }
 
@@ -329,6 +329,7 @@ static int cat_cancel_cb(struct llog_handle *cathandle,
                 index = loghandle->u.phd.phd_cookie.lgc_index;
                 llog_free_handle(loghandle);
 
                 index = loghandle->u.phd.phd_cookie.lgc_index;
                 llog_free_handle(loghandle);
 
+cat_cleanup:
                 LASSERT(index);
                 llog_cat_set_first_idx(cathandle, index);
                 rc = llog_cancel_rec(cathandle, index);
                 LASSERT(index);
                 llog_cat_set_first_idx(cathandle, index);
                 rc = llog_cancel_rec(cathandle, index);
@@ -475,3 +476,22 @@ int obd_llog_finish(struct obd_device *obd, int count)
         RETURN(rc);
 }
 EXPORT_SYMBOL(obd_llog_finish);
         RETURN(rc);
 }
 EXPORT_SYMBOL(obd_llog_finish);
+
+/* context key constructor/destructor: llog_key_init, llog_key_fini */
+LU_KEY_INIT_FINI(llog, struct llog_thread_info);
+/* context key: llog_thread_key */
+LU_CONTEXT_KEY_DEFINE(llog, LCT_MD_THREAD | LCT_MG_THREAD | LCT_LOCAL);
+LU_KEY_INIT_GENERIC(llog);
+EXPORT_SYMBOL(llog_thread_key);
+
+int llog_info_init(void)
+{
+       llog_key_init_generic(&llog_thread_key, NULL);
+       lu_context_key_register(&llog_thread_key);
+       return 0;
+}
+
+void llog_info_fini(void)
+{
+       lu_context_key_degister(&llog_thread_key);
+}