Whamcloud - gitweb
LU-13609 llog: list all the log files correctly on MGS/MDT
[fs/lustre-release.git] / lustre / obdclass / llog_ioctl.c
index a20a077..894e2ea 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Intel, Inc.
+ * Copyright (c) 2011, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 #define DEBUG_SUBSYSTEM S_LOG
 
 #include <obd_class.h>
+#include <uapi/linux/lustre/lustre_ioctl.h>
 #include <lustre_log.h>
 #include "llog_internal.h"
 
 static int str2logid(struct llog_logid *logid, char *str, int len)
 {
-        char *start, *end, *endp;
+       unsigned long long id, seq;
+       char *start, *end;
+       u32 ogen;
+       int rc;
 
-        ENTRY;
-        start = str;
-        if (*start != '#')
-                RETURN(-EINVAL);
+       ENTRY;
+       start = str;
+       if (start[0] == '[') {
+               struct lu_fid *fid = &logid->lgl_oi.oi_fid;
+               int num;
+
+               fid_zero(fid);
+               logid->lgl_ogen = 0;
+               num = sscanf(start + 1, SFID, RFID(fid));
+               CDEBUG(D_INFO, DFID":%x\n", PFID(fid), logid->lgl_ogen);
+               RETURN(num == 3 && fid_is_sane(fid) ? 0 : -EINVAL);
+       }
 
-        start++;
-        if (start - str >= len - 1)
-                RETURN(-EINVAL);
-        end = strchr(start, '#');
-        if (end == NULL || end == start)
-                RETURN(-EINVAL);
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 1, 53, 0)
+       /*
+        * logids used to be input in the form "#id#seq:ogen" before they
+        * were changed over to accept the FID [seq:oid:ver] format.
+        * This is accepted for compatibility reasons, though I doubt
+        * anyone is actually using this for anything.
+        */
+       if (start[0] != '#')
+               RETURN(-EINVAL);
 
-        *end = '\0';
-        logid->lgl_oid = simple_strtoull(start, &endp, 0);
-        if (endp != end)
-                RETURN(-EINVAL);
+       start++;
+       if (start - str >= len - 1)
+               RETURN(-EINVAL);
+       end = strchr(start, '#');
+       if (end == NULL || end == start)
+               RETURN(-EINVAL);
 
-        start = ++end;
-        if (start - str >= len - 1)
-                RETURN(-EINVAL);
-        end = strchr(start, '#');
-        if (end == NULL || end == start)
-                RETURN(-EINVAL);
+       *end = '\0';
+       rc = kstrtoull(start, 0, &id);
+       if (rc)
+               RETURN(rc);
 
-        *end = '\0';
-        logid->lgl_oseq = simple_strtoull(start, &endp, 0);
-        if (endp != end)
-                RETURN(-EINVAL);
+       start = ++end;
+       if (start - str >= len - 1)
+               RETURN(-EINVAL);
 
-        start = ++end;
-        if (start - str >= len - 1)
-                RETURN(-EINVAL);
-        logid->lgl_ogen = simple_strtoul(start, &endp, 16);
-        if (*endp != '\0')
+       end = strchr(start, '#');
+       if (!end || end == start)
+               RETURN(-EINVAL);
+
+       *end = '\0';
+       rc = kstrtoull(start, 0, &seq);
+       if (rc)
+               RETURN(rc);
+
+       ostid_set_seq(&logid->lgl_oi, seq);
+       if (ostid_set_id(&logid->lgl_oi, id))
+               RETURN(-EINVAL);
+
+       start = ++end;
+       if (start - str >= len - 1)
+               RETURN(-EINVAL);
+
+       rc = kstrtouint(start, 16, &ogen);
+       if (rc)
                 RETURN(-EINVAL);
+       logid->lgl_ogen = ogen;
 
-        RETURN(0);
+       RETURN(0);
+#else
+       RETURN(-EINVAL);
+#endif
 }
 
 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;
-        static char *out;
-        char *endp;
-        int cur_index, rc = 0;
-
-        ENTRY;
+       struct obd_ioctl_data *ioc_data = data;
+       static int l, remains;
+       static long from, to;
+       static char *out;
+       int cur_index;
+       int rc = 0;
 
