Whamcloud - gitweb
r=adilger
[fs/lustre-release.git] / lustre / obdclass / llog_ioctl.c
index 14d20f2..0e5d201 100644 (file)
@@ -15,8 +15,7 @@
 #include <linux/fs.h>
 #include <linux/obd_class.h>
 #include <linux/lustre_log.h>
-#include <portals/list.h>
-#include "llog_internal.h"
+#include <libcfs/list.h>
 
 static int str2logid(struct llog_logid *logid, char *str, int len)
 {
@@ -34,7 +33,7 @@ static int str2logid(struct llog_logid *logid, char *str, int len)
                 RETURN(-EINVAL);
 
         *end = '\0';
-        logid->lgl_oid = simple_strtoull(start, &endp, 16);
+        logid->lgl_oid = simple_strtoull(start, &endp, 0);
         if (endp != end)
                 RETURN(-EINVAL);
 
@@ -46,7 +45,7 @@ static int str2logid(struct llog_logid *logid, char *str, int len)
                 RETURN(-EINVAL);
 
         *end = '\0';
-        logid->lgl_ogr = simple_strtoull(start, &endp, 16);
+        logid->lgl_ogr = simple_strtoull(start, &endp, 0);
         if (endp != end)
                 RETURN(-EINVAL);
 
@@ -253,12 +252,12 @@ int llog_ioctl(struct llog_ctxt *ctxt, int cmd, struct obd_ioctl_data *data)
                 err = str2logid(&logid, data->ioc_inlbuf1, data->ioc_inllen1);
                 if (err)
                         GOTO(out, err);
-                err = llog_create(ctxt, &handle, &logid, NULL);
+                err = llog_open(ctxt, &handle, &logid, NULL, 0);
                 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(ctxt, &handle, NULL, name, 0);
                 if (err)
                         GOTO(out, err);
         } else {
@@ -305,9 +304,11 @@ int llog_ioctl(struct llog_ctxt *ctxt, int cmd, struct obd_ioctl_data *data)
 
         case OBD_IOC_LLOG_PRINT: {
                 LASSERT(data->ioc_inllen1);
-                err = llog_process(handle, llog_print_cb, data, NULL);
+                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);
         }
@@ -316,15 +317,23 @@ int llog_ioctl(struct llog_ctxt *ctxt, int cmd, struct obd_ioctl_data *data)
                 struct llog_logid plain;
                 char *endp;
 
-                if (!(handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT))
+                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;
-                cookie.lgc_index = simple_strtoul(data->ioc_inlbuf3, &endp, 0);
-                if (*endp != '\0')
+
+                if (!(handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT))
                         GOTO(out_close, err = -EINVAL);
 
                 err = llog_cat_cancel_records(handle, 1, &cookie);
@@ -333,6 +342,13 @@ int llog_ioctl(struct llog_ctxt *ctxt, int cmd, struct obd_ioctl_data *data)
         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);
 
@@ -362,8 +378,8 @@ out:
 }
 EXPORT_SYMBOL(llog_ioctl);
 
-int llog_catlog_list(struct obd_device *obd, int count,
-                     struct obd_ioctl_data *data)
+int llog_catalog_list(struct obd_device *obd, int count,
+                      struct obd_ioctl_data *data)
 {
         int size, i;
         struct llog_catid *idarray;
@@ -379,7 +395,8 @@ int llog_catlog_list(struct obd_device *obd, int count,
                 RETURN(-ENOMEM);
         memset(idarray, 0, size);
 
-        rc = llog_get_cat_list(obd, obd, name, count, idarray);
+        rc = llog_get_cat_list(&obd->obd_lvfs_ctxt, obd->obd_fsops,
+                               name, count, idarray);
         if (rc) {
                 OBD_FREE(idarray, size);
                 RETURN(rc);
@@ -403,4 +420,4 @@ int llog_catlog_list(struct obd_device *obd, int count,
         RETURN(0);
 
 }
-EXPORT_SYMBOL(llog_catlog_list);
+EXPORT_SYMBOL(llog_catalog_list);