Whamcloud - gitweb
LU-16985 utils: adaptive bufsize for mirroring
authorAlex Zhuravlev <bzzz@whamcloud.com>
Wed, 26 Jul 2023 19:00:29 +0000 (22:00 +0300)
committerAndreas Dilger <adilger@whamcloud.com>
Tue, 1 Aug 2023 22:04:59 +0000 (22:04 +0000)
if bandwidth limit is requested, then change default bufsize to
make I/O rather smooth than like a saw.

Lustre-change: https://review.whamcloud.com/51773
Lustre-commit: TBD (from 390235cc52bd51dc807492db19d8a1f905dbd9d0)

Test-Parameters: trivial
Fixes: 23224e03dc ("LU-16587 utils: give lfs migrate a larger buffer")
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: Ibc8e7d30ded201a4ff3d699530f5c9f8be5ce7f1
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/51839
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/utils/lfs.c

index 8371adc..4495d2f 100644 (file)
@@ -1010,7 +1010,8 @@ 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 = 64 * 1024 * 1024;
+       size_t buf_size = 64 * ONE_MB;
+       uint64_t stripe_size = ONE_MB;
        void *buf = NULL;
        off_t pos = 0;
        off_t data_end = 0;
@@ -1025,8 +1026,6 @@ static int migrate_copy_data(int fd_src, int fd_dst, int (*check_file)(int),
 
        layout = llapi_layout_get_by_fd(fd_src, 0);
        if (layout) {
-               uint64_t stripe_size;
-
                rc = llapi_layout_stripe_size_get(layout, &stripe_size);
                if (rc == 0) {
                        /* We like big bufs */
@@ -1040,6 +1039,11 @@ static int migrate_copy_data(int fd_src, int fd_dst, int (*check_file)(int),
                llapi_layout_free(layout);
        }
 
+       /* limit transfer size to what can be sent in one second */
+       if (bandwidth_bytes_sec && bandwidth_bytes_sec < buf_size)
+               buf_size = (bandwidth_bytes_sec + stripe_size - 1) &
+                       ~(stripe_size - 1);
+
        /* Use a page-aligned buffer for direct I/O */
        rc = posix_memalign(&buf, page_size, buf_size);
        if (rc != 0)