X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Finclude%2Flustre_log.h;h=e64ef1eb8dea0ee6c82510fc28d7318a49d61a9b;hp=00c854194b57bdc715a02ee63ffc38c121ebba3b;hb=6ad1581bf6003631d87e8365c01c03b06be136de;hpb=90dfed8469d46f4b79ebdff8121eb109b5db6746;ds=sidebyside diff --git a/lustre/include/lustre_log.h b/lustre/include/lustre_log.h index 00c8541..e64ef1e 100644 --- a/lustre/include/lustre_log.h +++ b/lustre/include/lustre_log.h @@ -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. @@ -26,8 +24,10 @@ * 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. + * + * Copyright (c) 2012, Whamcloud, Inc. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -191,7 +191,7 @@ int llog_setup(struct obd_device *obd, struct obd_llog_group *olg, int index, struct llog_operations *op); int __llog_ctxt_put(struct llog_ctxt *ctxt); int llog_cleanup(struct llog_ctxt *); -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 llog_add(struct llog_ctxt *ctxt, struct llog_rec_hdr *rec, struct lov_stripe_md *lsm, struct llog_cookie *logcookies, int numcookies); @@ -228,7 +228,8 @@ int llog_handle_connect(struct ptlrpc_request *req); int llog_obd_repl_cancel(struct llog_ctxt *ctxt, struct lov_stripe_md *lsm, int count, struct llog_cookie *cookies, int flags); -int llog_obd_repl_sync(struct llog_ctxt *ctxt, struct obd_export *exp); +int llog_obd_repl_sync(struct llog_ctxt *ctxt, struct obd_export *exp, + int flags); int llog_obd_repl_connect(struct llog_ctxt *ctxt, struct llog_logid *logid, struct llog_gen *gen, struct obd_uuid *uuid); @@ -251,7 +252,8 @@ struct llog_operations { int (*lop_setup)(struct obd_device *obd, struct obd_llog_group *olg, int ctxt_idx, struct obd_device *disk_obd, int count, struct llog_logid *logid, const char *name); - int (*lop_sync)(struct llog_ctxt *ctxt, struct obd_export *exp); + int (*lop_sync)(struct llog_ctxt *ctxt, struct obd_export *exp, + int flags); int (*lop_cleanup)(struct llog_ctxt *ctxt); int (*lop_add)(struct llog_ctxt *ctxt, struct llog_rec_hdr *rec, struct lov_stripe_md *lsm, @@ -274,6 +276,7 @@ int llog_put_cat_list(struct obd_device *disk_obd, char *name, int idx, int count, struct llog_catid *idarray); #define LLOG_CTXT_FLAG_UNINITIALIZED 0x00000001 +#define LLOG_CTXT_FLAG_STOP 0x00000002 struct llog_ctxt { int loc_idx; /* my index the obd array of ctxt's */ @@ -287,7 +290,7 @@ struct llog_ctxt { struct llog_handle *loc_handle; struct llog_commit_master *loc_lcm; struct llog_canceld_ctxt *loc_llcd; - cfs_semaphore_t loc_sem; /* protects loc_llcd and loc_imp */ + cfs_mutex_t loc_mutex; /* protects loc_llcd and loc_imp */ cfs_atomic_t loc_refcount; void *llog_proc_cb; long loc_flags; /* flags, see above defines */ @@ -329,7 +332,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; } @@ -337,10 +339,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 { @@ -389,6 +390,9 @@ static inline void llog_gen_init(struct llog_ctxt *ctxt) { struct obd_device *obd = ctxt->loc_exp->exp_obd; + 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++; } @@ -434,7 +438,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)); @@ -445,8 +448,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, LI_POISON); CDEBUG(D_INFO, "PUTting ctxt %p : new refcount %d\n", ctxt, cfs_atomic_read(&ctxt->loc_refcount) - 1); __llog_ctxt_put(ctxt); @@ -456,8 +458,8 @@ 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; + cfs_mutex_init(&olg->olg_cat_processing); + olg->olg_seq = group; } static inline void llog_group_set_export(struct obd_llog_group *olg, @@ -468,7 +470,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);