From 2982978eb97e0607dfba319fcb2ef94d2cb8807a Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 12 Nov 2020 10:13:33 -0600 Subject: [PATCH] LU-14136 utils: correct error message in lfs mirror extend In migrate_open_files(), use llapi_layout_file_open() instead of lfs_component_create() to avoid printing a confusing error message and to ensure that the type of error is correctly propagated. Signed-off-by: John L. Hammond Change-Id: I31ebf29771b1a3e0b106a0a246a260a82eed92a4 Reviewed-on: https://review.whamcloud.com/40631 Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Tested-by: jenkins Reviewed-by: Gu Zheng Tested-by: Maloo --- lustre/utils/lfs.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 299bf3e..15a2f77 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -761,9 +761,6 @@ enum { MIGRATION_VERBOSE = 0x0008, }; -static int lfs_component_create(char *fname, int open_flags, mode_t open_mode, - struct llapi_layout *layout); - static int migrate_open_files(const char *name, __u64 migration_flags, const struct llapi_stripe_param *param, @@ -839,12 +836,17 @@ migrate_open_files(const char *name, __u64 migration_flags, } /* create, open a volatile file, use caching (ie no directio) */ - if (layout) - fdv = lfs_component_create(volatile_file, open_flags, - open_mode, layout); - else + if (layout) { + /* Returns -1 and sets errno on error: */ + fdv = llapi_layout_file_open(volatile_file, open_flags, + open_mode, layout); + if (fdv < 0) + fdv = -errno; + } else { + /* Does the right thing on error: */ fdv = llapi_file_open_param(volatile_file, open_flags, open_mode, param); + } } while (fdv < 0 && (rc = fdv) == -EEXIST); if (rc < 0) { -- 1.8.3.1