Whamcloud - gitweb
LU-14136 utils: correct error message in lfs mirror extend 31/40631/2
authorJohn L. Hammond <jhammond@whamcloud.com>
Thu, 12 Nov 2020 16:13:33 +0000 (10:13 -0600)
committerOleg Drokin <green@whamcloud.com>
Thu, 26 Nov 2020 09:27:03 +0000 (09:27 +0000)
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 <jhammond@whamcloud.com>
Change-Id: I31ebf29771b1a3e0b106a0a246a260a82eed92a4
Reviewed-on: https://review.whamcloud.com/40631
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Gu Zheng <gzheng@ddn.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/utils/lfs.c

index 299bf3e..15a2f77 100644 (file)
@@ -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) {