Whamcloud - gitweb
LU-814 test: automate NFS over lustre testing
[fs/lustre-release.git] / lustre / include / lustre_log.h
index d1d9d59..54f3f04 100644 (file)
@@ -26,7 +26,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
 #ifndef _LUSTRE_LOG_H
 #define _LUSTRE_LOG_H
 
+/** \defgroup log log
+ *
+ * @{
+ */
+
 #if defined(__linux__)
 #include <linux/lustre_log.h>
 #elif defined(__APPLE__)
@@ -106,12 +111,17 @@ int llog_init_handle(struct llog_handle *handle, int flags,
 extern void llog_free_handle(struct llog_handle *handle);
 int llog_process(struct llog_handle *loghandle, llog_cb_t cb,
                  void *data, void *catdata);
+int llog_process_flags(struct llog_handle *loghandle, llog_cb_t cb,
+                 void *data, void *catdata, int flags);
 int llog_reverse_process(struct llog_handle *loghandle, llog_cb_t cb,
                          void *data, void *catdata);
 extern int llog_cancel_rec(struct llog_handle *loghandle, int index);
 extern int llog_close(struct llog_handle *cathandle);
 extern int llog_get_size(struct llog_handle *loghandle);
 
+/* llog_process flags */
+#define LLOG_FLAG_NODEAMON 0x0001
+
 /* llog_cat.c - catalog api */
 struct llog_process_data {
         /**
@@ -129,6 +139,7 @@ struct llog_process_data {
          */
         int                  lpd_startcat;
         int                  lpd_startidx;
+        int                  lpd_flags;  /** llog_process flags */
 };
 
 struct llog_process_cat_data {
@@ -164,6 +175,8 @@ int llog_cat_cancel_records(struct llog_handle *cathandle, int count,
                             struct llog_cookie *cookies);
 int llog_cat_process(struct llog_handle *cat_llh, llog_cb_t cb, void *data,
                      int startcat, int startidx);
+int llog_cat_process_flags(struct llog_handle *cat_llh, llog_cb_t cb, void *data,
+                     int flags, int startcat, int startidx);
 int llog_cat_process_thread(void *data);
 int llog_cat_reverse_process(struct llog_handle *cat_llh, llog_cb_t cb, void *data);
 int llog_cat_set_first_idx(struct llog_handle *cathandle, int index);
@@ -316,7 +329,6 @@ struct llog_commit_master {
 static inline struct llog_commit_master
 *lcm_get(struct llog_commit_master *lcm)
 {
-        LASSERT(cfs_atomic_read(&lcm->lcm_refcount) > 0);
         cfs_atomic_inc(&lcm->lcm_refcount);
         return lcm;
 }
@@ -324,10 +336,9 @@ static inline struct llog_commit_master
 static inline void
 lcm_put(struct llog_commit_master *lcm)
 {
-        if (!cfs_atomic_dec_and_test(&lcm->lcm_refcount)) {
-                return ;
-        }
-        OBD_FREE_PTR(lcm);
+        LASSERT_ATOMIC_POS(&lcm->lcm_refcount);
+        if (cfs_atomic_dec_and_test(&lcm->lcm_refcount))
+                OBD_FREE_PTR(lcm);
 }
 
 struct llog_canceld_ctxt {
@@ -376,12 +387,10 @@ static inline void llog_gen_init(struct llog_ctxt *ctxt)
 {
         struct obd_device *obd = ctxt->loc_exp->exp_obd;
 
-        if (!strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME))
-                ctxt->loc_gen.mnt_cnt = obd->u.mds.mds_mount_count;
-        else if (!strstr(obd->obd_type->typ_name, LUSTRE_OST_NAME))
-                ctxt->loc_gen.mnt_cnt = obd->u.filter.fo_mount_count;
-        else
-                ctxt->loc_gen.mnt_cnt = 0;
+        LASSERTF(obd->u.obt.obt_magic == OBT_MAGIC,
+                 "%s: wrong obt magic %#x\n",
+                 obd->obd_name, obd->u.obt.obt_magic);
+        ctxt->loc_gen.mnt_cnt = obd->u.obt.obt_mount_count;
         ctxt->loc_gen.conn_cnt++;
 }
 
@@ -426,7 +435,6 @@ static inline int llog_data_len(int len)
 
 static inline struct llog_ctxt *llog_ctxt_get(struct llog_ctxt *ctxt)
 {
-        LASSERT(cfs_atomic_read(&ctxt->loc_refcount) > 0);
         cfs_atomic_inc(&ctxt->loc_refcount);
         CDEBUG(D_INFO, "GETting ctxt %p : new refcount %d\n", ctxt,
                cfs_atomic_read(&ctxt->loc_refcount));
@@ -437,8 +445,7 @@ static inline void llog_ctxt_put(struct llog_ctxt *ctxt)
 {
         if (ctxt == NULL)
                 return;
-        LASSERT(cfs_atomic_read(&ctxt->loc_refcount) > 0);
-        LASSERT(cfs_atomic_read(&ctxt->loc_refcount) < 0x5a5a5a);
+        LASSERT_ATOMIC_GT_LT(&ctxt->loc_refcount, 0, 0x5a5a5a);
         CDEBUG(D_INFO, "PUTting ctxt %p : new refcount %d\n", ctxt,
                cfs_atomic_read(&ctxt->loc_refcount) - 1);
         __llog_ctxt_put(ctxt);
@@ -449,7 +456,7 @@ static inline void llog_group_init(struct obd_llog_group *olg, int group)
         cfs_waitq_init(&olg->olg_waitq);
         cfs_spin_lock_init(&olg->olg_lock);
         cfs_sema_init(&olg->olg_cat_processing, 1);
-        olg->olg_group = group;
+        olg->olg_seq = group;
 }
 
 static inline void llog_group_set_export(struct obd_llog_group *olg,
@@ -460,7 +467,7 @@ static inline void llog_group_set_export(struct obd_llog_group *olg,
         cfs_spin_lock(&olg->olg_lock);
         if (olg->olg_exp != NULL && olg->olg_exp != exp)
                 CWARN("%s: export for group %d is changed: 0x%p -> 0x%p\n",
-                      exp->exp_obd->obd_name, olg->olg_group,
+                      exp->exp_obd->obd_name, olg->olg_seq,
                       olg->olg_exp, exp);
         olg->olg_exp = exp;
         cfs_spin_unlock(&olg->olg_lock);
@@ -680,4 +687,6 @@ int lustre_process_log(struct super_block *sb, char *logname,
 int lustre_end_log(struct super_block *sb, char *logname,
                    struct config_llog_instance *cfg);
 
+/** @} log */
+
 #endif