diff options
Diffstat (limited to 'src/H5PB.c')
-rw-r--r-- | src/H5PB.c | 206 |
1 files changed, 104 insertions, 102 deletions
@@ -24,21 +24,21 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ #include "H5PBmodule.h" /* This source code file is part of the H5PB module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5PBpkg.h" /* File access */ -#include "H5SLprivate.h" /* Skip List */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5PBpkg.h" /* File access */ +#include "H5SLprivate.h" /* Skip List */ /****************/ @@ -153,7 +153,7 @@ H5FL_DEFINE_STATIC(H5PB_entry_t); /*------------------------------------------------------------------------- - * Function: H5PB_reset_stats + * Function: H5PB_reset_stats * * Purpose: This function was created without documentation. * What follows is my best understanding of Mohamad's intent. @@ -162,11 +162,11 @@ H5FL_DEFINE_STATIC(H5PB_entry_t); * * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ -herr_t +herr_t H5PB_reset_stats(H5PB_t *page_buf) { FUNC_ENTER_NOAPI_NOERR @@ -190,7 +190,7 @@ H5PB_reset_stats(H5PB_t *page_buf) /*------------------------------------------------------------------------- - * Function: H5PB_get_stats + * Function: H5PB_get_stats * * Purpose: This function was created without documentation. * What follows is my best understanding of Mohamad's intent. @@ -202,13 +202,13 @@ H5PB_reset_stats(H5PB_t *page_buf) * --evictions: the number of metadata and raw data evictions from the page buffer layer * --bypasses: the number of metadata and raw data accesses that bypass the page buffer layer * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ -herr_t +herr_t H5PB_get_stats(const H5PB_t *page_buf, unsigned accesses[2], unsigned hits[2], unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]) { @@ -233,16 +233,16 @@ H5PB_get_stats(const H5PB_t *page_buf, unsigned accesses[2], unsigned hits[2], /*------------------------------------------------------------------------- - * Function: H5PB_print_stats() + * Function: H5PB_print_stats() * * Purpose: This function was created without documentation. * What follows is my best understanding of Mohamad's intent. * * Print out statistics collected for the page buffer layer. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -278,13 +278,13 @@ H5PB_print_stats(const H5PB_t *page_buf) /*------------------------------------------------------------------------- - * Function: H5PB_create + * Function: H5PB_create * - * Purpose: Create and setup the PB on the file. + * Purpose: Create and setup the PB on the file. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -314,7 +314,7 @@ H5PB_create(H5F_shared_t *f_sh, size_t size, unsigned page_buf_min_meta_perc, un /* Allocate the new page buffering structure */ if(NULL == (page_buf = H5FL_CALLOC(H5PB_t))) - HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "memory allocation failed") page_buf->max_size = size; H5_CHECKED_ASSIGN(page_buf->page_size, size_t, f_sh->fs_page_size, hsize_t); @@ -355,13 +355,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB__flush_cb + * Function: H5PB__flush_cb * - * Purpose: Callback to flush PB skiplist entries. + * Purpose: Callback to flush PB skiplist entries. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -389,13 +389,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB_flush + * Function: H5PB_flush * - * Purpose: Flush/Free all the PB entries to the file. + * Purpose: Flush/Free all the PB entries to the file. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -424,13 +424,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB__dest_cb + * Function: H5PB__dest_cb * - * Purpose: Callback to free PB skiplist entries. + * Purpose: Callback to free PB skiplist entries. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -461,13 +461,13 @@ H5PB__dest_cb(void *item, void H5_ATTR_UNUSED *key, void *_op_data) /*------------------------------------------------------------------------- - * Function: H5PB_dest + * Function: H5PB_dest * - * Purpose: Flush and destroy the PB on the file if it exists. + * Purpose: Flush and destroy the PB on the file if it exists. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -515,16 +515,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB_add_new_page + * Function: H5PB_add_new_page * - * Purpose: Add a new page to the new page skip list. This is called - * from the MF layer when a new page is allocated to - * indicate to the page buffer layer that a read of the page + * Purpose: Add a new page to the new page skip list. This is called + * from the MF layer when a new page is allocated to + * indicate to the page buffer layer that a read of the page * from the file is not necessary since it's an empty page. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -575,20 +575,20 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB_update_entry + * Function: H5PB_update_entry * - * Purpose: In PHDF5, entries that are written by other processes and just - * marked clean by this process have to have their corresponding - * pages updated if they exist in the page buffer. + * Purpose: In PHDF5, entries that are written by other processes and just + * marked clean by this process have to have their corresponding + * pages updated if they exist in the page buffer. * This routine checks and update the pages. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ -herr_t +herr_t H5PB_update_entry(H5PB_t *page_buf, haddr_t addr, size_t size, const void *buf) { H5PB_entry_t *page_entry; /* Pointer to the corresponding page entry */ @@ -675,14 +675,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB_read + * Function: H5PB_read * - * Purpose: Reads in the data from the page containing it if it exists + * Purpose: Reads in the data from the page containing it if it exists * in the PB cache; otherwise reads in the page through the VFD. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -743,7 +743,7 @@ H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void * page_buf->bypasses[0] ++; } /* end if */ - /* If page buffering is disabled, or if this is a large metadata access, + /* If page buffering is disabled, or if this is a large metadata access, * or if this is parallel raw data access, we are done here */ if(NULL == page_buf || (size >= page_buf->page_size && H5FD_MEM_DRAW != type) || @@ -769,7 +769,7 @@ H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void * last_page_addr = ((addr + size - 1) / page_buf->page_size) * page_buf->page_size; /* How many pages does this write span */ - num_touched_pages = (last_page_addr / page_buf->page_size + 1) - + num_touched_pages = (last_page_addr / page_buf->page_size + 1) - (first_page_addr / page_buf->page_size); if(first_page_addr == last_page_addr) { HDassert(1 == num_touched_pages); @@ -822,7 +822,7 @@ H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void * offset = addr - first_page_addr; HDassert(page_buf->page_size > offset); - H5MM_memcpy(buf, (uint8_t *)page_entry->page_buf_ptr + offset, + H5MM_memcpy(buf, (uint8_t *)page_entry->page_buf_ptr + offset, page_buf->page_size - (size_t)offset); /* move to top of LRU list */ @@ -830,7 +830,7 @@ H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void * } /* end if */ /* special handling for the last page if it is not a full page access */ else if(num_touched_pages > 1 && i == num_touched_pages-1 && search_addr < addr+size) { - offset = (num_touched_pages-2)*page_buf->page_size + + offset = (num_touched_pages-2)*page_buf->page_size + (page_buf->page_size - (addr - first_page_addr)); H5MM_memcpy((uint8_t *)buf + offset, page_entry->page_buf_ptr, @@ -843,7 +843,7 @@ H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void * else { offset = i*page_buf->page_size; - H5MM_memcpy((uint8_t *)buf+(i*page_buf->page_size) , page_entry->page_buf_ptr, + H5MM_memcpy((uint8_t *)buf+(i*page_buf->page_size) , page_entry->page_buf_ptr, page_buf->page_size); } /* end else */ } /* end if */ @@ -971,15 +971,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB_write + * Function: H5PB_write * - * Purpose: Write data into the Page Buffer. If the page exists in the - * cache, update it; otherwise read it from disk, update it, and - * insert into cache. + * Purpose: Write data into the Page Buffer. If the page exists in the + * cache, update it; otherwise read it from disk, update it, and + * insert into cache. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -1039,7 +1039,7 @@ H5PB_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, page_buf->bypasses[0]++; } /* end if */ - /* If page buffering is disabled, or if this is a large metadata access, + /* If page buffering is disabled, or if this is a large metadata access, * or if this is a parallel raw data access, we are done here */ if(NULL == page_buf || (size >= page_buf->page_size && H5FD_MEM_DRAW != type) || @@ -1073,7 +1073,7 @@ H5PB_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, last_page_addr = (addr + size - 1) / page_buf->page_size * page_buf->page_size; /* how many pages does this write span */ - num_touched_pages = (last_page_addr/page_buf->page_size + 1) - + num_touched_pages = (last_page_addr/page_buf->page_size + 1) - (first_page_addr / page_buf->page_size); if(first_page_addr == last_page_addr) { HDassert(1 == num_touched_pages); @@ -1114,18 +1114,18 @@ H5PB_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, } /* end if */ } /* end if */ /* Special handling for the last page if it is not a full page update */ - else if(num_touched_pages > 1 && i == (num_touched_pages - 1) && + else if(num_touched_pages > 1 && i == (num_touched_pages - 1) && (search_addr + page_buf->page_size) != (addr + size)) { HDassert(search_addr+page_buf->page_size > addr+size); /* Lookup the page in the skip list */ page_entry = (H5PB_entry_t *)H5SL_search(page_buf->slist_ptr, (void *)(&search_addr)); if(page_entry) { - offset = (num_touched_pages - 2) * page_buf->page_size + + offset = (num_touched_pages - 2) * page_buf->page_size + (page_buf->page_size - (addr - first_page_addr)); /* Update page's data */ - H5MM_memcpy(page_entry->page_buf_ptr, (const uint8_t *)buf + offset, + H5MM_memcpy(page_entry->page_buf_ptr, (const uint8_t *)buf + offset, (size_t)((addr + size) - last_page_addr)); /* Mark page dirty and push to top of LRU */ @@ -1311,30 +1311,28 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB__insert_entry() + * Function: H5PB__insert_entry() * - * Purpose: ??? - * - * This function was created without documentation. - * What follows is my best understanding of Mohamad's intent. + * Purpose: This function was created without documentation. + * What follows is my best understanding of Mohamad's intent. * - * Insert the supplied page into the page buffer, both the - * skip list and the LRU. + * Insert the supplied page into the page buffer, both the + * skip list and the LRU. * - * As best I can tell, this function imposes no limit on the - * number of entries in the page buffer beyond an assertion - * failure it the page count exceeds the limit. + * As best I can tell, this function imposes no limit on the + * number of entries in the page buffer beyond an assertion + * failure it the page count exceeds the limit. * * JRM -- 12/22/16 * * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ -static herr_t +static herr_t H5PB__insert_entry(H5PB_t *page_buf, H5PB_entry_t *page_entry) { herr_t ret_value = SUCCEED; /* Return value */ @@ -1361,16 +1359,21 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB__make_space() + * Function: H5PB__make_space() * - * Purpose: If necessary and if possible, evict a page from the page - * buffer to make space for the supplied page. Depending on - * the page buffer configuration and contents, and the page - * supplied this may or may not be possible. + * Purpose: This function was created without documentation. + * What follows is my best understanding of Mohamad's intent. * - * Return: Non-negative on success/Negative on failure + * If necessary and if possible, evict a page from the page + * buffer to make space for the supplied page. Depending on + * the page buffer configuration and contents, and the page + * supplied this may or may not be possible. * - * Programmer: Mohamad Chaarawi + * JRM -- 12/22/16 + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -1399,7 +1402,7 @@ H5PB__make_space(H5F_shared_t *f_sh, H5PB_t *page_buf, H5FD_mem_t inserted_type) /* check the metadata threshold before evicting metadata items */ while(1) { - if(page_entry->prev && H5F_MEM_PAGE_META == page_entry->type && + if(page_entry->prev && H5F_MEM_PAGE_META == page_entry->type && page_buf->min_meta_count >= page_buf->meta_count) page_entry = page_entry->prev; else @@ -1416,7 +1419,7 @@ H5PB__make_space(H5F_shared_t *f_sh, H5PB_t *page_buf, H5FD_mem_t inserted_type) /* check the raw data threshold before evicting raw data items */ while(1) { - if(page_entry->prev && (H5F_MEM_PAGE_DRAW == page_entry->type || H5F_MEM_PAGE_GHEAP == page_entry->type) && + if(page_entry->prev && (H5F_MEM_PAGE_DRAW == page_entry->type || H5F_MEM_PAGE_GHEAP == page_entry->type) && page_buf->min_raw_count >= page_buf->raw_count) page_entry = page_entry->prev; else @@ -1459,17 +1462,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB__write_entry() + * Function: H5PB__write_entry() * - * Purpose: ??? - * - * This function was created without documentation. - * What follows is my best understanding of Mohamad's intent. + * Purpose: ??? * + * This function was created without documentation. + * What follows is my best understanding of Mohamad's intent. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ |