From 9514d54b6a968e7e126a5bd0cb33fe06eac3b00b Mon Sep 17 00:00:00 2001 From: Steve Guminski Date: Thu, 10 Aug 2017 09:37:00 -0400 Subject: [PATCH 1/1] LU-5170 lfs: Standardize llapi messages for lfs_find() Error messages in the llapi functions called by lfs_find() 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: Ia324887964b4a89cc5d4f92d3f3a7fa421e03dca Reviewed-on: https://review.whamcloud.com/28997 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Nunez --- lustre/utils/liblustreapi.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index e3e3e5c..351990d 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -502,13 +502,13 @@ static int get_mds_md_size(const char *path) rc = llapi_getname(path, inst, sizeof(inst)); if (rc != 0) - return md_size; + return rc; /* Get the max ea size from llite parameters. */ rc = get_lustre_param_value("llite", inst, FILTER_BY_EXACT, "max_easize", buf, sizeof(buf)); if (rc != 0) - return md_size; + return rc; rc = atoi(buf); @@ -1640,6 +1640,9 @@ static int common_param_init(struct find_param *param, char *path) { int lum_size = get_mds_md_size(path); + if (lum_size < 0) + return lum_size; + if (lum_size < PATH_MAX + 1) lum_size = PATH_MAX + 1; @@ -1970,12 +1973,13 @@ out: int llapi_file_fget_lov_uuid(int fd, struct obd_uuid *lov_name) { - int rc = ioctl(fd, OBD_IOC_GETNAME, lov_name); - if (rc) { - rc = -errno; - llapi_error(LLAPI_MSG_ERROR, rc, "error: can't get lov name."); - } - return rc; + int rc = ioctl(fd, OBD_IOC_GETNAME, lov_name); + + if (rc) { + rc = -errno; + llapi_error(LLAPI_MSG_ERROR, rc, "cannot get lov name"); + } + return rc; } int llapi_file_fget_lmv_uuid(int fd, struct obd_uuid *lov_name) @@ -1995,7 +1999,7 @@ int llapi_file_get_lov_uuid(const char *path, struct obd_uuid *lov_uuid) fd = open(path, O_RDONLY | O_NONBLOCK); if (fd < 0) { rc = -errno; - llapi_error(LLAPI_MSG_ERROR, rc, "error opening %s", path); + llapi_error(LLAPI_MSG_ERROR, rc, "cannot open '%s'", path); return rc; } @@ -2260,9 +2264,9 @@ retry_get_uuids: ret = -ENOMEM; } - llapi_error(LLAPI_MSG_ERROR, ret, "get ost uuid failed"); - goto out_free; - } + llapi_error(LLAPI_MSG_ERROR, ret, "cannot get ost uuid"); + goto out_free; + } indexes = malloc(num_obds * sizeof(*obdindex)); if (indexes == NULL) { @@ -2288,14 +2292,14 @@ retry_get_uuids: } } } - if (i >= obdcount) { - indexes[obdnum] = OBD_NOT_FOUND; - llapi_err_noerrno(LLAPI_MSG_ERROR, - "error: %s: unknown obduuid: %s", - __func__, obduuids[obdnum].uuid); - ret = -EINVAL; - } - } + if (i >= obdcount) { + indexes[obdnum] = OBD_NOT_FOUND; + llapi_err_noerrno(LLAPI_MSG_ERROR, + "invalid obduuid '%s'", + obduuids[obdnum].uuid); + ret = -EINVAL; + } + } if (obd_valid == 0) *obdindex = OBD_NOT_FOUND; -- 1.8.3.1