X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fllapi_hsm_test.c;h=2d4ab13ca69a6b8b3ecbaf61050ce3ef2285f57a;hb=a50eaae974ee04364c9fbbb4625dd3d581a8c986;hp=0ea66528fcbd4eacde2259660c341db1af9d8fd6;hpb=0754bc8f2623bea184111af216f7567608db35b6;p=fs%2Flustre-release.git diff --git a/lustre/tests/llapi_hsm_test.c b/lustre/tests/llapi_hsm_test.c index 0ea6652..2d4ab13 100644 --- a/lustre/tests/llapi_hsm_test.c +++ b/lustre/tests/llapi_hsm_test.c @@ -29,7 +29,7 @@ /* The purpose of this test is to check some HSM functions. HSM must * be enabled before running it: - * echo enabled > /proc/fs/lustre/mdt/lustre-MDT0000/hsm_control + * lctl set_param mdt.$FSNAME-MDT0000.hsm_control=enabled */ /* All tests return 0 on success and non zero on error. The program will @@ -47,6 +47,7 @@ static char fsmountdir[PATH_MAX]; /* Lustre mountpoint */ static char *lustre_dir; /* Test directory inside Lustre */ +static bool is_bitmap; #define ERROR(fmt, ...) \ fprintf(stderr, "%s: %s:%d: %s: " fmt "\n", \ @@ -131,19 +132,26 @@ int test3(void) int rc; struct hsm_copytool_private *ctdata; int archives[33]; + int count = sizeof(archives) / sizeof(*archives); rc = llapi_hsm_copytool_register(&ctdata, fsmountdir, 1, NULL, 0); ASSERTF(rc == -EINVAL, "llapi_hsm_copytool_register error: %s", strerror(-rc)); - rc = llapi_hsm_copytool_register(&ctdata, fsmountdir, 33, NULL, 0); + rc = llapi_hsm_copytool_register(&ctdata, fsmountdir, count, NULL, 0); ASSERTF(rc == -EINVAL, "llapi_hsm_copytool_register error: %s", strerror(-rc)); - memset(archives, 1, sizeof(archives)); - rc = llapi_hsm_copytool_register(&ctdata, fsmountdir, 34, archives, 0); - ASSERTF(rc == -EINVAL, "llapi_hsm_copytool_register error: %s", - strerror(-rc)); + if (is_bitmap) { + int i; + + for (i = 0; i < count; i++) + archives[i] = i + 1; + rc = llapi_hsm_copytool_register(&ctdata, fsmountdir, + count, archives, 0); + ASSERTF(rc == -EINVAL, "llapi_hsm_copytool_register error: %s", + strerror(-rc)); + } #if 0 /* BUG? Should that fail or not? */ @@ -193,7 +201,7 @@ int test5(void) /* Hopefully there is nothing lingering */ for (i = 0; i < 1000; i++) { rc = llapi_hsm_copytool_recv(ctdata, &hal, &msgsize); - ASSERTF(rc == -EWOULDBLOCK, "llapi_hsm_copytool_recv error: %s", + ASSERTF(rc == -EAGAIN, "llapi_hsm_copytool_recv error: %s", strerror(-rc)); } @@ -264,7 +272,7 @@ int test7(void) rc, strerror(errno)); rc = llapi_hsm_copytool_recv(ctdata, &hal, &msgsize); - ASSERTF(rc == -EWOULDBLOCK, "llapi_hsm_copytool_recv error: %s", + ASSERTF(rc == -EAGAIN, "llapi_hsm_copytool_recv error: %s", strerror(-rc)); fds[0].fd = fd; @@ -355,6 +363,7 @@ void test51(void) int rc; int fd; int i; + int test_count; struct hsm_user_state hus; fd = create_testfile(100); @@ -363,13 +372,17 @@ void test51(void) ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); /* Set archive id */ - for (i = 0; i <= 32; i++) { + if (is_bitmap) + test_count = 32; + else + test_count = 48; + for (i = 0; i <= test_count; i++) { rc = llapi_hsm_state_set_fd(fd, HS_EXISTS, 0, i); ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); rc = llapi_hsm_state_get_fd(fd, &hus); - ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", + ASSERTF(rc == 0, "llapi_hsm_state_get_fd failed: %s", strerror(-rc)); ASSERTF(hus.hus_states == HS_EXISTS, "state=%u", hus.hus_states); @@ -377,15 +390,20 @@ void test51(void) hus.hus_archive_id, i); } - /* Invalid archive numbers */ - rc = llapi_hsm_state_set_fd(fd, HS_EXISTS, 0, 33); - ASSERTF(rc == -EINVAL, "llapi_hsm_state_set_fd: %s", strerror(-rc)); + if (is_bitmap) { + /* Invalid archive numbers */ + rc = llapi_hsm_state_set_fd(fd, HS_EXISTS, 0, 33); + ASSERTF(rc == -EINVAL, "llapi_hsm_state_set_fd: %s", + strerror(-rc)); - rc = llapi_hsm_state_set_fd(fd, HS_EXISTS, 0, 151); - ASSERTF(rc == -EINVAL, "llapi_hsm_state_set_fd: %s", strerror(-rc)); + rc = llapi_hsm_state_set_fd(fd, HS_EXISTS, 0, 151); + ASSERTF(rc == -EINVAL, "llapi_hsm_state_set_fd: %s", + strerror(-rc)); - rc = llapi_hsm_state_set_fd(fd, HS_EXISTS, 0, -1789); - ASSERTF(rc == -EINVAL, "llapi_hsm_state_set_fd: %s", strerror(-rc)); + rc = llapi_hsm_state_set_fd(fd, HS_EXISTS, 0, -1789); + ASSERTF(rc == -EINVAL, "llapi_hsm_state_set_fd: %s", + strerror(-rc)); + } /* Settable flags, with respect of the HSM file state transition rules: * DIRTY without EXISTS: no dirty if no archive was created @@ -522,6 +540,7 @@ void helper_archiving(void (*progress) hur->hur_request.hr_flags = 0; hur->hur_request.hr_itemcount = 1; hur->hur_request.hr_data_len = 0; + hur->hur_user_item[0].hui_extent.offset = 0; hur->hur_user_item[0].hui_extent.length = -1; rc = llapi_fd2fid(fd, &hur->hur_user_item[0].hui_fid); @@ -1002,6 +1021,41 @@ void test112(void) helper_archiving(test112_progress, length); } +/* Archive, with 9 reports, each covering 20%, so many overlap. */ +static void test113_progress(struct hsm_copyaction_private *hcp, size_t length) +{ + int rc; + int i; + struct hsm_extent he; + struct hsm_current_action hca; + + for (i = 0; i < 9; i++) { + he.offset = i*length/10; + he.length = 2*length/10; + rc = llapi_hsm_action_progress(hcp, &he, length, 0); + ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s", + strerror(-rc)); + + rc = llapi_hsm_current_action(testfile, &hca); + ASSERTF(rc == 0, "llapi_hsm_current_action failed: %s", + strerror(-rc)); + ASSERTF(hca.hca_state == HPS_RUNNING, + "hca_state=%u", hca.hca_state); + ASSERTF(hca.hca_action == HUA_ARCHIVE, + "hca_state=%u", hca.hca_action); + ASSERTF(hca.hca_location.length == (i+2)*length/10, + "i=%d, length=%llu", + i, (unsigned long long)hca.hca_location.length); + } +} + +void test113(void) +{ + const size_t length = 1000; + + helper_archiving(test113_progress, length); +} + static void usage(char *prog) { fprintf(stderr, "Usage: %s [-d lustre_dir]\n", prog); @@ -1012,11 +1066,14 @@ static void process_args(int argc, char *argv[]) { int c; - while ((c = getopt(argc, argv, "d:")) != -1) { + while ((c = getopt(argc, argv, "bd:")) != -1) { switch (c) { case 'd': lustre_dir = optarg; break; + case 'b': + is_bitmap = true; + break; case '?': default: fprintf(stderr, "Unknown option '%c'\n", optopt); @@ -1069,6 +1126,7 @@ int main(int argc, char *argv[]) PERFORM(test110); PERFORM(test111); PERFORM(test112); + PERFORM(test113); return EXIT_SUCCESS; }