- if (remains <= 0)
- CERROR("not enough space for log header info\n");
-
- GOTO(out_close, err);
- }
- case OBD_IOC_LLOG_CHECK: {
- LASSERT(data->ioc_inllen1);
- err = llog_process(handle, llog_check_cb, data, NULL);
- if (err == -LLOG_EEMPTY)
- err = 0;
- GOTO(out_close, err);
- }
-
- case OBD_IOC_LLOG_PRINT: {
- LASSERT(data->ioc_inllen1);
- err = llog_process(handle, class_config_dump_handler,data,NULL);
- if (err == -LLOG_EEMPTY)
- err = 0;
- else
- err = llog_process(handle, llog_print_cb, data, NULL);
-
- GOTO(out_close, err);
- }
- case OBD_IOC_LLOG_CANCEL: {
- struct llog_cookie cookie;
- struct llog_logid plain;
- char *endp;
-
- cookie.lgc_index = simple_strtoul(data->ioc_inlbuf3, &endp, 0);
- if (*endp != '\0')
- GOTO(out_close, err = -EINVAL);
-
- if (handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) {
- down_write(&handle->lgh_lock);
- err = llog_cancel_rec(handle, cookie.lgc_index);
- up_write(&handle->lgh_lock);
- GOTO(out_close, err);
- }
-
- err = str2logid(&plain, data->ioc_inlbuf2, data->ioc_inllen2);
- if (err)
- GOTO(out_close, err);
- cookie.lgc_lgl = plain;
-
- if (!(handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT))
- GOTO(out_close, err = -EINVAL);
-
- err = llog_cat_cancel_records(handle, 1, &cookie);
- GOTO(out_close, err);
- }
- case OBD_IOC_LLOG_REMOVE: {
- struct llog_logid plain;
-
- if (handle->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN) {
- err = llog_destroy(handle);
- if (!err)
- llog_free_handle(handle);
- GOTO(out, err);
- }
-
- if (!(handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT))
- GOTO(out_close, err = -EINVAL);
-
- if (data->ioc_inlbuf2) {
- /*remove indicate log from the catalog*/
- err = str2logid(&plain, data->ioc_inlbuf2,
- data->ioc_inllen2);
- if (err)
- GOTO(out_close, err);
- err = llog_remove_log(handle, &plain);
- } else {
- /*remove all the log of the catalog*/
- llog_process(handle, llog_delete_cb, NULL, NULL);
- }
- GOTO(out_close, err);
- }
- }
+ if (remains <= 0) {
+ CERROR("%s: not enough space for log header info\n",
+ ctxt->loc_obd->obd_name);
+ rc = -ENOSPC;
+ }
+ break;
+ }
+ case OBD_IOC_LLOG_CHECK:
+ LASSERT(data->ioc_inllen1 > 0);
+ rc = llog_process(env, handle, llog_check_cb, data, NULL);
+ if (rc == -LLOG_EEMPTY)
+ rc = 0;
+ else if (rc)
+ GOTO(out_close, rc);
+ break;
+ case OBD_IOC_LLOG_PRINT:
+ LASSERT(data->ioc_inllen1 > 0);
+ rc = llog_process(env, handle, llog_print_cb, data, NULL);
+ if (rc == -LLOG_EEMPTY)
+ rc = 0;
+ else if (rc)
+ GOTO(out_close, rc);
+ break;
+ case OBD_IOC_LLOG_CANCEL: {
+ struct llog_cookie cookie;
+ struct llog_logid plain;
+ char *endp;
+
+ cookie.lgc_index = simple_strtoul(data->ioc_inlbuf3, &endp, 0);
+ if (*endp != '\0')
+ GOTO(out_close, rc = -EINVAL);
+
+ if (handle->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN) {
+ rc = llog_cancel_rec(env, handle, cookie.lgc_index);
+ GOTO(out_close, rc);
+ } else if (!(handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT)) {
+ GOTO(out_close, rc = -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);
+ }