+       ENTRY;
        if (ioc_data && ioc_data->ioc_inllen1 > 0) {
-                l = 0;
-                remains = ioc_data->ioc_inllen4 +
-                        cfs_size_round(ioc_data->ioc_inllen1) +
-                        cfs_size_round(ioc_data->ioc_inllen2) +
-                        cfs_size_round(ioc_data->ioc_inllen3);
-                from = simple_strtol(ioc_data->ioc_inlbuf2, &endp, 0);
-                if (*endp != '\0')
-                        RETURN(-EINVAL);
-                to = simple_strtol(ioc_data->ioc_inlbuf3, &endp, 0);
-                if (*endp != '\0')
-                        RETURN(-EINVAL);
-                ioc_data->ioc_inllen1 = 0;
-                out = ioc_data->ioc_bulk;
+               l = 0;
+               remains = ioc_data->ioc_inllen4 +
+                         round_up(ioc_data->ioc_inllen1, 8) +
+                         round_up(ioc_data->ioc_inllen2, 8) +
+                         round_up(ioc_data->ioc_inllen3, 8);
+
+               rc = kstrtol(ioc_data->ioc_inlbuf2, 0, &from);
+               if (rc)
+                       RETURN(rc);
+
+               rc = kstrtol(ioc_data->ioc_inlbuf3, 0, &to);
+               if (rc)
+                       RETURN(rc);
+
+               ioc_data->ioc_inllen1 = 0;
+               out = ioc_data->ioc_bulk;
        }
 
        cur_index = rec->lrh_index;
@@ -116,37 +147,36 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle,
        if (to > 0 && cur_index > to)
                RETURN(-LLOG_EEMPTY);
 
