From db831c666c24d23058021ca7e4a4cbaa63997fd9 Mon Sep 17 00:00:00 2001 From: Steve Guminski Date: Wed, 12 Jul 2017 12:43:22 -0400 Subject: [PATCH] LU-5170 lfs: Standardize error messages in adjust_first_extent Error and warning messages in adjust_first_extent() are updated to a standard format. Messages are prefixed with the name of the utility and the command that caused the error. User-provided values are delimited with single quotes. Test-Parameters: trivial Signed-off-by: Steve Guminski Change-Id: I9240fbce1f8fb065a17eaff1e4bbda70b4a5b0c9 Reviewed-on: https://review.whamcloud.com/28304 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger --- lustre/utils/lfs.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index bf061f3..b5b1ca6 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -1189,14 +1189,19 @@ static int adjust_first_extent(char *fname, struct llapi_layout *layout) uint64_t start, end, stripe_size, prev_end = 0; int rc; - if (layout == NULL) + if (layout == NULL) { + fprintf(stderr, + "%s setstripe: layout must be specified\n", + progname); return -EINVAL; + } errno = 0; head = llapi_layout_get_by_path(fname, 0); if (head == NULL) { - fprintf(stderr, "Read layout from %s failed. %s\n", - fname, strerror(errno)); + fprintf(stderr, + "%s setstripe: cannot read layout from '%s': %s\n", + progname, fname, strerror(errno)); return -EINVAL; } else if (errno == ENODATA) { /* file without LOVEA, this component-add will be turned @@ -1204,16 +1209,16 @@ static int adjust_first_extent(char *fname, struct llapi_layout *layout) llapi_layout_free(head); return -ENODATA; } else if (!llapi_layout_is_composite(head)) { - fprintf(stderr, "'%s' isn't a composite file.\n", - fname); + fprintf(stderr, "%s setstripe: '%s' not a composite file\n", + progname, fname); llapi_layout_free(head); return -EINVAL; } rc = llapi_layout_comp_extent_get(head, &start, &prev_end); if (rc) { - fprintf(stderr, "Get prev extent failed. %s\n", - strerror(errno)); + fprintf(stderr, "%s setstripe: cannot get prev extent: %s\n", + progname, strerror(errno)); llapi_layout_free(head); return rc; } @@ -1223,42 +1228,46 @@ static int adjust_first_extent(char *fname, struct llapi_layout *layout) /* Make sure we use the first component of the layout to be added. */ rc = llapi_layout_comp_use(layout, LLAPI_LAYOUT_COMP_USE_FIRST); if (rc < 0) { - fprintf(stderr, "Move component cursor failed. %s\n", - strerror(errno)); + fprintf(stderr, + "%s setstripe: cannot move component cursor: %s\n", + progname, strerror(errno)); return rc; } rc = llapi_layout_comp_extent_get(layout, &start, &end); if (rc) { - fprintf(stderr, "Get extent failed. %s\n", strerror(errno)); + fprintf(stderr, "%s setstripe: cannot get extent: %s\n", + progname, strerror(errno)); return rc; } if (start > prev_end || end <= prev_end) { - fprintf(stderr, "First extent to be set [%lu, %lu) isn't " - "adjacent with the existing file extent end: %lu\n", - start, end, prev_end); + fprintf(stderr, + "%s setstripe: first extent [%lu, %lu) not adjacent with extent end %lu\n", + progname, start, end, prev_end); return -EINVAL; } rc = llapi_layout_stripe_size_get(layout, &stripe_size); if (rc) { - fprintf(stderr, "Get stripe size failed. %s\n", - strerror(errno)); + fprintf(stderr, "%s setstripe: cannot get stripe size: %s\n", + progname, strerror(errno)); return rc; } if (stripe_size != LLAPI_LAYOUT_DEFAULT && (prev_end & (stripe_size - 1))) { - fprintf(stderr, "Stripe size %lu not aligned with %lu\n", - stripe_size, prev_end); + fprintf(stderr, + "%s setstripe: stripe size %lu not aligned with %lu\n", + progname, stripe_size, prev_end); return -EINVAL; } rc = llapi_layout_comp_extent_set(layout, prev_end, end); if (rc) { - fprintf(stderr, "Set component extent [%lu, %lu) failed. %s\n", - prev_end, end, strerror(errno)); + fprintf(stderr, + "%s setstripe: cannot set component extent [%lu, %lu): %s\n", + progname, prev_end, end, strerror(errno)); return rc; } -- 1.8.3.1