Whamcloud - gitweb
LU-13609 mgs: fix config_log buffer handling 78/41478/5
authorStephane Thiell <sthiell@stanford.edu>
Thu, 11 Feb 2021 00:15:02 +0000 (16:15 -0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 26 Feb 2021 08:25:12 +0000 (08:25 +0000)
Fix buffer handling in mgs_list_logs() to list all MGS config_logs
using multiple ioctl calls when we have a large number of targets.

Fixes: 1d97a8b4cd3d ("LU-13609 llog: list all the log files correctly on MGS/MDT")
Signed-off-by: Stephane Thiell <sthiell@stanford.edu>
Change-Id: I1bf32e918e242f4da83c3d1624b7285a18a88d01
Reviewed-on: https://review.whamcloud.com/41478
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Emoly Liu <emoly@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mgs/mgs_llog.c

index 3025dfb..28203c1 100644 (file)
@@ -4480,7 +4480,7 @@ int mgs_list_logs(const struct lu_env *env, struct mgs_device *mgs,
        struct mgs_direntry     *dirent, *n;
        char                    *out, *suffix, prefix[] = "config_log: ";
        int                      prefix_len = strlen(prefix);
        struct mgs_direntry     *dirent, *n;
        char                    *out, *suffix, prefix[] = "config_log: ";
        int                      prefix_len = strlen(prefix);
-       int                      l, remains, start = 0, rc;
+       int                      len, remains, start = 0, rc;
 
        ENTRY;
 
 
        ENTRY;
 
@@ -4499,8 +4499,8 @@ int mgs_list_logs(const struct lu_env *env, struct mgs_device *mgs,
                list_del_init(&dirent->mde_list);
                suffix = strrchr(dirent->mde_name, '-');
                if (suffix != NULL) {
                list_del_init(&dirent->mde_list);
                suffix = strrchr(dirent->mde_name, '-');
                if (suffix != NULL) {
-                       l = prefix_len + dirent->mde_len + 1;
-                       if (remains - 1 < 0) {
+                       len = prefix_len + dirent->mde_len + 1;
+                       if (remains - len < 0) {
                                /* No enough space for this record */
                                mgs_direntry_free(dirent);
                                goto out;
                                /* No enough space for this record */
                                mgs_direntry_free(dirent);
                                goto out;
@@ -4508,15 +4508,15 @@ int mgs_list_logs(const struct lu_env *env, struct mgs_device *mgs,
                        start++;
                        if (start < data->ioc_count) {
                                mgs_direntry_free(dirent);
                        start++;
                        if (start < data->ioc_count) {
                                mgs_direntry_free(dirent);
-                                       continue;
+                               continue;
                        }
                        }
-                       l = scnprintf(out, remains, "%s%s\n", prefix,
-                                     dirent->mde_name);
-                       out += l;
-                       remains -= l;
+                       len = scnprintf(out, remains, "%s%s\n", prefix,
+                                       dirent->mde_name);
+                       out += len;
+                       remains -= len;
                }
                mgs_direntry_free(dirent);
                }
                mgs_direntry_free(dirent);
-               if (remains == 0)
+               if (remains <= 1)
                        /* Full */
                        goto out;
        }
                        /* Full */
                        goto out;
        }