#include <sys/param.h>
#include <err.h>
-#include <uapi/linux/lustre/lustre_idl.h>
+#include <linux/lustre/lustre_idl.h>
#include <lustre/lustreapi.h>
#define syserr(exp, str, args...) \
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;
int c;
int i;
- unsigned int ids[4096] = { 0 };
+ __u16 ids[4096] = { 0 };
size_t count = 0;
ssize_t result;
struct llapi_resync_comp comp_array[1024] = { { 0 } };
size_t comp_size = 0;
uint32_t flr_state;
+ uint64_t start;
+ uint64_t end;
opterr = 0;
while ((c = getopt(argc, argv, "e:d:")) != -1) {
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);
printf("%s: found %zd stale components\n", fname, comp_size);
- idx = 0;
- while (idx < comp_size) {
- ssize_t res;
- uint64_t end;
- uint32_t mirror_id;
- int i;
+ /* get the read range [start, end) */
+ start = comp_array[0].lrc_start;
+ end = comp_array[0].lrc_end;
+ for (idx = 1; idx < comp_size; idx++) {
+ if (comp_array[idx].lrc_start < start)
+ start = comp_array[idx].lrc_start;
+ if (end < comp_array[idx].lrc_end)
+ end = comp_array[idx].lrc_end;
+ }
- rc = llapi_lease_check(fd);
+ rc = llapi_lease_check(fd);
+ if (rc != LL_LEASE_WRLCK) {
+ free(ioc);
syserr(rc != LL_LEASE_WRLCK, "lost lease lock");
-
- mirror_id = comp_array[idx].lrc_mirror_id;
- end = comp_array[idx].lrc_end;
-
- printf("%s: resyncing mirror: %u, components: %u ",
- fname, mirror_id, comp_array[idx].lrc_id);
-
- for (i = idx + 1; i < comp_size; i++) {
- if (mirror_id != comp_array[i].lrc_mirror_id ||
- end != comp_array[i].lrc_start)
- break;
-
- printf("%u ", comp_array[i].lrc_id);
- end = comp_array[i].lrc_end;
- }
- printf("\b\n");
-
- res = llapi_mirror_resync_one(fd, layout, mirror_id,
- comp_array[idx].lrc_start, end);
- if (res > 0) {
- int j;
-
- printf("components synced: ");
- for (j = idx; j < i; j++) {
- comp_array[j].lrc_synced = true;
- printf("%u ", comp_array[j].lrc_id);
- }
- printf("\n");
- }
-
- if (res < 0)
- free(ioc);
- syserrx(res < 0, "llapi_mirror_copy_many");
-
- idx = i;
}
+ rc = llapi_mirror_resync_many(fd, layout, comp_array, comp_size, start,
+ end);
+ if (rc < 0)
+ free(ioc);
+ syserrx(rc < 0, "llapi_mirror_resync_many");
+
/* prepare ioc for lease put */
ioc->lil_mode = LL_LEASE_UNLCK;
ioc->lil_flags = LL_LEASE_RESYNC_DONE;
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");
+ if (rc <= 0)
+ llapi_lease_release(fd);
free(ioc);
close(fd);