X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fllapi_hsm_test.c;h=01a701c98afb2cc2750d40f1a1e69d6c41e49bdc;hb=48830f888b651c32bfe4742f3d03fd04b15638a9;hp=e21b4b7889a87a8d981714d217f184bd40b5869b;hpb=1fe3ae8dab47941e465dcc47ffa52e18538aeb1e;p=fs%2Flustre-release.git diff --git a/lustre/tests/llapi_hsm_test.c b/lustre/tests/llapi_hsm_test.c index e21b4b7..01a701c 100644 --- a/lustre/tests/llapi_hsm_test.c +++ b/lustre/tests/llapi_hsm_test.c @@ -20,12 +20,16 @@ * GPL HEADER END */ -/* Copyright 2014 Cray Inc, all rights reserved. */ +/* + * Copyright 2014, 2015 Cray Inc, all rights reserved. + * + * Copyright (c) 2015, Intel Corporation. + */ /* Some portions are extracted from llapi_layout_test.c */ /* 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 @@ -43,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", \ @@ -127,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? */ @@ -351,6 +363,7 @@ void test51(void) int rc; int fd; int i; + int test_count; struct hsm_user_state hus; fd = create_testfile(100); @@ -359,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); @@ -373,31 +390,51 @@ void test51(void) hus.hus_archive_id, i); } - /* Bugs following. This should not succeed. Builds the following file: - * - * $ ../utils/lfs hsm_state /mnt/lustre/hsm_check_test - * - * /mnt/lustre/hsm_check_test: (0x8008007d) released exists - * archived never_release never_archive lost_from_hsm, - * archive_id:-1789 - */ + 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)); - /* Invalid archive numbers */ - rc = llapi_hsm_state_set_fd(fd, HS_EXISTS, 0, 33); + 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 + * DIRTY and RELEASED: a dirty file could not be released + * RELEASED without ARCHIVED: do not release a non-archived file + * LOST without ARCHIVED: cannot lost a non-archived file. + */ + rc = llapi_hsm_state_set_fd(fd, HS_DIRTY, 0, 0); ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); - rc = llapi_hsm_state_set_fd(fd, HS_EXISTS, 0, 151); + rc = llapi_hsm_state_set_fd(fd, 0, HS_EXISTS, 0); + ASSERTF(rc == -EINVAL, "llapi_hsm_state_set_fd failed: %s", + strerror(-rc)); + + rc = llapi_hsm_state_set_fd(fd, 0, HS_DIRTY, 0); ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); - rc = llapi_hsm_state_set_fd(fd, HS_EXISTS, 0, -1789); + rc = llapi_hsm_state_set_fd(fd, 0, HS_EXISTS, 0); ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); - /* Setable + Unsettable flags */ rc = llapi_hsm_state_set_fd(fd, HS_DIRTY, 0, 0); - ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); + ASSERTF(rc == -EINVAL, "llapi_hsm_state_set_fd failed: %s", + strerror(-rc)); - rc = llapi_hsm_state_set_fd(fd, 0, HS_DIRTY, 0); - ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); + rc = llapi_hsm_state_set_fd(fd, HS_RELEASED, 0, 0); + ASSERTF(rc == -EINVAL, "llapi_hsm_state_set_fd failed: %s", + strerror(-rc)); + + rc = llapi_hsm_state_set_fd(fd, HS_LOST, 0, 0); + ASSERTF(rc == -EINVAL, "llapi_hsm_state_set_fd failed: %s", + strerror(-rc)); rc = llapi_hsm_state_set_fd(fd, HS_ARCHIVED, 0, 0); ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); @@ -405,21 +442,47 @@ void test51(void) rc = llapi_hsm_state_set_fd(fd, HS_RELEASED, 0, 0); ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); + rc = llapi_hsm_state_set_fd(fd, HS_LOST, 0, 0); + ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); + + rc = llapi_hsm_state_set_fd(fd, HS_DIRTY|HS_EXISTS, 0, 0); + ASSERTF(rc == -EINVAL, "llapi_hsm_state_set_fd failed: %s", + strerror(-rc)); + + rc = llapi_hsm_state_set_fd(fd, 0, HS_RELEASED, 0); + ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); + + rc = llapi_hsm_state_set_fd(fd, HS_DIRTY|HS_EXISTS, 0, 0); + ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); + + rc = llapi_hsm_state_set_fd(fd, 0, HS_ARCHIVED, 0); + ASSERTF(rc == -EINVAL, "llapi_hsm_state_set_fd failed: %s", + strerror(-rc)); + + rc = llapi_hsm_state_set_fd(fd, 0, HS_LOST, 0); + ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); + + rc = llapi_hsm_state_set_fd(fd, 0, HS_ARCHIVED, 0); + ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); + rc = llapi_hsm_state_set_fd(fd, HS_NORELEASE, 0, 0); ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); + rc = llapi_hsm_state_set_fd(fd, 0, HS_NORELEASE, 0); + ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); + rc = llapi_hsm_state_set_fd(fd, HS_NOARCHIVE, 0, 0); ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); - rc = llapi_hsm_state_set_fd(fd, HS_LOST, 0, 0); + rc = llapi_hsm_state_set_fd(fd, 0, HS_NOARCHIVE, 0); ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); /* Bogus flags for good measure. */ rc = llapi_hsm_state_set_fd(fd, 0x00080000, 0, 0); - ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); + ASSERTF(rc == -EINVAL, "llapi_hsm_state_set_fd: %s", strerror(-rc)); rc = llapi_hsm_state_set_fd(fd, 0x80000000, 0, 0); - ASSERTF(rc == 0, "llapi_hsm_state_set_fd failed: %s", strerror(-rc)); + ASSERTF(rc == -EINVAL, "llapi_hsm_state_set_fd: %s", strerror(-rc)); close(fd); } @@ -447,8 +510,9 @@ void test52(void) /* Helper to simulate archiving a file. No actual data movement * happens. */ -void (*helper_progress)(struct hsm_copyaction_private *hcp); -void helper_archiving(const size_t length) +void helper_archiving(void (*progress) + (struct hsm_copyaction_private *hcp, size_t length), + const size_t length) { int rc; int fd; @@ -476,6 +540,7 @@ void helper_archiving(const size_t length) 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); @@ -504,8 +569,8 @@ void helper_archiving(const size_t length) ASSERTF(rc == 0, "llapi_hsm_action_begin failed: %s", strerror(-rc)); ASSERTF(hcp != NULL, "hcp is NULL"); - if (helper_progress) - helper_progress(hcp); + if (progress) + progress(hcp, length); /* Done archiving */ rc = llapi_hsm_action_end(&hcp, &hai->hai_extent, 0, 0); @@ -528,200 +593,320 @@ void helper_archiving(const size_t length) void test100(void) { const size_t length = 100; - helper_progress = NULL; - helper_archiving(length); + + helper_archiving(NULL, length); } /* Archive, with a report every byte. */ +static void test101_progress(struct hsm_copyaction_private *hcp, size_t length) +{ + int i; + int rc; + struct hsm_extent he; + struct hsm_current_action hca; + + /* Report progress. 1 byte at a time :) */ + for (i = 0; i < length; i++) { + he.offset = i; + he.length = 1; + 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 == length, + "length=%llu", (unsigned long long)hca.hca_location.length); +} + void test101(void) { const size_t length = 1000; - void test101_progress(struct hsm_copyaction_private *hcp) - { - int i; - int rc; - struct hsm_extent he; - struct hsm_current_action hca; - - /* Report progress. 1 byte at a time :) */ - for (i = 0; i < length; i++) { - he.offset = i; - he.length = 1; - rc = llapi_hsm_action_progress(hcp, &he, length, 0); - ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s", - strerror(-rc)); - } + helper_archiving(test101_progress, length); +} - rc = llapi_hsm_current_action(testfile, &hca); - ASSERTF(rc == 0, "llapi_hsm_current_action failed: %s", +/* Archive, with a report every byte, backwards. */ +static void test102_progress(struct hsm_copyaction_private *hcp, size_t length) +{ + int i; + int rc; + struct hsm_extent he; + struct hsm_current_action hca; + + /* Report progress. 1 byte at a time :) */ + for (i = length-1; i >= 0; i--) { + he.offset = i; + he.length = 1; + rc = llapi_hsm_action_progress(hcp, &he, length, 0); + ASSERTF(rc == 0, "llapi_hsm_action_progress 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 == length, - "length=%llu", hca.hca_location.length); } - helper_progress = test101_progress; - helper_archiving(length); + 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 == length, + "length=%llu", (unsigned long long)hca.hca_location.length); } -/* Archive, with a report every byte, backwards. */ void test102(void) { const size_t length = 1000; - void test102_progress(struct hsm_copyaction_private *hcp) - { - int i; - int rc; - struct hsm_extent he; - struct hsm_current_action hca; - - /* Report progress. 1 byte at a time :) */ - for (i = length-1; i >= 0; i--) { - he.offset = i; - he.length = 1; - rc = llapi_hsm_action_progress(hcp, &he, length, 0); - ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s", - strerror(-rc)); - } + helper_archiving(test102_progress, length); +} - 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 == length, - "length=%llu", hca.hca_location.length); - } +/* Archive, with a single report. */ +static void test103_progress(struct hsm_copyaction_private *hcp, size_t length) +{ + int rc; + struct hsm_extent he; + struct hsm_current_action hca; - helper_progress = test102_progress; - helper_archiving(length); + he.offset = 0; + he.length = length; + 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 == length, + "length=%llu", (unsigned long long)hca.hca_location.length); } -/* Archive, with a single report. */ void test103(void) { const size_t length = 1000; - void test103_progress(struct hsm_copyaction_private *hcp) - { - int rc; - struct hsm_extent he; - struct hsm_current_action hca; + helper_archiving(test103_progress, length); +} - he.offset = 0; - he.length = length; - rc = llapi_hsm_action_progress(hcp, &he, length, 0); - ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s", - strerror(-rc)); +/* Archive, with 2 reports. */ +static void test104_progress(struct hsm_copyaction_private *hcp, size_t length) +{ + int rc; + struct hsm_extent he; + struct hsm_current_action hca; - 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 == length, - "length=%llu", hca.hca_location.length); - } + he.offset = 0; + he.length = length/2; + rc = llapi_hsm_action_progress(hcp, &he, length, 0); + ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s", + strerror(-rc)); + + he.offset = length/2; + he.length = length/2; + rc = llapi_hsm_action_progress(hcp, &he, length, 0); + ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s", + strerror(-rc)); - helper_progress = test103_progress; - helper_archiving(length); + 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 == length, + "length=%llu", (unsigned long long)hca.hca_location.length); } -/* Archive, with 2 reports. */ void test104(void) { const size_t length = 1000; - void test104_progress(struct hsm_copyaction_private *hcp) - { - int rc; - struct hsm_extent he; - struct hsm_current_action hca; + helper_archiving(test104_progress, length); +} - he.offset = 0; - he.length = length/2; - rc = llapi_hsm_action_progress(hcp, &he, length, 0); - ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s", - strerror(-rc)); +/* Archive, with 1 bogus report. */ +static void test105_progress(struct hsm_copyaction_private *hcp, size_t length) +{ + int rc; + struct hsm_extent he; + struct hsm_current_action hca; - he.offset = length/2; - he.length = length/2; - rc = llapi_hsm_action_progress(hcp, &he, length, 0); - ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s", - strerror(-rc)); + he.offset = 2*length; + he.length = 10*length; + 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 == length, - "length=%llu", hca.hca_location.length); - } + 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); + + /* BUG - offset should be 2*length, or length should + * be 8*length */ + ASSERTF(hca.hca_location.length == 10*length, + "length=%llu", (unsigned long long)hca.hca_location.length); +} + +void test105(void) +{ + const size_t length = 1000; + + helper_archiving(test105_progress, length); +} + +/* Archive, with 1 empty report. */ +static void test106_progress(struct hsm_copyaction_private *hcp, size_t length) +{ + int rc; + struct hsm_extent he; + struct hsm_current_action hca; + + he.offset = 0; + he.length = 0; + rc = llapi_hsm_action_progress(hcp, &he, length, 0); + ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s", + strerror(-rc)); - helper_progress = test104_progress; - helper_archiving(length); + 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 == 0, + "length=%llu", (unsigned long long)hca.hca_location.length); +} + +void test106(void) +{ + const size_t length = 1000; + + helper_archiving(test106_progress, length); } /* Archive, with 1 bogus report. */ -void test105(void) +static void test107_progress(struct hsm_copyaction_private *hcp, size_t length) +{ + int rc; + struct hsm_extent he; + struct hsm_current_action hca; + + he.offset = -1; + he.length = 10; + rc = llapi_hsm_action_progress(hcp, &he, length, 0); + ASSERTF(rc == -EINVAL, "llapi_hsm_action_progress error: %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 == 0, + "length=%llu", (unsigned long long)hca.hca_location.length); +} + +void test107(void) { const size_t length = 1000; - void test105_progress(struct hsm_copyaction_private *hcp) - { - int rc; - struct hsm_extent he; - struct hsm_current_action hca; + helper_archiving(test107_progress, length); +} + +/* Archive, with same report, many times. */ +static void test108_progress(struct hsm_copyaction_private *hcp, size_t length) +{ + int rc; + struct hsm_extent he; + int i; + struct hsm_current_action hca; - he.offset = 2*length; - he.length = 10*length; + for (i = 0; i < 1000; i++) { + he.offset = 0; + he.length = length; 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); + 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 == length, + "length=%llu", (unsigned long long)hca.hca_location.length); +} - /* BUG - offset should be 2*length, or length should - * be 8*length */ - ASSERTF(hca.hca_location.length == 10*length, - "length=%llu", hca.hca_location.length); - } +void test108(void) +{ + const size_t length = 1000; - helper_progress = test105_progress; - helper_archiving(length); + helper_archiving(test108_progress, length); } -/* Archive, with 1 empty report. */ -void test106(void) +/* Archive, 1 report, with large number. */ +static void test109_progress(struct hsm_copyaction_private *hcp, size_t length) +{ + int rc; + struct hsm_extent he; + struct hsm_current_action hca; + + he.offset = 0; + he.length = 0xffffffffffffffffULL; + 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 == 0xffffffffffffffffULL, + "length=%llu", (unsigned long long)hca.hca_location.length); +} + +void test109(void) { const size_t length = 1000; - void test106_progress(struct hsm_copyaction_private *hcp) - { - int rc; - struct hsm_extent he; - struct hsm_current_action hca; + helper_archiving(test109_progress, length); +} - he.offset = 0; - he.length = 0; +/* Archive, with 10 reports, checking progress. */ +static void test110_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 < 10; i++) { + he.offset = i*length/10; + he.length = length/10; rc = llapi_hsm_action_progress(hcp, &he, length, 0); ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s", strerror(-rc)); @@ -733,29 +918,32 @@ void test106(void) "hca_state=%u", hca.hca_state); ASSERTF(hca.hca_action == HUA_ARCHIVE, "hca_state=%u", hca.hca_action); - ASSERTF(hca.hca_location.length == 0, - "length=%llu", hca.hca_location.length); + ASSERTF(hca.hca_location.length == (i+1)*length/10, + "i=%d, length=%llu", + i, (unsigned long long)hca.hca_location.length); } - - helper_progress = test106_progress; - helper_archiving(length); } -/* Archive, with 1 bogus report. */ -void test107(void) +void test110(void) { const size_t length = 1000; - void test107_progress(struct hsm_copyaction_private *hcp) - { - int rc; - struct hsm_extent he; - struct hsm_current_action hca; + helper_archiving(test110_progress, length); +} + +/* Archive, with 10 reports in reverse order, checking progress. */ +static void test111_progress(struct hsm_copyaction_private *hcp, size_t length) +{ + int rc; + int i; + struct hsm_extent he; + struct hsm_current_action hca; - he.offset = -1; - he.length = 10; + for (i = 0; i < 10; i++) { + he.offset = (9-i)*length/10; + he.length = length/10; rc = llapi_hsm_action_progress(hcp, &he, length, 0); - ASSERTF(rc == -EINVAL, "llapi_hsm_action_progress error: %s", + ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s", strerror(-rc)); rc = llapi_hsm_current_action(testfile, &hca); @@ -765,33 +953,34 @@ void test107(void) "hca_state=%u", hca.hca_state); ASSERTF(hca.hca_action == HUA_ARCHIVE, "hca_state=%u", hca.hca_action); - ASSERTF(hca.hca_location.length == 0, - "length=%llu", hca.hca_location.length); + ASSERTF(hca.hca_location.length == (i+1)*length/10, + "i=%d, length=%llu", + i, (unsigned long long)hca.hca_location.length); } - - helper_progress = test107_progress; - helper_archiving(length); } -/* Archive, with same report, many times. */ -void test108(void) +void test111(void) { const size_t length = 1000; - void test108_progress(struct hsm_copyaction_private *hcp) - { - int rc; - struct hsm_extent he; - int i; - struct hsm_current_action hca; - - for (i = 0; i < 1000; i++) { - he.offset = 0; - he.length = length; - rc = llapi_hsm_action_progress(hcp, &he, length, 0); - ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s", - strerror(-rc)); - } + helper_archiving(test111_progress, length); +} + +/* Archive, with 10 reports, and duplicating them, checking + * progress. */ +static void test112_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 < 10; i++) { + he.offset = i*length/10; + he.length = 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", @@ -800,27 +989,14 @@ void test108(void) "hca_state=%u", hca.hca_state); ASSERTF(hca.hca_action == HUA_ARCHIVE, "hca_state=%u", hca.hca_action); - ASSERTF(hca.hca_location.length == length, - "length=%llu", hca.hca_location.length); + ASSERTF(hca.hca_location.length == (i+1)*length/10, + "i=%d, length=%llu", + i, (unsigned long long)hca.hca_location.length); } - helper_progress = test108_progress; - helper_archiving(length); -} - -/* Archive, 1 report, with large number. */ -void test109(void) -{ - const size_t length = 1000; - - void test109_progress(struct hsm_copyaction_private *hcp) - { - int rc; - struct hsm_extent he; - struct hsm_current_action hca; - - he.offset = 0; - he.length = 0xffffffffffffffffULL; + for (i = 0; i < 10; i++) { + he.offset = i*length/10; + he.length = length/10; rc = llapi_hsm_action_progress(hcp, &he, length, 0); ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s", strerror(-rc)); @@ -832,141 +1008,17 @@ void test109(void) "hca_state=%u", hca.hca_state); ASSERTF(hca.hca_action == HUA_ARCHIVE, "hca_state=%u", hca.hca_action); - ASSERTF(hca.hca_location.length == 0xffffffffffffffffULL, - "length=%llu", hca.hca_location.length); - } - - helper_progress = test109_progress; - helper_archiving(length); -} - -/* Archive, with 10 reports, checking progress. */ -void test110(void) -{ - const size_t length = 1000; - - void test110_progress(struct hsm_copyaction_private *hcp) - { - int rc; - int i; - struct hsm_extent he; - struct hsm_current_action hca; - - for (i = 0; i < 10; i++) { - he.offset = i*length/10; - he.length = 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+1)*length/10, - "i=%d, length=%llu", - i, hca.hca_location.length); - } - } - - helper_progress = test110_progress; - helper_archiving(length); -} - -/* Archive, with 10 reports in reverse order, checking progress. */ -void test111(void) -{ - const size_t length = 1000; - - void test111_progress(struct hsm_copyaction_private *hcp) - { - int rc; - int i; - struct hsm_extent he; - struct hsm_current_action hca; - - for (i = 0; i < 10; i++) { - he.offset = (9-i)*length/10; - he.length = 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+1)*length/10, - "i=%d, length=%llu", - i, hca.hca_location.length); - } + ASSERTF(hca.hca_location.length == length, + "i=%d, length=%llu", + i, (unsigned long long)hca.hca_location.length); } - - helper_progress = test111_progress; - helper_archiving(length); } -/* Archive, with 10 reports, and duplicating them, checking - * progress. */ void test112(void) { const size_t length = 1000; - void test112_progress(struct hsm_copyaction_private *hcp) - { - int rc; - int i; - struct hsm_extent he; - struct hsm_current_action hca; - - for (i = 0; i < 10; i++) { - he.offset = i*length/10; - he.length = 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+1)*length/10, - "i=%d, length=%llu", - i, hca.hca_location.length); - } - - for (i = 0; i < 10; i++) { - he.offset = i*length/10; - he.length = 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 == length, - "i=%d, length=%llu", - i, hca.hca_location.length); - } - - } - - helper_progress = test112_progress; - helper_archiving(length); + helper_archiving(test112_progress, length); } static void usage(char *prog) @@ -979,11 +1031,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); @@ -995,7 +1050,7 @@ static void process_args(int argc, char *argv[]) int main(int argc, char *argv[]) { - char fsname[8]; + char fsname[8 + 1]; int rc; process_args(argc, argv);