Whamcloud - gitweb
Land b_smallfix onto HEAD (20040416_1638) (more 2.6 build fixes)
[fs/lustre-release.git] / lustre / obdclass / llog_test.c
index f8e6de1..049db79 100644 (file)
@@ -489,6 +489,42 @@ parse_out:
         RETURN(rc);
 }
 
+static int llog_test_7(struct obd_device *obd)
+{
+        struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
+        struct llog_handle *llh;
+        struct llog_create_rec lcr;
+        char name[10];
+        int rc;
+        ENTRY;
+
+        sprintf(name, "%x", llog_test_rand+2);
+        CWARN("7: create a log with name: %s\n", name);
+        LASSERT(ctxt);
+
+        rc = llog_create(ctxt, &llh, NULL, name);
+        if (rc) {
+                CERROR("7: llog_create with name %s failed: %d\n", name, rc);
+                RETURN(rc);
+        }
+        llog_init_handle(llh, LLOG_F_IS_PLAIN, &uuid);
+
+        lcr.lcr_hdr.lrh_len = lcr.lcr_tail.lrt_len = cpu_to_le32(sizeof(lcr));
+        lcr.lcr_hdr.lrh_type = cpu_to_le32(OST_SZ_REC);
+        rc = llog_write_rec(llh,  &lcr.lcr_hdr, NULL, 0, NULL, -1);
+        if (rc) {
+                CERROR("7: write one log record failed: %d\n", rc);
+                RETURN(rc);
+        }
+
+        rc = llog_destroy(llh);
+        if (rc) 
+                CERROR("7: llog_destroy failed: %d\n", rc);
+        else
+                llog_free_handle(llh); 
+        RETURN(rc);
+}
+
 /* -------------------------------------------------------------------------
  * Tests above, boring obd functions below
  * ------------------------------------------------------------------------- */
@@ -529,6 +565,10 @@ static int llog_run_tests(struct obd_device *obd)
         if (rc)
                 GOTO(cleanup, rc);
 
+        rc = llog_test_7(obd);
+        if (rc)
+                GOTO(cleanup, rc);
+
  cleanup:
         switch (cleanup_phase) {
         case 1:
@@ -570,11 +610,14 @@ static int llog_test_cleanup(struct obd_device *obd, int flags)
         if (rc)
                 CERROR("failed to llog_test_llog_finish: %d\n", rc);
 
+        lprocfs_obd_cleanup(obd);
+
         return rc;
 }
 
 static int llog_test_setup(struct obd_device *obd, obd_count len, void *buf)
 {
+        struct lprocfs_static_vars lvars;
         struct lustre_cfg *lcfg = buf;
         struct obd_device *tgt;
         int rc;
@@ -601,35 +644,19 @@ static int llog_test_setup(struct obd_device *obd, obd_count len, void *buf)
         rc = llog_run_tests(obd);
         if (rc)
                 llog_test_cleanup(obd, 0);
-        RETURN(rc);
-}
-
-static struct lprocfs_vars lprocfs_ost_obd_vars[] = { {0} };
-static struct lprocfs_vars lprocfs_ost_module_vars[] = { {0} };
-LPROCFS_INIT_VARS(ost, lprocfs_ost_module_vars, lprocfs_ost_obd_vars)
-
-static int llog_test_attach(struct obd_device *dev, obd_count len, void *data)
-{
-        struct lprocfs_static_vars lvars;
 
-        lprocfs_init_vars(ost, &lvars);
-        return lprocfs_obd_attach(dev, lvars.obd_vars);
-}
+        lprocfs_init_vars(llog_test, &lvars);
+        lprocfs_obd_setup(obd, lvars.obd_vars);
 
-static int llog_test_detach(struct obd_device *dev)
-{
-        return lprocfs_obd_detach(dev);
+        RETURN(rc);
 }
 
 static struct obd_ops llog_obd_ops = {
-        o_owner:       THIS_MODULE,
-        o_attach:      llog_test_attach,
-        o_detach:      llog_test_detach,
-        o_setup:       llog_test_setup,
-        o_cleanup:     llog_test_cleanup,
-        o_llog_init:   llog_test_llog_init,
-        o_llog_finish: llog_test_llog_finish,
-
+        .o_owner       = THIS_MODULE,
+        .o_setup       = llog_test_setup,
+        .o_cleanup     = llog_test_cleanup,
+        .o_llog_init   = llog_test_llog_init,
+        .o_llog_finish = llog_test_llog_finish,
 };
 
 static struct lprocfs_vars lprocfs_obd_vars[] = { {0} };