X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdclass%2Fllog_test.c;h=00678c25f7fc31bc82c290035789939fe1e345a9;hb=04a38ba7cda4e242850a47b13d4402a69e8dd921;hp=a2a1d91b5e8f2fc4e7e3bc0f36c416a4b037391a;hpb=6869932b552ac705f411de3362f01bd50c1f6f7d;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/llog_test.c b/lustre/obdclass/llog_test.c index a2a1d91..00678c2 100644 --- a/lustre/obdclass/llog_test.c +++ b/lustre/obdclass/llog_test.c @@ -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,7 +24,7 @@ * 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. */ /* @@ -38,9 +36,6 @@ * Author: Phil Schwan */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_CLASS #include @@ -131,10 +126,8 @@ static int llog_test_1(struct obd_device *obd, char *name) 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); @@ -147,7 +140,7 @@ static int llog_test_2(struct obd_device *obd, char *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) { @@ -173,6 +166,7 @@ static int llog_test_2(struct obd_device *obd, char *name, GOTO(out, rc); } llog_free_handle(loghandle); +#endif out: llog_ctxt_put(ctxt); @@ -238,6 +232,41 @@ static int llog_test_3(struct obd_device *obd, struct llog_handle *llh) 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); } @@ -415,7 +444,7 @@ static int llog_test_5(struct obd_device *obd) } 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); @@ -437,7 +466,7 @@ static int llog_test_5(struct obd_device *obd) } 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); @@ -464,10 +493,9 @@ static int llog_test_5(struct obd_device *obd) /* 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; @@ -475,22 +503,24 @@ static int llog_test_6(struct obd_device *obd, char *name) 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); @@ -518,7 +548,6 @@ parse_out: if (rc) { CERROR("6: llog_close failed: rc = %d\n", rc); } - rc = obd_disconnect(exp); ctxt_release: llog_ctxt_put(ctxt); RETURN(rc); @@ -624,8 +653,7 @@ static int llog_run_tests(struct obd_device *obd) static int llog_test_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *tgt, int count, - struct llog_catid *logid, struct obd_uuid *uuid) + struct obd_device *tgt, int *index) { int rc; ENTRY; @@ -681,6 +709,7 @@ static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) 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", @@ -688,11 +717,11 @@ static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) 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); - llog_test_rand = ll_rand(); + llog_test_rand = cfs_rand(); rc = llog_run_tests(obd); if (rc)