#define DEBUG_SUBSYSTEM S_LOG
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
-
#include <obd_class.h>
#include <lustre_log.h>
#include <libcfs/list.h>
RETURN(0);
}
-static int llog_check_cb(struct llog_handle *handle, struct llog_rec_hdr *rec,
- void *data)
+static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle,
+ struct llog_rec_hdr *rec, void *data)
{
struct obd_ioctl_data *ioc_data = (struct obd_ioctl_data *)data;
static int l, remains, from, to;
}
if (handle->lgh_ctxt == NULL)
RETURN(-EOPNOTSUPP);
- rc = llog_cat_id2handle(handle, &log_handle, &lir->lid_id);
+ rc = llog_cat_id2handle(env, handle, &log_handle,
+ &lir->lid_id);
if (rc) {
CDEBUG(D_IOCTL,
"cannot find log #"LPX64"#"LPX64"#%08x\n",
lir->lid_id.lgl_ogen);
RETURN(rc);
}
- rc = llog_process(log_handle, llog_check_cb, NULL, NULL);
- llog_close(log_handle);
+ rc = llog_process(env, log_handle, llog_check_cb, NULL, NULL);
+ llog_close(env, log_handle);
} else {
switch (rec->lrh_type) {
case OST_SZ_REC:
- case OST_RAID1_REC:
case MDS_UNLINK_REC:
- case MDS_SETATTR_REC:
case MDS_SETATTR64_REC:
case OBD_CFG_REC:
case LLOG_HDR_MAGIC: {
RETURN(rc);
}
-static int llog_print_cb(struct llog_handle *handle, struct llog_rec_hdr *rec,
- void *data)
+static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle,
+ struct llog_rec_hdr *rec, void *data)
{
struct obd_ioctl_data *ioc_data = (struct obd_ioctl_data *)data;
static int l, remains, from, to;
if (handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) {
struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
+
if (rec->lrh_type != LLOG_LOGID_MAGIC) {
CERROR("invalid record in catalog\n");
RETURN(-EINVAL);
RETURN(0);
}
-static int llog_remove_log(struct llog_handle *cat, struct llog_logid *logid)
+static int llog_remove_log(const struct lu_env *env, struct llog_handle *cat,
+ struct llog_logid *logid)
{
struct llog_handle *log;
int rc, index = 0;
ENTRY;
cfs_down_write(&cat->lgh_lock);
- rc = llog_cat_id2handle(cat, &log, logid);
+ rc = llog_cat_id2handle(env, cat, &log, logid);
if (rc) {
CDEBUG(D_IOCTL, "cannot find log #"LPX64"#"LPX64"#%08x\n",
logid->lgl_oid, logid->lgl_oseq, logid->lgl_ogen);
index = log->u.phd.phd_cookie.lgc_index;
LASSERT(index);
- rc = llog_destroy(log);
- if (rc) {
- CDEBUG(D_IOCTL, "cannot destroy log\n");
- GOTO(out, rc);
- }
- llog_cat_set_first_idx(cat, index);
- rc = llog_cancel_rec(cat, index);
+ rc = llog_destroy(env, log);
+ if (rc) {
+ CDEBUG(D_IOCTL, "cannot destroy log\n");
+ GOTO(out, rc);
+ }
+ llog_cat_set_first_idx(cat, index);
+ rc = llog_cancel_rec(env, cat, index);
out:
- llog_free_handle(log);
- cfs_up_write(&cat->lgh_lock);
- RETURN(rc);
+ cfs_up_write(&cat->lgh_lock);
+ llog_close(env, log);
+ RETURN(rc);
}
-static int llog_delete_cb(struct llog_handle *handle, struct llog_rec_hdr *rec,
- void *data)
+static int llog_delete_cb(const struct lu_env *env, struct llog_handle *handle,
+ struct llog_rec_hdr *rec, void *data)
{
- struct llog_logid_rec *lir = (struct llog_logid_rec*)rec;
- int rc;
+ struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
+ int rc;
- ENTRY;
- if (rec->lrh_type != LLOG_LOGID_MAGIC)
- RETURN (-EINVAL);
- rc = llog_remove_log(handle, &lir->lid_id);
+ ENTRY;
+ if (rec->lrh_type != LLOG_LOGID_MAGIC)
+ RETURN(-EINVAL);
+ rc = llog_remove_log(env, handle, &lir->lid_id);
- RETURN(rc);
+ RETURN(rc);
}
err = str2logid(&logid, data->ioc_inlbuf1, data->ioc_inllen1);
if (err)
GOTO(out, err);
- err = llog_create(ctxt, &handle, &logid, NULL);
+ err = llog_open(NULL, ctxt, &handle, &logid, NULL,
+ LLOG_OPEN_EXISTS);
if (err)
GOTO(out, err);
} else if (*data->ioc_inlbuf1 == '$') {
char *name = data->ioc_inlbuf1 + 1;
- err = llog_create(ctxt, &handle, NULL, name);
+
+ err = llog_open(NULL, ctxt, &handle, NULL, name,
+ LLOG_OPEN_EXISTS);
if (err)
GOTO(out, err);
} else {
GOTO(out, err = -EINVAL);
}
- err = llog_init_handle(handle, 0, NULL);
+ err = llog_init_handle(NULL, handle, 0, NULL);
if (err)
GOTO(out_close, err = -ENOENT);
case OBD_IOC_LLOG_INFO: {
int l;
int remains = data->ioc_inllen2 +
- cfs_size_round(data->ioc_inllen1);
+ cfs_size_round(data->ioc_inllen1);
char *out = data->ioc_bulk;
l = snprintf(out, remains,
}
case OBD_IOC_LLOG_CHECK: {
LASSERT(data->ioc_inllen1);
- err = llog_process(handle, llog_check_cb, data, NULL);
+ err = llog_process(NULL, 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);
+ err = llog_process(NULL, handle, class_config_dump_handler,
+ data, NULL);
+ if (err == -LLOG_EEMPTY)
+ err = 0;
+ else
+ err = llog_process(NULL, handle, llog_print_cb, data,
+ NULL);
GOTO(out_close, err);
}
if (handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) {
cfs_down_write(&handle->lgh_lock);
- err = llog_cancel_rec(handle, cookie.lgc_index);
+ err = llog_cancel_rec(NULL, handle, cookie.lgc_index);
cfs_up_write(&handle->lgh_lock);
GOTO(out_close, err);
}
if (!(handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT))
GOTO(out_close, err = -EINVAL);
- err = llog_cat_cancel_records(handle, 1, &cookie);
+ err = llog_cat_cancel_records(NULL, 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);
+ err = llog_destroy(NULL, handle);
+ GOTO(out_close, err);
+ } else 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*/
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);
- }
+ err = llog_remove_log(NULL, handle, &plain);
+ } else {
+ /* remove all the log of the catalog */
+ err = llog_process(NULL, handle, llog_delete_cb, NULL,
+ NULL);
+ if (err)
+ GOTO(out_close, err);
+ }
+ break;
+ }
+ default:
+ GOTO(out_close, err = -ENOTTY);
}
out_close:
- if (handle->lgh_hdr &&
- handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT)
- llog_cat_put(handle);
- else
- llog_close(handle);
+ if (handle->lgh_hdr &&
+ handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT)
+ llog_cat_close(NULL, handle);
+ else
+ llog_close(NULL, handle);
out:
- RETURN(err);
+ RETURN(err);
}
EXPORT_SYMBOL(llog_ioctl);