Whamcloud - gitweb
LU-13609 llog: list all the log files correctly on MGS/MDT
[fs/lustre-release.git] / lustre / obdclass / llog_ioctl.c
index 1ee49ad..894e2ea 100644 (file)
@@ -167,7 +167,7 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle,
                        RETURN(rc);
                }
                rc = llog_process(env, loghandle, llog_check_cb, NULL, NULL);
-               llog_handle_put(loghandle);
+               llog_handle_put(env, loghandle);
        } else {
                bool ok;
 
@@ -292,7 +292,7 @@ static int llog_remove_log(const struct lu_env *env, struct llog_handle *cat,
        }
        llog_cat_cleanup(env, cat, log, log->u.phd.phd_cookie.lgc_index);
 out:
-       llog_handle_put(log);
+       llog_handle_put(env, log);
        RETURN(rc);
 
 }
@@ -497,15 +497,28 @@ int llog_catalog_list(const struct lu_env *env, struct dt_device *d,
 
        out = data->ioc_bulk;
        remains = data->ioc_inllen1;
-       for (i = 0; i < count; i++) {
+       /* 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);
+                             PFID(&id->lgl_oi.oi_fid), id->lgl_ogen);
                out += l;
                remains -= l;
-               if (remains <= 0)
-                       break;
+               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);