-        if (handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) {
-                struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
-                struct llog_handle *log_handle;
-
-                if (rec->lrh_type != LLOG_LOGID_MAGIC) {
-                        l = snprintf(out, remains, "[index]: %05d  [type]: "
-                                     "%02x  [len]: %04d failed\n",
-                                     cur_index, rec->lrh_type,
-                                     rec->lrh_len);
-                }
-                if (handle->lgh_ctxt == NULL)
-                        RETURN(-EOPNOTSUPP);
-               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_oid, lir->lid_id.lgl_oseq,
-                               lir->lid_id.lgl_ogen);
-                        RETURN(rc);
-                }
-               rc = llog_process(env, log_handle, llog_check_cb, NULL, NULL);
-               llog_close(env, log_handle);
-        } else {
+       if (handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) {
+               struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
+               struct llog_handle *loghandle;
+
+               if (rec->lrh_type != LLOG_LOGID_MAGIC) {
+                       l = snprintf(out, remains,
+                                    "[index]: %05d  [type]: %02x  [len]: %04d failed\n",
+                                    cur_index, rec->lrh_type,
+                                    rec->lrh_len);
+               }
+               if (handle->lgh_ctxt == NULL)
+                       RETURN(-EOPNOTSUPP);
+               rc = llog_cat_id2handle(env, handle, &loghandle, &lir->lid_id);
+               if (rc) {
+                       CDEBUG(D_IOCTL, "cannot find log "DFID":%x\n",
+                              PFID(&lir->lid_id.lgl_oi.oi_fid),
+                              lir->lid_id.lgl_ogen);
+                       RETURN(rc);
+               }
+               rc = llog_process(env, loghandle, llog_check_cb, NULL, NULL);
+               llog_handle_put(env, loghandle);
+       } else {
                bool ok;
 
-                switch (rec->lrh_type) {
-                case OST_SZ_REC:
-                case MDS_UNLINK_REC:
+               switch (rec->lrh_type) {
+               case OST_SZ_REC:
+               case MDS_UNLINK_REC:
                case MDS_UNLINK64_REC:
-                case MDS_SETATTR64_REC:
-                case OBD_CFG_REC:
+               case MDS_SETATTR64_REC:
+               case OBD_CFG_REC:
                case LLOG_GEN_REC:
                case LLOG_HDR_MAGIC:
                        ok = true;
@@ -173,51 +203,55 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle,
 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;
-        static char *out;
-        char *endp;
-        int cur_index;
-
-        ENTRY;
-       if (ioc_data != NULL && ioc_data->ioc_inllen1 > 0) {
-                l = 0;
-                remains = ioc_data->ioc_inllen4 +
-                        cfs_size_round(ioc_data->ioc_inllen1) +
-                        cfs_size_round(ioc_data->ioc_inllen2) +
-                        cfs_size_round(ioc_data->ioc_inllen3);
-                from = simple_strtol(ioc_data->ioc_inlbuf2, &endp, 0);
-                if (*endp != '\0')
-                        RETURN(-EINVAL);
-                to = simple_strtol(ioc_data->ioc_inlbuf3, &endp, 0);
-                if (*endp != '\0')
-                        RETURN(-EINVAL);
-                out = ioc_data->ioc_bulk;
-                ioc_data->ioc_inllen1 = 0;
-        }
-
-        cur_index = rec->lrh_index;
-        if (cur_index < from)
-                RETURN(0);
-        if (to > 0 && cur_index > to)
-                RETURN(-LLOG_EEMPTY);
-
-        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);
-                }
-
-                l = snprintf(out, remains,
-                             "[index]: %05d  [logid]: #"LPX64"#"LPX64"#%08x\n",
-                             cur_index, lir->lid_id.lgl_oid,
-                             lir->lid_id.lgl_oseq, lir->lid_id.lgl_ogen);
+       struct obd_ioctl_data *ioc_data = data;
+       static int l, remains;
+       static long from, to;
+       static char *out;
+       int cur_index;
+       int rc;
+
+       ENTRY;
+       if (ioc_data && ioc_data->ioc_inllen1 > 0) {
+               l = 0;
+               remains = ioc_data->ioc_inllen4 +
+                         round_up(ioc_data->ioc_inllen1, 8) +
+                         round_up(ioc_data->ioc_inllen2, 8) +
+                         round_up(ioc_data->ioc_inllen3, 8);
+
+               rc = kstrtol(ioc_data->ioc_inlbuf2, 0, &from);
+               if (rc)
+                       RETURN(rc);
+
+               rc = kstrtol(ioc_data->ioc_inlbuf3, 0, &to);
+               if (rc)
+                       RETURN(rc);
+
+               out = ioc_data->ioc_bulk;
+               ioc_data->ioc_inllen1 = 0;
+       }
+
+       cur_index = rec->lrh_index;
+       if (cur_index < from)
+               RETURN(0);
+       if (to > 0 && cur_index > to)
+               RETURN(-LLOG_EEMPTY);
+
+       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);
+               }
+
+               l = snprintf(out, remains,
+                            "[index]: %05d  [logid]: "DFID":%x\n",
+                            cur_index, PFID(&lir->lid_id.lgl_oi.oi_fid),
+                            lir->lid_id.lgl_ogen);
        } else if (rec->lrh_type == OBD_CFG_REC) {
                int rc;
 
-               rc = class_config_parse_rec(rec, out, remains);
+               rc = class_config_yaml_output(rec, out, remains);
                if (rc < 0)
                        RETURN(rc);
                l = rc;
@@ -225,46 +259,40 @@ static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle,
                l = snprintf(out, remains,
                             "[index]: %05d  [type]: %02x  [len]: %04d\n",
                             cur_index, rec->lrh_type, rec->lrh_len);
-        }
-        out += l;
-        remains -= l;
-        if (remains <= 0) {
-                CERROR("not enough space for print log records\n");
-                RETURN(-LLOG_EEMPTY);
-        }
-
-        RETURN(0);
+       }
+       out += l;
+       remains -= l;
+       if (remains <= 0) {
+               CERROR("not enough space for print log records\n");
+               RETURN(-LLOG_EEMPTY);
+       }
+
+       RETURN(0);
 }
 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;
+       struct llog_handle *log;
+       int rc;
 
-        ENTRY;
+       ENTRY;
 
        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);
-                GOTO(out, rc = -ENOENT);
-        }
-
-        index = log->u.phd.phd_cookie.lgc_index;
-        LASSERT(index);
+       if (rc) {
+               CDEBUG(D_IOCTL, "cannot find log "DFID":%x\n",
+                      PFID(&logid->lgl_oi.oi_fid), logid->lgl_ogen);
+               RETURN(-ENOENT);
+       }
+
        rc = llog_destroy(env, log);
        if (rc) {
-               CDEBUG(D_IOCTL, "cannot destroy log\n");
+               CDEBUG(D_IOCTL, "cannot destroy log "DFID":%x\n",
+                      PFID(&logid->lgl_oi.oi_fid), logid->lgl_ogen);
                GOTO(out, rc);
        }
-       cfs_down_write(&cat->lgh_lock);
-       if (cat->u.chd.chd_current_log == log)
-               cat->u.chd.chd_current_log = NULL;
-       cfs_up_write(&cat->lgh_lock);
-       llog_cat_set_first_idx(cat, index);
-       rc = llog_cancel_rec(env, cat, index);
+       llog_cat_cleanup(env, cat, log, log->u.phd.phd_cookie.lgc_index);
 out:
