From: Thomas Stibor Date: Mon, 20 Nov 2017 15:36:57 +0000 (+0100) Subject: LU-10260 hsm: enable max archive_id posix copytool X-Git-Tag: 2.10.59~47 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;ds=sidebyside;h=c98a51f2cebd3417956f5823a0531311e2895028;p=fs%2Flustre-release.git LU-10260 hsm: enable max archive_id posix copytool The current maximum archive-id in posix copytool is limited to id < LL_HSM_MAX_ARCHIVE. However, the Lustre HSM implementation checks as follows for the maximum: if (id > LL_HSM_MAX_ARCHIVE) then flag ERROR. Thus the number of archive id's is in the range 0,1,..,32 = LL_HSM_MAX_ARCHIVE, and therefore 32 = LL_HSM_MAX_ARCHIVE should be included. Note, archive-id = 0 is reserved to specify to listen to ANY archive id and is use as default when no archive-id option is provided. Test-Parameters: trivial testlist=sanity-hsm Signed-off-by: Thomas Stibor Change-Id: I6289c8c0e7d86b05f1f2d821b7f6b3127e5fa352 Reviewed-on: https://review.whamcloud.com/30171 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin --- diff --git a/lustre/utils/lhsmtool_posix.c b/lustre/utils/lhsmtool_posix.c index d3633d6..05036af 100644 --- a/lustre/utils/lhsmtool_posix.c +++ b/lustre/utils/lhsmtool_posix.c @@ -88,7 +88,7 @@ struct options { int o_verbose; int o_copy_xattrs; int o_archive_cnt; - int o_archive_id[LL_HSM_MAX_ARCHIVE]; + int o_archive_id[LL_HSM_MAX_ARCHIVE + 1]; int o_report_int; unsigned long long o_bandwidth; size_t o_chunk_size; @@ -258,17 +258,28 @@ static int ct_parseopts(int argc, char * const *argv) while ((c = getopt_long(argc, argv, "A:b:c:f:hiMp:qru:v", long_opts, NULL)) != -1) { switch (c) { - case 'A': - if ((opt.o_archive_cnt >= LL_HSM_MAX_ARCHIVE) || - (atoi(optarg) >= LL_HSM_MAX_ARCHIVE)) { - rc = -E2BIG; + case 'A': { + char *end = NULL; + int val = strtol(optarg, &end, 10); + + if (*end != '\0') { + rc = -EINVAL; + CT_ERROR(rc, "invalid archive-id: '%s'", + optarg); + return rc; + } + + if (opt.o_archive_cnt > LL_HSM_MAX_ARCHIVE || + val > LL_HSM_MAX_ARCHIVE) { + rc = -EINVAL; CT_ERROR(rc, "archive number must be less" - "than %zu", LL_HSM_MAX_ARCHIVE); + " than %zu", LL_HSM_MAX_ARCHIVE + 1); return rc; } - opt.o_archive_id[opt.o_archive_cnt] = atoi(optarg); + opt.o_archive_id[opt.o_archive_cnt] = val; opt.o_archive_cnt++; break; + } case 'b': /* -b and -c have both a number with unit as arg */ case 'c': unit = ONE_MB; @@ -2001,4 +2012,3 @@ error_cleanup: return -rc; } -