RETURN(rc);
}
+ if (llh->lgh_last_idx != 0) {
+ CERROR("1a: handle->last_idx is %d, expected 0 after create\n",
+ llh->lgh_last_idx);
+ RETURN(-ERANGE);
+ }
+ if (llh->lgh_hdr->llh_count != 0) {
+ CERROR("1a: header->count is %d, expected 0 after create\n",
+ llh->lgh_hdr->llh_count);
+ RETURN(-ERANGE);
+ }
+
CERROR("1b: close newly-created log\n");
rc = llog_close(llh);
if (rc)
CERROR("2: re-open a log with a name\n");
sprintf(name, "%x", llog_test_rand);
rc = llog_create(obd, llh, NULL, name);
- if (rc)
+ if (rc) {
CERROR("2: re-open log with name %s failed: %d\n", name, rc);
+ RETURN(rc);
+ }
+
+ if ((*llh)->lgh_last_idx != 0) {
+ CERROR("2: handle->last_idx is %d, expected 0 after reopen\n",
+ (*llh)->lgh_last_idx);
+ RETURN(-ERANGE);
+ }
+ if ((*llh)->lgh_hdr->llh_count != 0) {
+ CERROR("2: header->count is %d, expected 0 after reopen\n",
+ (*llh)->lgh_hdr->llh_count);
+ RETURN(-ERANGE);
+ }
RETURN(rc);
}
RETURN(rc);
}
+ if (llh->lgh_last_idx != 1) {
+ CERROR("3: handle->last_idx is %d, expected 1 after write\n",
+ llh->lgh_last_idx);
+ RETURN(-ERANGE);
+ }
+ if (llh->lgh_hdr->llh_count != 1) {
+ CERROR("3: header->count is %d, expected 1 after write\n",
+ llh->lgh_hdr->llh_count);
+ RETURN(-ERANGE);
+ }
+ if (!ext2_test_bit(0, llh->lgh_hdr->llh_bitmap)) {
+ CERROR("3: first bit in bitmap should be set after write\n");
+ RETURN(-ERANGE);
+ }
+
CERROR("3b: write 1000 more log records\n");
for (i = 0; i < 1000; i++) {
rc = llog_write_rec(llh, &rec, NULL, 0, NULL, -1);
}
}
+ if (llh->lgh_last_idx != 1001) {
+ CERROR("3: handle->last_idx is %d, expected 1001 after write\n",
+ llh->lgh_last_idx);
+ RETURN(-ERANGE);
+ }
+ if (llh->lgh_hdr->llh_count != 1001) {
+ CERROR("3: header->count is %d, expected 1001 after write\n",
+ llh->lgh_hdr->llh_count);
+ RETURN(-ERANGE);
+ }
+ for (i = 0; i < 1001; i++) {
+ if (!ext2_test_bit(i, llh->lgh_hdr->llh_bitmap)) {
+ CERROR("3: bit %d not set after 1001 writes\n", i);
+ RETURN(-ERANGE);
+ }
+ }
+ for (i = 1001; i < LLOG_BITMAP_BYTES * 8; i++) {
+ if (ext2_test_bit(i, llh->lgh_hdr->llh_bitmap)) {
+ CERROR("3: bit %d is set, but should not be\n", i);
+ RETURN(-ERANGE);
+ }
+ }
+
RETURN(rc);
}
static int llog_run_tests(struct obd_device *obd)
{
struct llog_handle *llh;
+ struct obd_run_ctxt saved;
int rc, err, cleanup_phase = 0;
ENTRY;
+ push_ctxt(&saved, &obd->obd_log_exp->exp_obd->obd_ctxt, NULL);
+
rc = llog_test_1(obd);
if (rc)
GOTO(cleanup, rc);
CERROR("cleanup: llog_close failed: %d\n", err);
if (!rc)
rc = err;
+ case 0:
+ pop_ctxt(&saved, &obd->obd_log_exp->exp_obd->obd_ctxt, NULL);
}
return rc;
}
obd->obd_log_exp = class_conn2export(&conn);
+ llog_test_rand = ll_insecure_random_int();
+
rc = llog_run_tests(obd);
if (rc)
llog_test_cleanup(obd, 0);
{
struct lprocfs_static_vars lvars;
- llog_test_rand = ll_insecure_random_int();
-
lprocfs_init_multi_vars(0, &lvars);
return class_register_type(&llog_obd_ops,lvars.module_vars,"llog_test");
}