+static inline struct llog_ctxt *llog_ctxt_get(struct llog_ctxt *ctxt)
+{
+ LASSERT(atomic_read(&ctxt->loc_refcount) > 0);
+ atomic_inc(&ctxt->loc_refcount);
+ CDEBUG(D_INFO, "GETting ctxt %p : new refcount %d\n", ctxt,
+ atomic_read(&ctxt->loc_refcount));
+ return ctxt;
+}
+
+static inline void llog_ctxt_put(struct llog_ctxt *ctxt)
+{
+ if (ctxt == NULL)
+ return;
+ CDEBUG(D_INFO, "PUTting ctxt %p : new refcount %d\n", ctxt,
+ atomic_read(&ctxt->loc_refcount) - 1);
+ LASSERT(atomic_read(&ctxt->loc_refcount) > 0);
+ LASSERT(atomic_read(&ctxt->loc_refcount) < 0x5a5a5a);
+ __llog_ctxt_put(ctxt);
+}
+
+static inline void llog_group_init(struct obd_llog_group *olg, int group)
+{
+ cfs_waitq_init(&olg->olg_waitq);
+ spin_lock_init(&olg->olg_lock);
+ olg->olg_group = group;
+}
+
+static inline void llog_group_set_export(struct obd_llog_group *olg,
+ struct obd_export *exp)
+{
+ LASSERT(exp != NULL);
+
+ 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,
+ olg->olg_exp, exp);
+ olg->olg_exp = exp;
+ spin_unlock(&olg->olg_lock);
+}
+
+static inline int llog_group_set_ctxt(struct obd_llog_group *olg,
+ struct llog_ctxt *ctxt, int index)
+{
+ LASSERT(index >= 0 && index < LLOG_MAX_CTXTS);
+
+ spin_lock(&olg->olg_lock);
+ if (olg->olg_ctxts[index] != NULL) {
+ spin_unlock(&olg->olg_lock);
+ return -EEXIST;
+ }
+ olg->olg_ctxts[index] = ctxt;
+ spin_unlock(&olg->olg_lock);
+ return 0;
+}
+
+static inline struct llog_ctxt *llog_group_get_ctxt(struct obd_llog_group *olg,
+ int index)
+{
+ struct llog_ctxt *ctxt;
+
+ LASSERT(index >= 0 && index < LLOG_MAX_CTXTS);
+
+ spin_lock(&olg->olg_lock);
+ if (olg->olg_ctxts[index] == NULL) {
+ ctxt = NULL;
+ } else {
+ ctxt = llog_ctxt_get(olg->olg_ctxts[index]);
+ }
+ spin_unlock(&olg->olg_lock);
+ return ctxt;
+}
+