Whamcloud - gitweb
LU-16587 utils: give lfs migrate a larger buffer 18/50118/5
authorNathan Rutman <nathan.rutman@hpe.com>
Wed, 22 Feb 2023 22:34:09 +0000 (14:34 -0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 21 Mar 2023 23:14:50 +0000 (23:14 +0000)
lfs migrate is slow because it mostly uses a small 1MB buffer. Bigify.

[root@kjlmo4n00 16G]# time lfs migrate -S 1M -p flash 16G.1
real 0m25.341s
[root@kjlmo4n00 16G]# time /root/tools/lfs_nzr migrate -S 1M -p flash 16G.1
real 0m6.526s

Signed-off-by: Nathan Rutman <nathan.rutman@hpe.com>
Change-Id: I850ca475fcd0efe2d71d26e4d1544f462c60252a
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50118
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/utils/lfs.c

index f3ca066..96cff47 100644 (file)
@@ -832,7 +832,7 @@ static int migrate_copy_data(int fd_src, int fd_dst, int (*check_file)(int),
                             long stats_interval_sec, off_t file_size_bytes)
 {
        struct llapi_layout *layout;
-       size_t buf_size = 4 * 1024 * 1024;
+       size_t buf_size = 64 * 1024 * 1024;
        void *buf = NULL;
        off_t pos = 0;
        off_t data_end = 0;
@@ -850,8 +850,14 @@ static int migrate_copy_data(int fd_src, int fd_dst, int (*check_file)(int),
                uint64_t stripe_size;
 
                rc = llapi_layout_stripe_size_get(layout, &stripe_size);
-               if (rc == 0)
-                       buf_size = stripe_size;
+               if (rc == 0) {
+                       /* We like big bufs */
+                       if (stripe_size > buf_size)
+                               buf_size = stripe_size;
+                       else
+                               /* Trim to stripe_size multiple */
+                               buf_size -= buf_size % stripe_size;
+               }
 
                llapi_layout_free(layout);
        }