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