From 7f04890a1b5f806cde7db0666a45b9f73cafa9b8 Mon Sep 17 00:00:00 2001 From: Stephane Thiell Date: Wed, 10 Feb 2021 16:15:02 -0800 Subject: [PATCH] LU-13609 mgs: fix config_log buffer handling 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. Lustre-change: https://review.whamcloud.com/41478 Lustre-commit: e3f17defc141d8847562b610931255d37ed4dd3c Fixes: 1d97a8b4cd3d ("LU-13609 llog: list all the log files correctly on MGS/MDT") Signed-off-by: Stephane Thiell Change-Id: I1bf32e918e242f4da83c3d1624b7285a18a88d01 Reviewed-by: Andreas Dilger Reviewed-by: Emoly Liu Signed-off-by: Minh Diep Reviewed-on: https://review.whamcloud.com/41777 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/mgs/mgs_llog.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index 9c30a36..3fba4ad 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -4473,7 +4473,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); - int l, remains, start = 0, rc; + int len, remains, start = 0, rc; ENTRY; @@ -4492,8 +4492,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) { - 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; @@ -4503,13 +4503,13 @@ int mgs_list_logs(const struct lu_env *env, struct mgs_device *mgs, mgs_direntry_free(dirent); 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); - if (remains == 0) + if (remains <= 1) /* Full */ goto out; } -- 1.8.3.1