X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fmirror_io.c;h=ab39f6953f3979150f7ed70083144dc2d2277320;hb=32989af838f8b5fa161014db732cd31934aa921a;hp=bf486990b60eb48b1d9bfc1d7459d8e871d19678;hpb=79da3738df220b2ea055098aaa3aaba59934616e;p=fs%2Flustre-release.git diff --git a/lustre/tests/mirror_io.c b/lustre/tests/mirror_io.c index bf48699..ab39f69 100644 --- a/lustre/tests/mirror_io.c +++ b/lustre/tests/mirror_io.c @@ -204,7 +204,7 @@ static void mirror_dump(int argc, char *argv[]) free(buf); } -static size_t add_tids(unsigned int *ids, size_t count, char *arg) +static size_t add_tids(__u16 *ids, size_t count, char *arg) { while (*arg) { char *end; @@ -240,7 +240,7 @@ static void mirror_copy(int argc, char *argv[]) int c; int i; - unsigned int ids[4096] = { 0 }; + __u16 ids[4096] = { 0 }; size_t count = 0; ssize_t result; @@ -359,6 +359,48 @@ static enum resync_errors resync_parse_error(const char *err) return -1; } +ssize_t mirror_resync_one(int fd, struct llapi_layout *layout, + uint32_t dst, uint64_t start, uint64_t end) +{ + uint64_t mirror_end = 0; + ssize_t result = 0; + uint64_t count; + + if (end == OBD_OBJECT_EOF) + count = OBD_OBJECT_EOF; + else + count = end - start; + + while (count > 0) { + uint32_t src; + uint64_t to_copy; + ssize_t copied; + + src = llapi_mirror_find(layout, start, end, &mirror_end); + if (src == 0) + return -ENOENT; + + if (mirror_end == OBD_OBJECT_EOF) + to_copy = count; + else + to_copy = MIN(count, mirror_end - start); + + copied = llapi_mirror_copy(fd, src, dst, start, to_copy); + if (copied < 0) + return copied; + + result += copied; + if (copied < to_copy) /* end of file */ + break; + + if (count != OBD_OBJECT_EOF) + count -= copied; + start += copied; + } + + return result; +} + static void mirror_resync(int argc, char *argv[]) { const char *fname; @@ -403,10 +445,10 @@ static void mirror_resync(int argc, char *argv[]) ioc->lil_mode = LL_LEASE_WRLCK; ioc->lil_flags = LL_LEASE_RESYNC; - rc = llapi_lease_get_ext(fd, ioc); + rc = llapi_lease_set(fd, ioc); if (rc < 0) free(ioc); - syserr(rc < 0, "llapi_lease_get_ext resync"); + syserr(rc < 0, "llapi_lease_set resync"); if (error_inject & AFTER_RESYNC_START) { free(ioc); @@ -464,8 +506,8 @@ static void mirror_resync(int argc, char *argv[]) } printf("\b\n"); - res = llapi_mirror_resync_one(fd, layout, mirror_id, - comp_array[idx].lrc_start, end); + res = mirror_resync_one(fd, layout, mirror_id, + comp_array[idx].lrc_start, end); if (res > 0) { int j; @@ -506,8 +548,8 @@ static void mirror_resync(int argc, char *argv[]) if (error_inject & OPEN_TEST_FILE) /* break lease */ close(open(argv[optind], O_RDONLY)); - rc = llapi_lease_get_ext(fd, ioc); - syserr(rc <= 0, "llapi_lease_get_ext resync failed"); + rc = llapi_lease_set(fd, ioc); + syserr(rc <= 0, "llapi_lease_set resync failed"); free(ioc); close(fd);