-       llog_close(env, log);
+       llog_handle_put(env, log);
        RETURN(rc);
 
 }
@@ -272,8 +300,8 @@ out:
 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)
@@ -287,29 +315,36 @@ static int llog_delete_cb(const struct lu_env *env, struct llog_handle *handle,
 int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd,
               struct obd_ioctl_data *data)
 {
-       struct llog_logid        logid;
-       int                      rc = 0;
-       struct llog_handle      *handle = NULL;
+       struct llog_logid logid;
+       int rc = 0;
+       struct llog_handle *handle = NULL;
+       char *logname, start;
 
        ENTRY;
 
-       if (*data->ioc_inlbuf1 == '#') {
-               rc = str2logid(&logid, data->ioc_inlbuf1, data->ioc_inllen1);
+       logname = data->ioc_inlbuf1;
+       start = logname[0];
+       if (start == '#' || start == '[') {
+               rc = str2logid(&logid, logname, data->ioc_inllen1);
                if (rc)
                        RETURN(rc);
                rc = llog_open(env, ctxt, &handle, &logid, NULL,
                               LLOG_OPEN_EXISTS);
                if (rc)
                        RETURN(rc);
-       } else if (*data->ioc_inlbuf1 == '$') {
-               char *name = data->ioc_inlbuf1 + 1;
+       } else if (start == '$' || isalpha(start) || isdigit(start)) {
+               if (start == '$')
+                       logname++;
 
-               rc = llog_open(env, ctxt, &handle, NULL, name,
+               rc = llog_open(env, ctxt, &handle, NULL, logname,
                               LLOG_OPEN_EXISTS);
                if (rc)
                        RETURN(rc);
        } else {
-               RETURN(-EINVAL);
+               rc = -EINVAL;
+               CDEBUG(D_INFO, "%s: invalid log name '%s': rc = %d\n",
+                     ctxt->loc_obd->obd_name, logname, rc);
+               RETURN(rc);
        }
 
        rc = llog_init_handle(env, handle, 0, NULL);
@@ -318,25 +353,25 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd,
 
        switch (cmd) {
        case OBD_IOC_LLOG_INFO: {
-               int      l;
-               int      remains = data->ioc_inllen2 +
+               int l;
+               int remains = data->ioc_inllen2 +
                                   cfs_size_round(data->ioc_inllen1);
-               char    *out = data->ioc_bulk;
-
-                l = snprintf(out, remains,
-                             "logid:            #"LPX64"#"LPX64"#%08x\n"
-                             "flags:            %x (%s)\n"
-                             "records count:    %d\n"
-                             "last index:       %d\n",
-                             handle->lgh_id.lgl_oid, handle->lgh_id.lgl_oseq,
-                             handle->lgh_id.lgl_ogen,
-                             handle->lgh_hdr->llh_flags,
-                             handle->lgh_hdr->llh_flags &
-                             LLOG_F_IS_CAT ? "cat" : "plain",
-                             handle->lgh_hdr->llh_count,
-                             handle->lgh_last_idx);
-                out += l;
-                remains -= l;
+               char *out = data->ioc_bulk;
+
+               l = snprintf(out, remains,
+                            "logid:            "DFID":%x\n"
+                            "flags:            %x (%s)\n"
+                            "records_count:    %d\n"
+                            "last_index:       %d\n",
+                            PFID(&handle->lgh_id.lgl_oi.oi_fid),
+                            handle->lgh_id.lgl_ogen,
+                            handle->lgh_hdr->llh_flags,
+                            handle->lgh_hdr->llh_flags &
+                               LLOG_F_IS_CAT ? "cat" : "plain",
+                            handle->lgh_hdr->llh_count,
+                            handle->lgh_last_idx);
+               out += l;
+               remains -= l;
                if (remains <= 0) {
                        CERROR("%s: not enough space for log header info\n",
                               ctxt->loc_obd->obd_name);
@@ -363,14 +398,15 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd,
        case OBD_IOC_LLOG_CANCEL: {
                struct llog_cookie cookie;
                struct llog_logid plain;
-               char *endp;
+               u32 lgc_index;
 
-               cookie.lgc_index = simple_strtoul(data->ioc_inlbuf3, &endp, 0);
-               if (*endp != '\0')
-                       GOTO(out_close, rc = -EINVAL);
+               rc = kstrtouint(data->ioc_inlbuf3, 0, &lgc_index);
+               if (rc)
+                       GOTO(out_close, rc);
+               cookie.lgc_index = lgc_index;
 
                if (handle->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN) {
-                       rc = llog_cancel_rec(NULL, handle, cookie.lgc_index);
+                       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);
@@ -398,7 +434,7 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd,
                        GOTO(out_close, rc = -EINVAL);
                }
 
-               if (data->ioc_inlbuf2 > 0) {
+               if (data->ioc_inlbuf2) {
                        /* remove indicate log from the catalog */
                        rc = str2logid(&plain, data->ioc_inlbuf2,
                                       data->ioc_inllen2);
@@ -430,50 +466,61 @@ out_close:
 }
 EXPORT_SYMBOL(llog_ioctl);
 
-#ifdef HAVE_LDISKFS_OSD
-int llog_catalog_list(struct obd_device *obd, int count,
-                      struct obd_ioctl_data *data)
+int llog_catalog_list(const struct lu_env *env, struct dt_device *d,
+                     int count, struct obd_ioctl_data *data,
+                     const struct lu_fid *fid)
 {
-        int size, i;
-        struct llog_catid *idarray;
-        struct llog_logid *id;
-        char name[32] = CATLIST;
-        char *out;
-        int l, remains, rc = 0;
-
-        ENTRY;
-        size = sizeof(*idarray) * count;
-
-        OBD_ALLOC_LARGE(idarray, size);
-        if (!idarray)
-                RETURN(-ENOMEM);
-
-        cfs_mutex_lock(&obd->obd_olg.olg_cat_processing);
-        rc = llog_get_cat_list(obd, name, 0, count, idarray);
-        if (rc)
-                GOTO(out, rc);
-
-        out = data->ioc_bulk;
-        remains = data->ioc_inllen1;
-        for (i = 0; i < count; i++) {
-                id = &idarray[i].lci_logid;
-                l = snprintf(out, remains,
-                             "catalog log: #"LPX64"#"LPX64"#%08x\n",
-                             id->lgl_oid, id->lgl_oseq, id->lgl_ogen);
-                out += l;
-                remains -= l;
-                if (remains <= 0) {
-                        CWARN("not enough memory for catlog list\n");
-                        break;
-                }
-        }
-out:
-        /* release semaphore */
-        cfs_mutex_unlock(&obd->obd_olg.olg_cat_processing);
+       int size, i;
+       struct llog_catid *idarray;
+       struct llog_logid *id;
+       char *out;
+       int l, remains, rc = 0;
+
+       ENTRY;
+
+       if (count == 0) { /* get total number of logs */
+               rc = llog_osd_get_cat_list(env, d, 0, 0, NULL, fid);
+               if (rc < 0)
+                       RETURN(rc);
+               count = rc;
+       }
 
-        OBD_FREE_LARGE(idarray, size);
-        RETURN(rc);
+       size = sizeof(*idarray) * count;
 
+       OBD_ALLOC_LARGE(idarray, size);
+       if (!idarray)
+               RETURN(-ENOMEM);
+
+       rc = llog_osd_get_cat_list(env, d, 0, count, idarray, fid);
+       if (rc)
+               GOTO(out, rc);
+
+       out = data->ioc_bulk;
+       remains = data->ioc_inllen1;
+       /* OBD_FAIL: fetch the catalog records from the specified one */
+       if (OBD_FAIL_CHECK(OBD_FAIL_CATLIST))
+               data->ioc_count = cfs_fail_val - 1;
+       for (i = data->ioc_count; i < count; i++) {
+               id = &idarray[i].lci_logid;
+               l = snprintf(out, remains, "catalog_log: "DFID":%x\n",
+                             PFID(&id->lgl_oi.oi_fid), id->lgl_ogen);
+               out += l;
+               remains -= l;
+               if (remains <= 0) {
+                       if (remains < 0) {
+                               /* the print is not complete */
+                               remains += l;
+                               data->ioc_bulk[out - data->ioc_bulk - l] = '\0';
+                               data->ioc_count = i;
+                       } else {
+                               data->ioc_count = i++;
+                       }
+                       goto out;
+               }
+       }
+       data->ioc_count = 0;
+out:
+       OBD_FREE_LARGE(idarray, size);
+       RETURN(rc);
 }
 EXPORT_SYMBOL(llog_catalog_list);
-#endif