- GOTO(out_close, err);
- }
- case OBD_IOC_LLOG_CANCEL: {
- struct llog_cookie cookie;
- struct llog_logid plain;
- char *endp;
-
- if (!(le32_to_cpu(handle->lgh_hdr->llh_flags) & LLOG_F_IS_CAT))
- GOTO(out_close, err = -EINVAL);
-
- err = str2logid(&plain, data->ioc_inlbuf2, data->ioc_inllen2);
- if (err)
- GOTO(out_close, err);
- cookie.lgc_lgl = plain;
- cookie.lgc_index = simple_strtoul(data->ioc_inlbuf3,
- &endp, 0);
- if (*endp != '\0')
- GOTO(out_close, err = -EINVAL);
+ if (data->ioc_inlbuf2 == NULL) /* catalog but no logid */
+ GOTO(out_close, rc = -ENOTTY);
+
+ rc = str2logid(&plain, data->ioc_inlbuf2, data->ioc_inllen2);
+ if (rc)
+ GOTO(out_close, rc);
+ cookie.lgc_lgl = plain;
+ rc = llog_cat_cancel_records(env, handle, 1, &cookie);
+ if (rc)
+ GOTO(out_close, rc);
+ break;
+ }
+ case OBD_IOC_LLOG_REMOVE: {
+ struct llog_logid plain;
+
+ if (handle->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN) {
+ rc = llog_destroy(env, handle);
+ GOTO(out_close, rc);
+ } else if (!(handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT)) {
+ GOTO(out_close, rc = -EINVAL);
+ }
+
+ if (data->ioc_inlbuf2 > 0) {
+ /* remove indicate log from the catalog */
+ rc = str2logid(&plain, data->ioc_inlbuf2,
+ data->ioc_inllen2);
+ if (rc)
+ GOTO(out_close, rc);
+ rc = llog_remove_log(env, handle, &plain);
+ } else {
+ /* remove all the log of the catalog */
+ rc = llog_process(env, handle, llog_delete_cb, NULL,
+ NULL);
+ if (rc)
+ GOTO(out_close, rc);
+ }
+ break;
+ }
+ default:
+ CERROR("%s: Unknown ioctl cmd %#x\n",
+ ctxt->loc_obd->obd_name, cmd);
+ GOTO(out_close, rc = -ENOTTY);
+ }