From eed4ac18c2f99a03dd7149712cacc3447282425b Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Fri, 4 Sep 2009 14:58:18 +0200 Subject: [PATCH] btape: Add speed command and test drive speed with Bacula blocks --- bacula/src/stored/btape.c | 166 +++++++++++++++++++++++++++++++++++--- bacula/technotes | 2 + 2 files changed, 157 insertions(+), 11 deletions(-) diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index 1da025c8fa..2d06baadb3 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -933,6 +933,75 @@ static bool speed_test_raw(fill_mode_t mode, uint64_t nb_gb, uint32_t nb) } +static bool speed_test_bacula(fill_mode_t mode, uint64_t nb_gb, uint32_t nb) +{ + DEV_BLOCK *block = dcr->block; + char ed1[200]; + DEV_RECORD *rec; + uint64_t last_bytes = dev->VolCatInfo.VolCatBytes; + uint64_t written=0; + + nb_gb *= 1024*1024*1024; /* convert size from nb to GB */ + + init_total_speed(); + + empty_block(block); + rec = new_record(); + rec->data = check_pool_memory_size(rec->data, block->buf_len); + rec->data_len = block->buf_len-100; + + fill_buffer(mode, rec->data, rec->data_len); + + Pmsg3(0, _("Begin writing %i files of %sB with blocks of %u bytes.\n"), + nb, edit_uint64_with_suffix(nb_gb, ed1), block->buf_len); + + for (uint32_t j=0; jBlockNumber % 500) == 0) { + printf("+"); + fflush(stdout); + } + written += dev->VolCatInfo.VolCatBytes - last_bytes; + last_bytes = dev->VolCatInfo.VolCatBytes; + mix_buffer(mode, rec->data, rec->data_len); + } + printf("\n"); + weofcmd(); + print_speed(written); + } + print_total_speed(); + printf("\n"); + free_record(rec); + return true; + +bail_out: + free_record(rec); + return false; +} + +/* TODO: use UAContext */ +static int btape_find_arg(const char *keyword) +{ + for (int i=1; irewind(dcr); - Pmsg0(0, _("Test with zero data, should give the maximum throughput.\n")); - ok(speed_test_raw(FILL_ZERO, 1, 3)); - ok(speed_test_raw(FILL_ZERO, 2, 3)); - ok(speed_test_raw(FILL_ZERO, 4, 3)); - - Pmsg0(0, _("Test with random data, should give the minimum throughput.\n")); - ok(speed_test_raw(FILL_RANDOM, 1, 3)); - ok(speed_test_raw(FILL_RANDOM, 2, 3)); - ok(speed_test_raw(FILL_RANDOM, 4, 3)); + bool do_zero=true, do_random=true, do_block=true, do_raw=true; + uint32_t file_size=0, nb_file=3; + int32_t i; + + i = btape_find_arg("file_size"); + if (i > 0) { + file_size = atoi(argv[i]); + if (file_size > 100) { + Pmsg0(0, _("The file_size is too big, stop this test with Ctrl-c.\n")); + } + } + + i = btape_find_arg("nb_file"); + if (i > 0) { + nb_file = atoi(argv[i]); + } + + if (btape_find_arg("skip_zero") > 0) { + do_zero = false; + } + + if (btape_find_arg("skip_random") > 0) { + do_random = false; + } + + if (btape_find_arg("skip_raw") > 0) { + do_raw = false; + } + + if (btape_find_arg("skip_block") > 0) { + do_block = false; + } + + if (do_raw) { + dev->rewind(dcr); + if (do_zero) { + Pmsg0(0, _("Test with zero data, should give the " + "maximum throughput.\n")); + if (file_size) { + ok(speed_test_raw(FILL_ZERO, file_size, nb_file)); + } else { + ok(speed_test_raw(FILL_ZERO, 1, nb_file)); + ok(speed_test_raw(FILL_ZERO, 2, nb_file)); + ok(speed_test_raw(FILL_ZERO, 4, nb_file)); + } + } + + if (do_random) { + Pmsg0(0, _("Test with random data, should give the minimum " + "throughput.\n")); + if (file_size) { + ok(speed_test_raw(FILL_RANDOM, file_size, nb_file)); + } else { + ok(speed_test_raw(FILL_RANDOM, 1, nb_file)); + ok(speed_test_raw(FILL_RANDOM, 2, nb_file)); + ok(speed_test_raw(FILL_RANDOM, 4, nb_file)); + } + } + } + + if (do_block) { + dev->rewind(dcr); + if (do_zero) { + Pmsg0(0, _("Test with zero data and bacula block structure.\n")); + if (file_size) { + ok(speed_test_bacula(FILL_ZERO, file_size, nb_file)); + } else { + ok(speed_test_bacula(FILL_ZERO, 1, nb_file)); + ok(speed_test_bacula(FILL_ZERO, 2, nb_file)); + ok(speed_test_bacula(FILL_ZERO, 4, nb_file)); + } + } + + if (do_random) { + Pmsg0(0, _("Test with random data, should give the minimum " + "throughput.\n")); + if (file_size) { + ok(speed_test_bacula(FILL_RANDOM, file_size, nb_file)); + } else { + ok(speed_test_bacula(FILL_RANDOM, 1, nb_file)); + ok(speed_test_bacula(FILL_RANDOM, 2, nb_file)); + ok(speed_test_bacula(FILL_RANDOM, 4, nb_file)); + } + } + } } const int num_recs = 10000; @@ -2743,7 +2887,7 @@ static struct cmdstruct commands[] = { {NT_("rewind"), rewindcmd, _("rewind the tape")}, {NT_("scan"), scancmd, _("read() tape block by block to EOT and report")}, {NT_("scanblocks"),scan_blocks, _("Bacula read block by block to EOT and report")}, - {NT_("speed"), speed_test, _("try different configuration and report drive speed")}, + {NT_("speed"), speed_test, _("[file_size=n(GB)|nb_file=3|skip_zero|skip_random|skip_raw|skip_block] report drive speed")}, {NT_("status"), statcmd, _("print tape status")}, {NT_("test"), testcmd, _("General test Bacula tape functions")}, {NT_("weof"), weofcmd, _("write an EOF on the tape")}, diff --git a/bacula/technotes b/bacula/technotes index fc0fe514cc..33bdee270a 100644 --- a/bacula/technotes +++ b/bacula/technotes @@ -2,6 +2,8 @@ General: +04Sep09 +ebl btape: Add speed command and test drive speed with Bacula blocks 03Sep09 ebl Use MaxFileSize device configuration in btape ebl Make less tweaks in random buffer in btape -- 2.39.5