- struct mds_obd *mds = &obd->u.mds;
- struct llog_handle *handle;
- struct obd_run_ctxt saved;
- int size, i, count;
- struct llog_logid *idarray, *id;
- char name[32] = "CATLIST";
- int rc;
- struct cb_data data;
- struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
-
- if (ctxt == NULL || mds == NULL)
- RETURN(-EOPNOTSUPP);
-
- count = mds->mds_lov_desc.ld_tgt_count;
- size = sizeof(*idarray) * count;
-
- OBD_ALLOC(idarray, size);
- if (!idarray)
- RETURN(-ENOMEM);
- memset(idarray, 0, size);
-
- rc = llog_get_cat_list(obd, obd, name, count, idarray);
- if (rc)
- GOTO(out_free, rc);
-
- push_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_ctxt, NULL);
-
- id = idarray;
- data.ctxt = ctxt;
- data.out = buf;
- data.remains = buf_len;
- for (i = 0; i < count; i++) {
- int l, index, uncanceled = 0;
- rc = llog_create(ctxt, &handle, id, NULL);
- if (rc)
- GOTO(out_pop, rc);
- rc = llog_init_handle(handle, 0, NULL);
- if (rc) {
- llog_close(handle);
- GOTO(out_pop, rc = -ENOENT);
- }
- for (index = 1; index < (LLOG_BITMAP_BYTES * 8); index++) {
- if (ext2_test_bit(index, handle->lgh_hdr->llh_bitmap))
- uncanceled++;
- }
- l = snprintf(data.out, data.remains,
- "\n[Catlog ID]: #"LPX64"#"LPX64"#%08x "
- "[Log Count]: %d\n",
- id->lgl_oid, id->lgl_ogr, id->lgl_ogen,
- uncanceled);
-
- data.out += l;
- data.remains -= l;
- data.init = 1;
-
- llog_process(handle, llog_catinfo_cb, &data);
- llog_close(handle);
-
- if (data.remains <= 0)
- break;
- }
-out_pop:
- pop_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_ctxt, NULL);
-out_free:
- OBD_FREE(idarray, size);
- RETURN(rc);