Whamcloud - gitweb
bd508541dfa94860d8ddfe73bb35ad39b8e606ac
[fs/lustre-release.git] / lustre / obdclass / llog_test.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2003 Cluster File Systems, Inc.
5  *   Author: Phil Schwan <phil@clusterfs.com>
6  *
7  *   This file is part of Lustre, http://www.lustre.org/
8  *
9  *   Lustre is free software; you can redistribute it and/or
10  *   modify it under the terms of version 2 of the GNU General Public
11  *   License as published by the Free Software Foundation.
12  *
13  *   Lustre is distributed in the hope that it will be useful,
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *   GNU General Public License for more details.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with Lustre; if not, write to the Free Software
20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  * A kernel module which tests the llog API from the OBD setup function.
23  */
24
25 #ifndef EXPORT_SYMTAB
26 # define EXPORT_SYMTAB
27 #endif
28 #define DEBUG_SUBSYSTEM S_CLASS
29
30 #include <linux/module.h>
31 #include <linux/init.h>
32
33 #include <linux/obd_class.h>
34 #include <linux/lustre_log.h>
35 #include <linux/lustre_mds.h> /* for LUSTRE_MDC_NAME */
36
37 static int llog_test_rand;
38 static struct obd_uuid uuid = { .uuid = "test_uuid" };
39 static struct llog_logid cat_logid;
40
41 struct llog_mini_rec {
42         struct llog_rec_hdr     lmr_hdr;
43         struct llog_rec_tail    lmr_tail;
44 } __attribute__((packed));
45
46 static int verify_handle(char *test, struct llog_handle *llh, int num_recs)
47 {
48         int i;
49         int last_idx = 0;
50         int active_recs = 0;
51
52         for (i = 0; i < LLOG_BITMAP_BYTES * 8; i++) {
53                 if (ext2_test_bit(i, llh->lgh_hdr->llh_bitmap)) {
54                         last_idx = i;
55                         active_recs++;
56                 }
57         }
58
59         if (active_recs != num_recs) {
60                 CERROR("%s: expected %d active recs after write, found %d\n",
61                        test, num_recs, active_recs);
62                 RETURN(-ERANGE);
63         }
64
65         if (llh->lgh_hdr->llh_count != num_recs) {
66                 CERROR("%s: handle->count is %d, expected %d after write\n",
67                        test, llh->lgh_hdr->llh_count, num_recs);
68                 RETURN(-ERANGE);
69         }
70
71         if (llh->lgh_last_idx < last_idx) {
72                 CERROR("%s: handle->last_idx is %d, expected %d after write\n",
73                        test, llh->lgh_last_idx, last_idx);
74                 RETURN(-ERANGE);
75         }
76
77         RETURN(0);
78 }
79
80 /* Test named-log create/open, close */
81 static int llog_test_1(struct obd_device *obd, char *name)
82 {
83         struct llog_handle *llh;
84         struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
85         int rc;
86         int rc2;
87         ENTRY;
88
89         CWARN("1a: create a log with name: %s\n", name);
90         LASSERT(ctxt);
91
92         rc = llog_create(ctxt, &llh, NULL, name);
93         if (rc) {
94                 CERROR("1a: llog_create with name %s failed: %d\n", name, rc);
95                 RETURN(rc);
96         }
97         llog_init_handle(llh, LLOG_F_IS_PLAIN, &uuid);
98
99         if ((rc = verify_handle("1", llh, 1)))
100                 GOTO(out, rc);
101
102  out:
103         CWARN("1b: close newly-created log\n");
104         rc2 = llog_close(llh);
105         if (rc2) {
106                 CERROR("1b: close log %s failed: %d\n", name, rc2);
107                 if (rc == 0)
108                         rc = rc2;
109         }
110         RETURN(rc);
111 }
112
113 /* Test named-log reopen; returns opened log on success */
114 static int llog_test_2(struct obd_device *obd, char *name,
115                        struct llog_handle **llh)
116 {
117         struct llog_handle *loghandle;
118         struct llog_logid logid;
119         int rc;
120         struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
121         ENTRY;
122
123         CWARN("2a: re-open a log with name: %s\n", name);
124         rc = llog_create(ctxt, llh, NULL, name);
125         if (rc) {
126                 CERROR("2a: re-open log with name %s failed: %d\n", name, rc);
127                 RETURN(rc);
128         }
129         llog_init_handle(*llh, LLOG_F_IS_PLAIN, &uuid);
130
131         if ((rc = verify_handle("2", *llh, 1)))
132                 RETURN(rc);
133
134         CWARN("2b: create a log without specified NAME & LOGID\n");
135         rc = llog_create(ctxt, &loghandle, NULL, NULL);
136         if (rc) {
137                 CERROR("2b: create log failed\n");
138                 RETURN(rc);
139         }
140         llog_init_handle(loghandle, LLOG_F_IS_PLAIN, &uuid);
141         logid = loghandle->lgh_id;
142         llog_close(loghandle);
143
144         CWARN("2b: re-open the log by LOGID\n");
145         rc = llog_create(ctxt, &loghandle, &logid, NULL);
146         if (rc) {
147                 CERROR("2b: re-open log by LOGID failed\n");
148                 RETURN(rc);
149         }
150         llog_init_handle(loghandle, LLOG_F_IS_PLAIN, &uuid);
151
152         CWARN("2b: destroy this log\n");
153         rc = llog_destroy(loghandle);
154         if (rc) {
155                 CERROR("2b: destroy log failed\n");
156                 RETURN(rc);
157         }
158         llog_free_handle(loghandle);
159
160         RETURN(rc);
161 }
162
163 /* Test record writing, single and in bulk */
164 static int llog_test_3(struct obd_device *obd, struct llog_handle *llh)
165 {
166         struct llog_create_rec lcr;
167         int rc, i;
168         int num_recs = 1;       /* 1 for the header */
169         ENTRY;
170
171         lcr.lcr_hdr.lrh_len = lcr.lcr_tail.lrt_len = sizeof(lcr);
172         lcr.lcr_hdr.lrh_type = OST_SZ_REC;
173
174         CWARN("3a: write one create_rec\n");
175         rc = llog_write_rec(llh,  &lcr.lcr_hdr, NULL, 0, NULL, -1);
176         num_recs++;
177         if (rc) {
178                 CERROR("3a: write one log record failed: %d\n", rc);
179                 RETURN(rc);
180         }
181
182         if ((rc = verify_handle("3a", llh, num_recs)))
183                 RETURN(rc);
184
185         CWARN("3b: write 10 cfg log records with 8 bytes bufs\n");
186         for (i = 0; i < 10; i++) {
187                 struct llog_rec_hdr hdr;
188                 char buf[8];
189                 hdr.lrh_len = 8;
190                 hdr.lrh_type = OBD_CFG_REC;
191                 memset(buf, 0, sizeof buf);
192                 rc = llog_write_rec(llh, &hdr, NULL, 0, buf, -1);
193                 if (rc) {
194                         CERROR("3b: write 10 records failed at #%d: %d\n",
195                                i + 1, rc);
196                         RETURN(rc);
197                 }
198                 num_recs++;
199                 if ((rc = verify_handle("3c", llh, num_recs)))
200                         RETURN(rc);
201         }
202
203         if ((rc = verify_handle("3b", llh, num_recs)))
204                 RETURN(rc);
205
206         CWARN("3c: write 1000 more log records\n");
207         for (i = 0; i < 1000; i++) {
208                 rc = llog_write_rec(llh, &lcr.lcr_hdr, NULL, 0, NULL, -1);
209                 if (rc) {
210                         CERROR("3c: write 1000 records failed at #%d: %d\n",
211                                i + 1, rc);
212                         RETURN(rc);
213                 }
214                 num_recs++;
215                 if ((rc = verify_handle("3b", llh, num_recs)))
216                         RETURN(rc);
217         }
218
219         if ((rc = verify_handle("3c", llh, num_recs)))
220                 RETURN(rc);
221
222         RETURN(rc);
223 }
224
225 /* Test catalogue additions */
226 static int llog_test_4(struct obd_device *obd)
227 {
228         struct llog_handle *cath;
229         char name[10];
230         int rc, i, buflen;
231         struct llog_mini_rec lmr;
232         struct llog_cookie cookie;
233         struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
234         int num_recs = 0;
235         char *buf;
236         struct llog_rec_hdr rec;
237
238         ENTRY;
239
240         lmr.lmr_hdr.lrh_len = lmr.lmr_tail.lrt_len = LLOG_MIN_REC_SIZE;
241         lmr.lmr_hdr.lrh_type = 0xf00f00;
242
243         sprintf(name, "%x", llog_test_rand+1);
244         CWARN("4a: create a catalog log with name: %s\n", name);
245         rc = llog_create(ctxt, &cath, NULL, name);
246         if (rc) {
247                 CERROR("1a: llog_create with name %s failed: %d\n", name, rc);
248                 GOTO(out, rc);
249         }
250         llog_init_handle(cath, LLOG_F_IS_CAT, &uuid);
251         num_recs++;
252         cat_logid = cath->lgh_id;
253
254         CWARN("4b: write 1 record into the catalog\n");
255         rc = llog_cat_add_rec(cath, &lmr.lmr_hdr, &cookie, NULL);
256         if (rc != 1) {
257                 CERROR("4b: write 1 catalog record failed at: %d\n", rc);
258                 GOTO(out, rc);
259         }
260         num_recs++;
261         if ((rc = verify_handle("4b", cath, 2)))
262                 RETURN(rc);
263
264         if ((rc = verify_handle("4b", cath->u.chd.chd_current_log, num_recs)))
265                 RETURN(rc);
266
267         CWARN("4c: cancel 1 log record\n");
268         rc = llog_cat_cancel_records(cath, 1, &cookie);
269         if (rc) {
270                 CERROR("4c: cancel 1 catalog based record failed: %d\n", rc);
271                 GOTO(out, rc);
272         }
273         num_recs--;
274
275         if ((rc = verify_handle("4c", cath->u.chd.chd_current_log, num_recs)))
276                 RETURN(rc);
277
278         CWARN("4d: write 40,000 more log records\n");
279         for (i = 0; i < 40000; i++) {
280                 rc = llog_cat_add_rec(cath, &lmr.lmr_hdr, NULL, NULL);
281                 if (rc) {
282                         CERROR("4d: write 40000 records failed at #%d: %d\n",
283                                i + 1, rc);
284                         GOTO(out, rc);
285                 }
286                 num_recs++;
287         }
288
289         CWARN("4e: add 5 large records, one record per block\n");
290         buflen = LLOG_CHUNK_SIZE - sizeof(struct llog_rec_hdr)
291                         - sizeof(struct llog_rec_tail);
292         OBD_ALLOC(buf, buflen);
293         if (buf == NULL)
294                 GOTO(out, rc = -ENOMEM);
295         for (i = 0; i < 5; i++) {
296                 rec.lrh_len = buflen;
297                 rec.lrh_type = OBD_CFG_REC;
298                 rc = llog_cat_add_rec(cath, &rec, NULL, buf);
299                 if (rc) {
300                         CERROR("4e: write 5 records failed at #%d: %d\n",
301                                i + 1, rc);
302                         OBD_FREE(buf, buflen);
303                         GOTO(out, rc);
304                 }
305                 num_recs++;
306         }
307         OBD_FREE(buf, buflen);
308
309  out:
310         CWARN("4f: put newly-created catalog\n");
311         rc = llog_cat_put(cath);
312         if (rc)
313                 CERROR("1b: close log %s failed: %d\n", name, rc);
314         RETURN(rc);
315 }
316
317 static int cat_print_cb(struct llog_handle *llh, struct llog_rec_hdr *rec,
318                         void *data)
319 {
320         struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
321
322         if (rec->lrh_type != LLOG_LOGID_MAGIC) {
323                 CERROR("invalid record in catalog\n");
324                 RETURN(-EINVAL);
325         }
326
327         CWARN("seeing record at index %d - "LPX64":%x in log "LPX64"\n",
328                rec->lrh_index, lir->lid_id.lgl_oid,
329                lir->lid_id.lgl_ogen, llh->lgh_id.lgl_oid);
330         RETURN(0);
331 }
332
333 static int plain_print_cb(struct llog_handle *llh, struct llog_rec_hdr *rec,
334                           void *data)
335 {
336         if (!(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN)) {
337                 CERROR("log is not plain\n");
338                 RETURN(-EINVAL);
339         }
340
341         CWARN("seeing record at index %d in log "LPX64"\n",
342                rec->lrh_index, llh->lgh_id.lgl_oid);
343         RETURN(0);
344 }
345
346 static int llog_cancel_rec_cb(struct llog_handle *llh, struct llog_rec_hdr *rec,
347                               void *data)
348 {
349         struct llog_cookie cookie;
350         static int i = 0;
351
352         if (!(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN)) {
353                 CERROR("log is not plain\n");
354                 RETURN(-EINVAL);
355         }
356
357         cookie.lgc_lgl = llh->lgh_id;
358         cookie.lgc_index = rec->lrh_index;
359
360         llog_cat_cancel_records(llh->u.phd.phd_cat_handle, 1, &cookie);
361         i++;
362         if (i == 40000)
363                 RETURN(-4711);
364         RETURN(0);
365 }
366
367 /* Test log and catalogue processing */
368 static int llog_test_5(struct obd_device *obd)
369 {
370         struct llog_handle *llh = NULL;
371         char name[10];
372         int rc;
373         struct llog_mini_rec lmr;
374         struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
375
376         ENTRY;
377
378         lmr.lmr_hdr.lrh_len = lmr.lmr_tail.lrt_len = LLOG_MIN_REC_SIZE;
379         lmr.lmr_hdr.lrh_type = 0xf00f00;
380
381         CWARN("5a: re-open catalog by id\n");
382         rc = llog_create(ctxt, &llh, &cat_logid, NULL);
383         if (rc) {
384                 CERROR("5a: llog_create with logid failed: %d\n", rc);
385                 GOTO(out, rc);
386         }
387         llog_init_handle(llh, LLOG_F_IS_CAT, &uuid);
388
389         CWARN("5b: print the catalog entries.. we expect 2\n");
390         rc = llog_process(llh, (llog_cb_t)cat_print_cb, "test 5", NULL);
391         if (rc) {
392                 CERROR("5b: process with cat_print_cb failed: %d\n", rc);
393                 GOTO(out, rc);
394         }
395
396         CWARN("5c: Cancel 40000 records, see one log zapped\n");
397         rc = llog_cat_process(llh, llog_cancel_rec_cb, "foobar");
398         if (rc != -4711) {
399                 CERROR("5c: process with cat_cancel_cb failed: %d\n", rc);
400                 GOTO(out, rc);
401         }
402
403         CWARN("5d: add 1 record to the log with many canceled empty pages\n");
404         rc = llog_cat_add_rec(llh, &lmr.lmr_hdr, NULL, NULL);
405         if (rc) {
406                 CERROR("5d: add record to the log with many canceled empty\
407                        pages failed\n");
408                 GOTO(out, rc);
409         }
410
411         CWARN("5b: print the catalog entries.. we expect 1\n");
412         rc = llog_process(llh, (llog_cb_t)cat_print_cb, "test 5", NULL);
413         if (rc) {
414                 CERROR("5b: process with cat_print_cb failed: %d\n", rc);
415                 GOTO(out, rc);
416         }
417
418         CWARN("5e: print plain log entries.. expect 6\n");
419         rc = llog_cat_process(llh, plain_print_cb, "foobar");
420         if (rc) {
421                 CERROR("5e: process with plain_print_cb failed: %d\n", rc);
422                 GOTO(out, rc);
423         }
424
425         CWARN("5f: print plain log entries reversely.. expect 6\n");
426         rc = llog_cat_reverse_process(llh, plain_print_cb, "foobar");
427         if (rc) {
428                 CERROR("5f: reversely process with plain_print_cb failed: %d\n",
429                        rc);
430                 GOTO(out, rc);
431         }
432
433  out:
434         CWARN("5: close re-opened catalog\n");
435         if (llh)
436                 rc = llog_cat_put(llh);
437         if (rc)
438                 CERROR("1b: close log %s failed: %d\n", name, rc);
439         RETURN(rc);
440 }
441
442 /* Test client api; open log by name and process */
443 static int llog_test_6(struct obd_device *obd, char *name)
444 {
445         struct obd_device *mdc_obd;
446         struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
447         struct obd_uuid *mds_uuid = &ctxt->loc_exp->exp_obd->obd_uuid;
448         struct lustre_handle exph = {0, };
449         struct obd_export *exp;
450         struct obd_uuid uuid = {"LLOG_TEST6_UUID"};
451         struct llog_handle *llh = NULL;
452         struct llog_ctxt *nctxt;
453         int rc;
454
455         CWARN("6a: re-open log %s using client API\n", name);
456         mdc_obd = class_find_client_obd(mds_uuid, LUSTRE_MDC_NAME, NULL);
457         if (mdc_obd == NULL) {
458                 CERROR("6: no MDC devices connected to %s found.\n",
459                        mds_uuid->uuid);
460                 RETURN(-ENOENT);
461         }
462
463         rc = obd_connect(&exph, mdc_obd, &uuid);
464         if (rc) {
465                 CERROR("6: failed to connect to MDC: %s\n", mdc_obd->obd_name);
466                 RETURN(rc);
467         }
468         exp = class_conn2export(&exph);
469
470         nctxt = llog_get_context(mdc_obd, LLOG_CONFIG_REPL_CTXT);
471         rc = llog_create(nctxt, &llh, NULL, name);
472         if (rc) {
473                 CERROR("6: llog_create failed %d\n", rc);
474                 RETURN(rc);
475         }
476
477         rc = llog_init_handle(llh, LLOG_F_IS_PLAIN, NULL);
478         if (rc) {
479                 CERROR("6: llog_init_handle failed %d\n", rc);
480                 GOTO(parse_out, rc);
481         }
482
483         rc = llog_process(llh, (llog_cb_t)plain_print_cb, NULL, NULL);
484         if (rc)
485                 CERROR("6: llog_process failed %d\n", rc);
486
487         rc = llog_reverse_process(llh, (llog_cb_t)plain_print_cb, NULL, NULL);
488         if (rc)
489                 CERROR("6: llog_reverse_process failed %d\n", rc);
490
491 parse_out:
492         rc = llog_close(llh);
493         if (rc) {
494                 CERROR("6: llog_close failed: rc = %d\n", rc);
495         }
496
497         rc = obd_disconnect(exp, 0);
498
499         RETURN(rc);
500 }
501
502 static int llog_test_7(struct obd_device *obd)
503 {
504         struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
505         struct llog_handle *llh;
506         struct llog_create_rec lcr;
507         char name[10];
508         int rc;
509         ENTRY;
510
511         sprintf(name, "%x", llog_test_rand+2);
512         CWARN("7: create a log with name: %s\n", name);
513         LASSERT(ctxt);
514
515         rc = llog_create(ctxt, &llh, NULL, name);
516         if (rc) {
517                 CERROR("7: llog_create with name %s failed: %d\n", name, rc);
518                 RETURN(rc);
519         }
520         llog_init_handle(llh, LLOG_F_IS_PLAIN, &uuid);
521
522         lcr.lcr_hdr.lrh_len = lcr.lcr_tail.lrt_len = cpu_to_le32(sizeof(lcr));
523         lcr.lcr_hdr.lrh_type = cpu_to_le32(OST_SZ_REC);
524         rc = llog_write_rec(llh,  &lcr.lcr_hdr, NULL, 0, NULL, -1);
525         if (rc) {
526                 CERROR("7: write one log record failed: %d\n", rc);
527                 RETURN(rc);
528         }
529
530         rc = llog_destroy(llh);
531         if (rc) 
532                 CERROR("7: llog_destroy failed: %d\n", rc);
533         else
534                 llog_free_handle(llh); 
535         RETURN(rc);
536 }
537
538 /* -------------------------------------------------------------------------
539  * Tests above, boring obd functions below
540  * ------------------------------------------------------------------------- */
541 static int llog_run_tests(struct obd_device *obd)
542 {
543         struct llog_handle *llh;
544         struct lvfs_run_ctxt saved;
545         struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
546         int rc, err, cleanup_phase = 0;
547         char name[10];
548         ENTRY;
549
550         sprintf(name, "%x", llog_test_rand);
551         push_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL);
552
553         rc = llog_test_1(obd, name);
554         if (rc)
555                 GOTO(cleanup, rc);
556
557         rc = llog_test_2(obd, name, &llh);
558         if (rc)
559                 GOTO(cleanup, rc);
560         cleanup_phase = 1; /* close llh */
561
562         rc = llog_test_3(obd, llh);
563         if (rc)
564                 GOTO(cleanup, rc);
565
566         rc = llog_test_4(obd);
567         if (rc)
568                 GOTO(cleanup, rc);
569
570         rc = llog_test_5(obd);
571         if (rc)
572                 GOTO(cleanup, rc);
573
574         rc = llog_test_6(obd, name);
575         if (rc)
576                 GOTO(cleanup, rc);
577
578         rc = llog_test_7(obd);
579         if (rc)
580                 GOTO(cleanup, rc);
581
582  cleanup:
583         switch (cleanup_phase) {
584         case 1:
585                 err = llog_close(llh);
586                 if (err)
587                         CERROR("cleanup: llog_close failed: %d\n", err);
588                 if (!rc)
589                         rc = err;
590         case 0:
591                 pop_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL);
592         }
593
594         return rc;
595 }
596
597
598 static int llog_test_llog_init(struct obd_device *obd, struct obd_device *tgt,
599                                int count, struct llog_catid *logid)
600 {
601         int rc;
602         ENTRY;
603
604         rc = obd_llog_setup(obd, LLOG_TEST_ORIG_CTXT, tgt, 0, NULL,
605                             &llog_lvfs_ops);
606         RETURN(rc);
607 }
608
609 static int llog_test_llog_finish(struct obd_device *obd, int count)
610 {
611         int rc;
612         ENTRY;
613
614         rc = obd_llog_cleanup(llog_get_context(obd, LLOG_TEST_ORIG_CTXT));
615         RETURN(rc);
616 }
617
618 static int llog_test_cleanup(struct obd_device *obd, int flags)
619 {
620         int rc = obd_llog_finish(obd, 0);
621         if (rc)
622                 CERROR("failed to llog_test_llog_finish: %d\n", rc);
623
624         lprocfs_obd_cleanup(obd);
625
626         return rc;
627 }
628
629 static int llog_test_setup(struct obd_device *obd, obd_count len, void *buf)
630 {
631         struct lprocfs_static_vars lvars;
632         struct lustre_cfg *lcfg = buf;
633         struct obd_device *tgt;
634         int rc;
635         ENTRY;
636
637         if (lcfg->lcfg_inllen1 < 1) {
638                 CERROR("requires a TARGET OBD name\n");
639                 RETURN(-EINVAL);
640         }
641
642         tgt = class_name2obd(lcfg->lcfg_inlbuf1);
643         if (!tgt || !tgt->obd_attached || !tgt->obd_set_up) {
644                 CERROR("target device not attached or not set up (%s)\n",
645                        lcfg->lcfg_inlbuf1);
646                 RETURN(-EINVAL);
647         }
648
649         rc = obd_llog_init(obd, tgt, 0, NULL);
650         if (rc)
651                 RETURN(rc);
652
653         llog_test_rand = ll_insecure_random_int();
654
655         rc = llog_run_tests(obd);
656         if (rc)
657                 llog_test_cleanup(obd, 0);
658
659         lprocfs_init_vars(llog_test, &lvars);
660         lprocfs_obd_setup(obd, lvars.obd_vars);
661
662         RETURN(rc);
663 }
664
665 static struct obd_ops llog_obd_ops = {
666         .o_owner       = THIS_MODULE,
667         .o_setup       = llog_test_setup,
668         .o_cleanup     = llog_test_cleanup,
669         .o_llog_init   = llog_test_llog_init,
670         .o_llog_finish = llog_test_llog_finish,
671 };
672
673 static struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
674 static struct lprocfs_vars lprocfs_module_vars[] = { {0} };
675 LPROCFS_INIT_VARS(llog_test, lprocfs_module_vars, lprocfs_obd_vars)
676
677 static int __init llog_test_init(void)
678 {
679         struct lprocfs_static_vars lvars;
680
681         lprocfs_init_vars(llog_test, &lvars);
682         return class_register_type(&llog_obd_ops,lvars.module_vars,"llog_test");
683 }
684
685 static void __exit llog_test_exit(void)
686 {
687         class_unregister_type("llog_test");
688 }
689
690 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
691 MODULE_DESCRIPTION("llog test module");
692 MODULE_LICENSE("GPL");
693
694 module_init(llog_test_init);
695 module_exit(llog_test_exit);