From 80e9ebc1b1e44069f058d0ee81f0fd871b8f8748 Mon Sep 17 00:00:00 2001 From: Sebastien Piechurski Date: Tue, 16 Jun 2020 18:14:55 +0200 Subject: [PATCH] LU-13683 lfs: return -ENOENT when invoked on non-existing file Since merge of LU-11510, lfs migrate on a non-existing file will give the following error "lfs migrate: can't create composite layout from file /some/path/to/file" and will exit with code 0, potentially leaving a calling script unaware of the error. This patch fixes it by using errno which is set in the call to llapi_layout_get_by_path() Lustre-change: https://review.whamcloud.com/38953 Lustre-commit: 52d7cb5913c1e653a89d3a4de5f39c0e596dd28c Signed-off-by: Sebastien Piechurski Change-Id: I910eae78445f6071ff4e741afd43d140f554ab22 Fixes: 8bedfa377fbd ("LU-11510 lfs: migrate a composite layout file correctly") Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/40709 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Olaf Faaland Reviewed-by: Andreas Dilger Reviewed-by: Gian-Carlo DeFazio --- lustre/utils/lfs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 715215b..08d768b 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -3441,10 +3441,12 @@ static int lfs_setstripe_internal(int argc, char **argv, for (fname = argv[optind]; fname != NULL; fname = argv[++optind]) { if (from_copy) { layout = llapi_layout_get_by_path(template ?: fname, 0); - if (layout == NULL) { - fprintf(stderr, "%s: can't create composite " - "layout from file %s.\n", - progname, template ?: fname); + if (!layout) { + fprintf(stderr, + "%s: can't create composite layout from file %s: %s\n", + progname, template ?: fname, + strerror(errno)); + result = -errno; goto error; } } -- 1.8.3.1