/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * Copyright (C) 2003 Cluster File Systems, Inc.
- * Author: Phil Schwan <phil@clusterfs.com>
+ * GPL HEADER START
*
- * This file is part of the Lustre file system, http://www.lustre.org
- * Lustre is a trademark of Cluster File Systems, Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * You may have signed or agreed to another license before downloading
- * this software. If so, you are bound by the terms and conditions
- * of that agreement, and the following does not apply to you. See the
- * LICENSE file included with this distribution for more information.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
*
- * If you did not agree to a different license, then this copy of Lustre
- * is open source software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
*
- * In either case, Lustre is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * license text for more details.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
*
- * A kernel module which tests the llog API from the OBD setup function.
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/obdclass/llog_test.c
+ *
+ * Author: Phil Schwan <phil@clusterfs.com>
*/
#ifndef EXPORT_SYMTAB
static int llog_test_2(struct obd_device *obd, char *name,
struct llog_handle **llh)
{
- struct llog_handle *loghandle;
- struct llog_logid logid;
- int rc;
struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
+ int rc;
ENTRY;
CWARN("2a: re-open a log with name: %s\n", name);
if ((rc = verify_handle("2", *llh, 1)))
GOTO(out, rc);
-
+#if 0
CWARN("2b: create a log without specified NAME & LOGID\n");
rc = llog_create(ctxt, &loghandle, NULL, NULL);
if (rc) {
GOTO(out, rc);
}
llog_free_handle(loghandle);
+#endif
out:
llog_ctxt_put(ctxt);
if ((rc = verify_handle("3c", llh, num_recs)))
RETURN(rc);
+ CWARN("3d: write log more than BITMAP_SIZE, return -ENOSPC\n");
+ for (i = 0; i < LLOG_BITMAP_SIZE(llh->lgh_hdr) + 1; i++) {
+ struct llog_rec_hdr hdr;
+ char buf_even[24];
+ char buf_odd[32];
+
+ memset(buf_odd, 0, sizeof buf_odd);
+ memset(buf_even, 0, sizeof buf_even);
+ if ((i % 2) == 0) {
+ hdr.lrh_len = 24;
+ hdr.lrh_type = OBD_CFG_REC;
+ rc = llog_write_rec(llh, &hdr, NULL, 0, buf_even, -1);
+ } else {
+ hdr.lrh_len = 32;
+ hdr.lrh_type = OBD_CFG_REC;
+ rc = llog_write_rec(llh, &hdr, NULL, 0, buf_odd, -1);
+ }
+ if (rc) {
+ if (rc == -ENOSPC) {
+ break;
+ } else {
+ CERROR("3c: write recs failed at #%d: %d\n",
+ i + 1, rc);
+ RETURN(rc);
+ }
+ }
+ num_recs++;
+ }
+ if (rc != -ENOSPC) {
+ CWARN("3d: write record more than BITMAP size!\n");
+ RETURN(-EINVAL);
+ }
+ if ((rc = verify_handle("3d", llh, num_recs)))
+ RETURN(rc);
+
RETURN(rc);
}
}
CWARN("5c: Cancel 40000 records, see one log zapped\n");
- rc = llog_cat_process(llh, llog_cancel_rec_cb, "foobar");
+ rc = llog_cat_process(llh, llog_cancel_rec_cb, "foobar", 0, 0);
if (rc != -4711) {
CERROR("5c: process with cat_cancel_cb failed: %d\n", rc);
GOTO(out, rc);
}
CWARN("5e: print plain log entries.. expect 6\n");
- rc = llog_cat_process(llh, plain_print_cb, "foobar");
+ rc = llog_cat_process(llh, plain_print_cb, "foobar", 0, 0);
if (rc) {
CERROR("5e: process with plain_print_cb failed: %d\n", rc);
GOTO(out, rc);
/* Test client api; open log by name and process */
static int llog_test_6(struct obd_device *obd, char *name)
{
- struct obd_device *mdc_obd;
+ struct obd_device *mgc_obd;
struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
- struct obd_uuid *mds_uuid = &ctxt->loc_exp->exp_obd->obd_uuid;
- struct lustre_handle exph = {0, };
+ struct obd_uuid *mgs_uuid = &ctxt->loc_exp->exp_obd->obd_uuid;
struct obd_export *exp;
struct obd_uuid uuid = {"LLOG_TEST6_UUID"};
struct llog_handle *llh = NULL;
int rc;
CWARN("6a: re-open log %s using client API\n", name);
- mdc_obd = class_find_client_obd(mds_uuid, LUSTRE_MDC_NAME, NULL);
- if (mdc_obd == NULL) {
- CERROR("6: no MDC devices connected to %s found.\n",
- mds_uuid->uuid);
+ mgc_obd = class_find_client_obd(mgs_uuid, LUSTRE_MGC_NAME, NULL);
+ if (mgc_obd == NULL) {
+ CERROR("6: no MGC devices connected to %s found.\n",
+ mgs_uuid->uuid);
GOTO(ctxt_release, rc = -ENOENT);
}
- rc = obd_connect(NULL, &exph, mdc_obd, &uuid,
+ rc = obd_connect(NULL, &exp, mgc_obd, &uuid,
NULL /* obd_connect_data */, NULL);
- if (rc) {
- CERROR("6: failed to connect to MDC: %s\n", mdc_obd->obd_name);
- GOTO(ctxt_release, rc);
+ if (rc != -EALREADY) {
+ CERROR("6: connect on connected MDC (%s) failed to return"
+ " -EALREADY", mgc_obd->obd_name);
+ if (rc == 0)
+ obd_disconnect(exp);
+ GOTO(ctxt_release, rc = -EINVAL);
}
- exp = class_conn2export(&exph);
- nctxt = llog_get_context(mdc_obd, LLOG_CONFIG_REPL_CTXT);
+ nctxt = llog_get_context(mgc_obd, LLOG_CONFIG_REPL_CTXT);
rc = llog_create(nctxt, &llh, NULL, name);
if (rc) {
CERROR("6: llog_create failed %d\n", rc);
if (rc) {
CERROR("6: llog_close failed: rc = %d\n", rc);
}
- rc = obd_disconnect(exp);
ctxt_release:
llog_ctxt_put(ctxt);
RETURN(rc);
}
-static int llog_test_llog_init(struct obd_device *obd, int group,
- struct obd_device *tgt, int count,
- struct llog_catid *logid, struct obd_uuid *uuid)
+static int llog_test_llog_init(struct obd_device *obd,
+ struct obd_llog_group *olg,
+ struct obd_device *tgt, int *index)
{
int rc;
ENTRY;
- rc = llog_setup(obd, &obd->obd_olg, LLOG_TEST_ORIG_CTXT, tgt, 0, NULL,
+ rc = llog_setup(obd, &obd->obd_olg, LLOG_TEST_ORIG_CTXT, tgt, 0, NULL,
&llog_lvfs_ops);
RETURN(rc);
}
RETURN(-EINVAL);
}
+ /* disk obd */
tgt = class_name2obd(lustre_cfg_string(lcfg, 1));
if (!tgt || !tgt->obd_attached || !tgt->obd_set_up) {
CERROR("target device not attached or not set up (%s)\n",
RETURN(-EINVAL);
}
- rc = obd_llog_init(obd, OBD_LLOG_GROUP, tgt, 0, NULL, NULL);
+ rc = obd_llog_init(obd, NULL, tgt, NULL);
if (rc)
RETURN(rc);
class_unregister_type("llog_test");
}
-MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
+MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
MODULE_DESCRIPTION("llog test module");
MODULE_LICENSE("GPL");