From 241eaf490cef58dc4811628add2058852ce4fda0 Mon Sep 17 00:00:00 2001 From: niu Date: Mon, 24 Nov 2003 08:59:21 +0000 Subject: [PATCH] Move device type specific llog ioctl codes from generic obdclass to mds/obdfilter/mdc. --- lustre/obdclass/llog_internal.h | 6 --- lustre/obdclass/llog_ioctl.c | 91 ++++++++++++++++++++++------------------- 2 files changed, 49 insertions(+), 48 deletions(-) diff --git a/lustre/obdclass/llog_internal.h b/lustre/obdclass/llog_internal.h index 33b1778..8674351 100644 --- a/lustre/obdclass/llog_internal.h +++ b/lustre/obdclass/llog_internal.h @@ -5,12 +5,6 @@ int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd, char *name, int count, struct llog_logid *idarray); int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd, char *name, int count, struct llog_logid *); -struct llog_ctxt* push_llog_ioctl_ctxt(struct obd_device *obd, - struct obd_run_ctxt *saved); -void pop_llog_ioctl_ctxt(struct obd_device *obd, struct obd_run_ctxt *saved, - struct llog_ctxt *ctxt); -int llog_ioctl(struct llog_ctxt *ctxt, int cmd, - struct obd_ioctl_data *data, void *arg, int len); int llog_cat_id2handle(struct llog_handle *cathandle, struct llog_handle **res, struct llog_logid *logid); #endif diff --git a/lustre/obdclass/llog_ioctl.c b/lustre/obdclass/llog_ioctl.c index c7919de..03279f8 100644 --- a/lustre/obdclass/llog_ioctl.c +++ b/lustre/obdclass/llog_ioctl.c @@ -8,10 +8,13 @@ #define DEBUG_SUBSYSTEM S_LOG +#ifndef EXPORT_SYMTAB +#define EXPORT_SYMTAB +#endif + #include #include #include -#include /* for LUSTRE_MDC/MDS_NAME */ #include #include "llog_internal.h" @@ -142,41 +145,7 @@ out: } -struct llog_ctxt* push_llog_ioctl_ctxt(struct obd_device *obd, - struct obd_run_ctxt *saved) -{ - struct llog_ctxt *ctxt = NULL; - - if (!strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME)) { - ctxt = obd->obd_llog_ctxt[LLOG_CONFIG_ORIG_CTXT]; - push_ctxt(saved, &ctxt->loc_exp->exp_obd->obd_ctxt, NULL); - } - /* FIXME: obdfilter is not ready. */ -#if 0 - else if (!strcmp(obd->obd_type->typ_name, "obdfilter")) { - ctxt = obd->obd_llog_ctxt[LLOG_SIZE_ORIG_CTXT]; - push_ctxt(saved, &ctxt->loc_exp->exp_obd->obd_ctxt, NULL); - } -#endif - else if (!strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME)) { - ctxt = obd->obd_llog_ctxt[LLOG_CONFIG_REPL_CTXT]; - } - - return ctxt; -} - -void pop_llog_ioctl_ctxt(struct obd_device *obd, - struct obd_run_ctxt *saved, - struct llog_ctxt *ctxt) -{ - if (!strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME) || - !strcmp(obd->obd_type->typ_name, "obdfilter")) - pop_ctxt(saved, &ctxt->loc_exp->exp_obd->obd_ctxt, NULL); - -} - -int llog_ioctl(struct llog_ctxt *ctxt, int cmd, - struct obd_ioctl_data *data, void *arg, int len) +int llog_ioctl(struct llog_ctxt *ctxt, int cmd, struct obd_ioctl_data *data) { struct llog_logid logid; int err = 0; @@ -226,9 +195,6 @@ int llog_ioctl(struct llog_ctxt *ctxt, int cmd, if (remains <= 0) CERROR("not enough space for log header info\n"); - err = copy_to_user(arg, data, len); - if (err) - err = -EFAULT; GOTO(out_close, err); } case OBD_IOC_LLOG_PRINT: { @@ -237,9 +203,6 @@ int llog_ioctl(struct llog_ctxt *ctxt, int cmd, if (err == -LLOG_EEMPTY) err = 0; - err = copy_to_user(arg, data, len); - if (err) - err = -EFAULT; GOTO(out_close, err); } case OBD_IOC_LLOG_CANCEL: { @@ -285,3 +248,47 @@ out_close: out: RETURN(err); } +EXPORT_SYMBOL(llog_ioctl); + +int llog_catlog_list(struct obd_device *obd, int count, + struct obd_ioctl_data *data) +{ + int size, i; + struct llog_logid *idarray, *id; + char name[32] = "CATLIST"; + char *out; + int l, remains, rc = 0; + + 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) { + OBD_FREE(idarray, size); + RETURN(rc); + } + + out = data->ioc_bulk; + remains = data->ioc_inllen1; + id = idarray; + for (i = 0; i < count; i++) { + l = snprintf(out, remains, + "catalog log: #%llx#%llx#%08x\n", + id->lgl_oid, id->lgl_ogr, id->lgl_ogen); + id++; + out += l; + remains -= l; + if (remains <= 0) { + CWARN("not enough memory for catlog list\n"); + break; + } + } + OBD_FREE(idarray, size); + RETURN(0); + +} +EXPORT_SYMBOL(llog_catlog_list); -- 1.8.3.1