From 55af47c47c3c0c7bc17266968f5e0e782189e819 Mon Sep 17 00:00:00 2001 From: Mike McGreevy Date: Thu, 12 Jun 2008 12:10:17 -0500 Subject: [svn-r15207] Purpose: Adding a quick fix to put the end of address (EOA) value into journal entries to be used by the recovery tool. This value is only really neded once per transaction, and only when the EOA changes, so rather than putting it into each journal entry, this should be moved into its own transaction type. However, in order to speed testing along, this quick fix has been implemented for the time being. Modified h5recover tool to use eoa value as well as journaling tests accordingly. Tested: kagiso --- src/H5C2journal.c | 16 ++++++++++++---- src/H5C2private.h | 1 + test/cache2_journal.c | 35 +++++++++++++++++++++++----------- tools/h5recover/h5recover.c | 46 +++++++++++++++++++++++++++++++++++++-------- 4 files changed, 75 insertions(+), 23 deletions(-) diff --git a/src/H5C2journal.c b/src/H5C2journal.c index 7b0bfa1..a481e4d 100644 --- a/src/H5C2journal.c +++ b/src/H5C2journal.c @@ -871,7 +871,8 @@ H5C2_journal_transaction(H5F_t * f, size_t new_len; void * new_image_ptr; void * thing; - herr_t result; + herr_t result; + haddr_t eoa; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5C2_journal_transaction, FAIL) @@ -1055,9 +1056,14 @@ H5C2_journal_transaction(H5F_t * f, * the journal entry, & remove from the transaction list. */ if ( ( ! resized ) && ( ! renamed ) ) { - + + if(HADDR_UNDEF==(eoa = H5FDget_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, \ + "file get eoa request failed") + result = H5C2_jb__journal_entry(&(cache_ptr->mdj_jbrb), cache_ptr->trans_num, + eoa, entry_ptr->addr, entry_ptr->size, entry_ptr->image_ptr); @@ -2881,6 +2887,7 @@ done: herr_t H5C2_jb__journal_entry(H5C2_jbrb_t * struct_ptr, uint64_t trans_num, + haddr_t eoa, haddr_t base_addr, size_t length, const uint8_t * body) @@ -2925,10 +2932,11 @@ H5C2_jb__journal_entry(H5C2_jbrb_t * struct_ptr, /* Write journal entry */ HDsnprintf(temp, (size_t)(length + 100), - "2 trans_num %llu length %zu base_addr 0x%lx body ", + "2 trans_num %llu eoa 0x%lx length %zu base_addr 0x%lx body ", trans_num, + (unsigned long)eoa, length, - (unsigned long)base_addr); /* <== fix this */ + (unsigned long)base_addr); if ( H5C2_jb__write_to_buffer(struct_ptr, HDstrlen(temp), temp, FALSE, trans_num) < 0 ) { diff --git a/src/H5C2private.h b/src/H5C2private.h index 20111df..d397548 100644 --- a/src/H5C2private.h +++ b/src/H5C2private.h @@ -1544,6 +1544,7 @@ H5_DLL herr_t H5C2_jb__start_transaction(H5C2_jbrb_t * struct_ptr, H5_DLL herr_t H5C2_jb__journal_entry(H5C2_jbrb_t * struct_ptr, uint64_t trans_num, + haddr_t eoa, haddr_t base_addr, size_t length, const uint8_t * body); diff --git a/test/cache2_journal.c b/test/cache2_journal.c index 267c07d..da66f3e 100644 --- a/test/cache2_journal.c +++ b/test/cache2_journal.c @@ -5606,6 +5606,7 @@ check_message_format(void) if ( H5C2_jb__journal_entry(/* H5C2_jbrb_t */ &jbrb_struct, /* trans number */ (uint64_t)1, + /* eoa */ (haddr_t)1, /* base address */ (haddr_t)0, /* data length */ 1, /* data */ (const uint8_t *)"A") @@ -5627,6 +5628,7 @@ check_message_format(void) if ( H5C2_jb__journal_entry(/* H5C2_jbrb_t */ &jbrb_struct, /* trans number */ (uint64_t)1, + /* eoa */ (haddr_t)1, /* base address */ (haddr_t)1, /* data length */ 2, /* data */ (const uint8_t *)"AB") @@ -5648,6 +5650,7 @@ check_message_format(void) if ( H5C2_jb__journal_entry(/* H5C2_jbrb_t */ &jbrb_struct, /* trans number */ (uint64_t)1, + /* eoa */ (haddr_t)1, /* base address */ (haddr_t)3, /* data length */ 4, /* data */ (const uint8_t *)"CDEF") @@ -5704,6 +5707,7 @@ check_message_format(void) if ( H5C2_jb__journal_entry(/* H5C2_jbrb_t */ &jbrb_struct, /* trans number */ (uint64_t)2, + /* eoa */ (haddr_t)1, /* base address */ (haddr_t)285, /* data length */ 11, /* data */ (const uint8_t *)"Test Data?!") @@ -5759,12 +5763,12 @@ check_message_format(void) /* Fill out verify array with expected messages */ sprintf(verify[0], "0 ver_num 1 target_file_name HDF5.file creation_date %10.10s human_readable 1\n", ctime(¤t_date)); sprintf(verify[1], "1 bgn_trans 1\n"); - sprintf(verify[2], "2 trans_num 1 length 1 base_addr 0x0 body 41 \n"); - sprintf(verify[3], "2 trans_num 1 length 2 base_addr 0x1 body 41 42 \n"); - sprintf(verify[4], "2 trans_num 1 length 4 base_addr 0x3 body 43 44 45 46 \n"); + sprintf(verify[2], "2 trans_num 1 eoa 0x1 length 1 base_addr 0x0 body 41 \n"); + sprintf(verify[3], "2 trans_num 1 eoa 0x1 length 2 base_addr 0x1 body 41 42 \n"); + sprintf(verify[4], "2 trans_num 1 eoa 0x1 length 4 base_addr 0x3 body 43 44 45 46 \n"); sprintf(verify[5], "3 end_trans 1\n"); sprintf(verify[6], "1 bgn_trans 2\n"); - sprintf(verify[7], "2 trans_num 2 length 11 base_addr 0x11d body 54 65 73 74 20 44 61 74 61 3f 21 \n"); + sprintf(verify[7], "2 trans_num 2 eoa 0x1 length 11 base_addr 0x11d body 54 65 73 74 20 44 61 74 61 3f 21 \n"); sprintf(verify[8], "3 end_trans 2\n"); /* verify that messages in journal are same as expected */ @@ -5826,6 +5830,7 @@ check_message_format(void) if ( H5C2_jb__journal_entry(/* H5C2_jbrb_t */ &jbrb_struct, /* trans number */ (uint64_t)3, + /* eoa */ (haddr_t)1, /* base address */ (haddr_t)28591, /* data length */ 6, /* data */ (const uint8_t *)"#1nN`}") @@ -5915,7 +5920,7 @@ check_message_format(void) /* Fill out verify array with expected messages */ sprintf(verify[0], "0 ver_num 1 target_file_name HDF5.file creation_date %10.10s human_readable 1\n", ctime(¤t_date)); sprintf(verify[1], "1 bgn_trans 3\n"); - sprintf(verify[2], "2 trans_num 3 length 6 base_addr 0x6faf body 23 31 6e 4e 60 7d \n"); + sprintf(verify[2], "2 trans_num 3 eoa 0x1 length 6 base_addr 0x6faf body 23 31 6e 4e 60 7d \n"); sprintf(verify[3], "3 end_trans 3\n"); sprintf(verify[4], "C comment This is a comment!\n"); sprintf(verify[5], "C comment This is another comment!\n"); @@ -6105,6 +6110,7 @@ check_legal_calls(void) if ( H5C2_jb__journal_entry(/* H5C2_jbrb_t */ &jbrb_struct, /* Transaction # */ (uint64_t)1, + /* eoa */ (haddr_t)1, /* Base Address */ (haddr_t)123456789, /* Length */ 16, /* Body */ (const uint8_t *)"This should fail") @@ -6185,6 +6191,7 @@ check_legal_calls(void) if ( H5C2_jb__journal_entry(/* H5C2_jbrb_t */ &jbrb_struct, /* Transaction # */ (uint64_t)2, + /* eoa */ (haddr_t)1, /* Base Address */ (haddr_t)123456789, /* Length */ 16, /* Body */ (const uint8_t *)"This should fail") @@ -6206,6 +6213,7 @@ check_legal_calls(void) if ( H5C2_jb__journal_entry(/* H5C2_jbrb_t */ &jbrb_struct, /* Transaction # */ (uint64_t)1, + /* eoa */ (haddr_t)1, /* Base Address */ (haddr_t)123456789, /* Length */ 51, /* Body */ (const uint8_t *)"This is the first transaction during transaction 1.") @@ -6302,6 +6310,7 @@ check_legal_calls(void) if ( H5C2_jb__journal_entry(/* H5C2_jbrb_t */ &jbrb_struct, /* Transaction # */ (uint64_t)2, + /* eoa */ (haddr_t)1, /* Base Address */ (haddr_t)7465, /* Length */ 51, /* Body */ (const uint8_t *)"This is the first transaction during transaction 2!") @@ -6323,6 +6332,7 @@ check_legal_calls(void) if ( H5C2_jb__journal_entry(/* H5C2_jbrb_t */ &jbrb_struct, /* Transaction # */ (uint64_t)2, + /* eoa */ (haddr_t)1, /* Base Address */ (haddr_t)123456789, /* Length */ 60, /* Body */ (const uint8_t *)"... And here's your second transaction during transaction 2.") @@ -7072,9 +7082,10 @@ write_verify_trans_num(H5C2_jbrb_t * struct_ptr, if ( H5C2_jb__journal_entry(/* H5C2_jbrb_t */ struct_ptr, /* Transaction # */ trans_num, + /* eoa */ (haddr_t)16, /* Base Address */ (haddr_t)16, - /* Length */ 9, - /* Body */ (const uint8_t *)"XXXXXXXXX") + /* Length */ 6, + /* Body */ (const uint8_t *)"XXXXXX") != SUCCEED ) { pass2 = FALSE; @@ -7088,9 +7099,10 @@ write_verify_trans_num(H5C2_jbrb_t * struct_ptr, if ( H5C2_jb__journal_entry(/* H5C2_jbrb_t */ struct_ptr, /* Transaction # */ trans_num, + /* eoa */ (haddr_t)16, /* Base Address */ (haddr_t)16, - /* Length */ 8, - /* Body */ (const uint8_t *)"XXXXXXXX") + /* Length */ 5, + /* Body */ (const uint8_t *)"XXXXX") != SUCCEED ) { pass2 = FALSE; @@ -7104,9 +7116,10 @@ write_verify_trans_num(H5C2_jbrb_t * struct_ptr, if ( H5C2_jb__journal_entry(/* H5C2_jbrb_t */ struct_ptr, /* Transaction # */ trans_num, + /* eoa */ (haddr_t)16, /* Base Address */ (haddr_t)16, - /* Length */ 7, - /* Body */ (const uint8_t *)"XXXXXXX") + /* Length */ 4, + /* Body */ (const uint8_t *)"XXXX") != SUCCEED ) { pass2 = FALSE; diff --git a/tools/h5recover/h5recover.c b/tools/h5recover/h5recover.c index bb83d24..2b037be 100644 --- a/tools/h5recover/h5recover.c +++ b/tools/h5recover/h5recover.c @@ -13,6 +13,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#define H5F_PACKAGE + #include "hdf5.h" #include "h5tools.h" #include "h5tools_utils.h" @@ -21,6 +23,7 @@ #include #include #include +#include "H5Fpkg.h" const char * progname="h5recover"; int d_status; @@ -186,9 +189,10 @@ main (int argc, const char *argv[]) char * readback; /* array to read into from journal */ char * last_trans_msg; /* array to keep last end_trans msg */ int last_trans_found = 0; /* bool */ - char * tok[9]; /* string tokens */ + char * tok[11]; /* string tokens */ int i; /* iterator */ haddr_t address; /* address to write to */ + haddr_t eoa; /* end of address of file */ uint8_t * body; /* body of journal entry */ size_t size; /* size of journal entry body */ size_t max_size; /* maximum size of journal entry body */ @@ -203,6 +207,7 @@ main (int argc, const char *argv[]) long pos; /* file descriptor position indicator */ long pos_end; /* file descriptor position indicator */ char temp[100]; /* temporary buffer */ + H5F_t * f; /* File pointer */ /********************** * Command line parsing @@ -497,7 +502,7 @@ main (int argc, const char *argv[]) /* if ( verbose ) printf(" token[0] : <%s>\n", tok[0]); */ - for (i=1; i<8; i++) { + for (i=1; i<10; i++) { tok[i] = HDstrtok(NULL, " "); if (tok[i] == NULL) { @@ -513,8 +518,8 @@ main (int argc, const char *argv[]) /* put all remaining data into last token. */ /* This contains all of the journal entry body */ - tok[8] = HDstrtok(NULL, "\n"); - if (tok[8] == NULL) { + tok[10] = HDstrtok(NULL, "\n"); + if (tok[10] == NULL) { error_msg(progname, "Could not tokenize journal entry\n"); leave( EXIT_FAILURE); @@ -530,7 +535,7 @@ main (int argc, const char *argv[]) if ( verbose ) printf("Converting data from character strings.\n"); /* convert address from character character string */ - address = HDstrtod(tok[6], NULL); + address = HDstrtod(tok[8], NULL); if (address == 0) { error_msg(progname, "Could not convert address to integer\n"); @@ -541,7 +546,7 @@ main (int argc, const char *argv[]) /* if ( verbose ) printf(" address: %llx\n", address); */ /* convert size from character string*/ - size = HDstrtod(tok[4], NULL); + size = HDstrtod(tok[6], NULL); if (size == 0) { error_msg(progname, "Could not convert size to double\n"); @@ -549,6 +554,15 @@ main (int argc, const char *argv[]) } /* end if */ + /* convert eoa from character character string */ + eoa = HDstrtod(tok[4], NULL); + if (eoa == 0) { + + error_msg(progname, "Could not convert eoa to integer\n"); + leave( EXIT_FAILURE); + + } /* end if */ + /* if ( verbose ) printf(" size: %d\n", size); */ /* transform body out of hexadecimal character string */ @@ -560,7 +574,7 @@ main (int argc, const char *argv[]) } /* end if */ - p = &(tok[8])[0]; + p = &(tok[10])[0]; for (i = 0; i < size; i++) { @@ -690,7 +704,23 @@ main (int argc, const char *argv[]) leave( EXIT_FAILURE ); } /* end if */ - + + /* obtain H5F_t pointer */ + if ((f = H5I_object(fid)) == -1) { + + error_msg(progname, "Could not obtain H5F_t pointer from file id"); + leave( EXIT_FAILURE ); + + } /* end if */ + + /* set the correct value of the eoa */ + if (H5FDset_eoa(f->shared->lf, H5FD_MEM_DEFAULT, eoa) == -1) { + + error_msg(progname, "Driver set eoa request failed"); + leave( EXIT_FAILURE ); + + } /* end if */ + /* close HDF5 file */ if ( H5Fclose(fid) == -1 ) { -- cgit v0.12