-/* -*- 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 END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * 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/
#define DEBUG_SUBSYSTEM S_LOG
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
-
#ifndef __KERNEL__
#include <liblustre.h>
#endif
return NULL;
ctxt->loc_obd = obd;
- atomic_set(&ctxt->loc_refcount, 1);
+ cfs_atomic_set(&ctxt->loc_refcount, 1);
return ctxt;
}
struct obd_device *obd;
int rc = 0;
- spin_lock(&olg->olg_lock);
- if (!atomic_dec_and_test(&ctxt->loc_refcount)) {
- spin_unlock(&olg->olg_lock);
+ cfs_spin_lock(&olg->olg_lock);
+ if (!cfs_atomic_dec_and_test(&ctxt->loc_refcount)) {
+ cfs_spin_unlock(&olg->olg_lock);
return rc;
}
olg->olg_ctxts[ctxt->loc_idx] = NULL;
- spin_unlock(&olg->olg_lock);
+ cfs_spin_unlock(&olg->olg_lock);
if (ctxt->loc_lcm)
lcm_put(ctxt->loc_lcm);
obd = ctxt->loc_obd;
- spin_lock(&obd->obd_dev_lock);
- spin_unlock(&obd->obd_dev_lock); /* sync with llog ctxt user thread */
+ cfs_spin_lock(&obd->obd_dev_lock);
+ /* sync with llog ctxt user thread */
+ cfs_spin_unlock(&obd->obd_dev_lock);
/* obd->obd_starting is needed for the case of cleanup
* in error case while obd is starting up. */
rc = CTXTP(ctxt, cleanup)(ctxt);
llog_ctxt_destroy(ctxt);
- wake_up(&olg->olg_waitq);
+ cfs_waitq_signal(&olg->olg_waitq);
return rc;
}
EXPORT_SYMBOL(__llog_ctxt_put);
/*
* Banlance the ctxt get when calling llog_cleanup()
*/
- LASSERT(atomic_read(&ctxt->loc_refcount) < 0x5a5a5a);
- LASSERT(atomic_read(&ctxt->loc_refcount) > 1);
+ LASSERT(cfs_atomic_read(&ctxt->loc_refcount) < LI_POISON);
+ LASSERT(cfs_atomic_read(&ctxt->loc_refcount) > 1);
llog_ctxt_put(ctxt);
/*
ctxt->loc_olg = olg;
ctxt->loc_idx = index;
ctxt->loc_logops = op;
- 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;
}
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;
RETURN(0);
if (CTXTP(ctxt, sync))
- rc = CTXTP(ctxt, sync)(ctxt, exp);
+ rc = CTXTP(ctxt, sync)(ctxt, exp, flags);
RETURN(rc);
}
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);
}
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);
cathandle = ctxt->loc_handle;
if (cathandle) {
- list_for_each_entry_safe(loghandle, n,
- &cathandle->u.chd.chd_head,
- u.phd.phd_entry) {
+ cfs_list_for_each_entry_safe(loghandle, n,
+ &cathandle->u.chd.chd_head,
+ u.phd.phd_entry) {
llh = loghandle->lgh_hdr;
if ((llh->llh_flags &
LLOG_F_ZAP_WHEN_EMPTY) &&
cathandle = ctxt->loc_handle;
LASSERT(cathandle != NULL);
rc = llog_cat_add_rec(cathandle, rec, logcookies, NULL);
- if (rc != 1)
+ if (rc != 0 && rc != 1)
CERROR("write one catalog record failed: %d\n", rc);
RETURN(rc);
}