Changeset 9165

Show
Ignore:
Timestamp:
12/15/11 15:46:06 (18 months ago)
Author:
denton
Message:

Added some doxygen info.

Location:
trunk/src/client/usrint
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/client/usrint/ucache.c

    r9151 r9165  
    55 */ 
    66 
    7 /* Experimental cache for user data 
    8  * Currently under development... 
    9  */ 
    10 #include <usrint.h> /* to get PVFS_UCACHE_ENABLE */ 
     7/**  
     8 * \file   
     9 * \ingroup usrint 
     10 *  
     11 * Experimental cache for user data.  
     12 * 
     13 */ 
    1114#include "usrint.h" 
    1215#include "posix-ops.h" 
    1316#include "openfile-util.h" 
     17#include "iocommon.h" 
    1418#if PVFS_UCACHE_ENABLE 
    15 #include <ucache.h> 
    16 #include <iocommon.h> 
    17 #define FILE_SYSTEM_ENABLED  
     19#include "ucache.h" 
    1820 
    1921/* Global Variables */ 
     
    115117 */ 
    116118 
    117 /**  Initializes the cache.  
     119/**   
     120 * Initializes the cache.  
    118121 * Mainly, it aquires a previously created shared memory segment used to  
    119122 * cache data. The shared mem. creation and ftbl initialization should already 
     
    176179} 
    177180 
    178 /** Returns a pointer to the mtbl corresponding to the blk & ent.  
     181/**  
     182 * Returns a pointer to the mtbl corresponding to the blk & ent.  
    179183 * Input must be reliable otherwise invalid mtbl could be returned. 
    180184 */ 
     
    192196} 
    193197 
    194 /** Initializes the ucache file table if it hasn't previously been initialized. 
     198/**  
     199 * Initializes the ucache file table if it hasn't previously been initialized. 
    195200 * Although this function is visible, DO NOT CALL THIS FUNCTION.  
    196201 * It is meant to be called in the ucache daemon or during testing. 
     
    260265} 
    261266 
     267/** 
     268 * Opens a file in ucache. 
     269 */ 
    262270int ucache_open_file(PVFS_fs_id *fs_id, 
    263271                     PVFS_handle *handle,  
     
    322330} 
    323331 
    324 /** Returns ptr to block in ucache based on file and offset */ 
     332/**  
     333 * Returns ptr to block in ucache based on file and offset  
     334 */ 
    325335inline void *ucache_lookup(struct file_ent_s *fent, uint64_t offset,  
    326336                                         uint16_t *block_ndx) 
     
    341351} 
    342352 
    343 /** Prepares the data structures for block storage.  
     353/**  
     354 * Prepares the data structures for block storage.  
    344355 * On success, returns a pointer to where the block of data should be written.  
    345356 * On failure, returns NIL. 
     
    357368 
    358369#if 0 
    359 /** Removes a cached block of data from mtbl  
     370/**  
     371 * Removes a cached block of data from mtbl  
    360372 * Returns 1 on success, 0 on failure. 
    361373 */  
     
    370382#endif 
    371383 
    372 /** Flushes the entire ucache's dirty blocks (every file's dirty blocks) */ 
    373 /* Returns 0 on success, -1 on failure*/ 
     384/**  
     385 * Flushes the entire ucache's dirty blocks (every file's dirty blocks) 
     386 * Returns 0 on success, -1 on failure 
     387 */ 
    374388int ucache_flush_cache(void) 
    375389{ 
     
    403417} 
    404418 
    405 /** Externally visible wrapper of the internal flush file function. 
     419/**  
     420 * Externally visible wrapper of the internal flush file function. 
    406421 * This is intended to allow and external flush file call which locks the  
    407422 * global lock, flushes the file, then releases the global lock. 
     
    419434} 
    420435 
    421 /** Internal only function - Flushes dirty blocks to the I/O Nodes  
     436/**  
     437 * Internal only function - Flushes dirty blocks to the I/O Nodes  
    422438 * Returns 0 on success and -1 on failure. 
    423439 */ 
     
    445461        mtbl->mem[i].dirty_next = NIL16;  
    446462 
    447         #ifdef FILE_SYSTEM_ENABLED 
     463        /*#ifdef FILE_SYSTEM_ENABLED*/ 
    448464        PVFS_object_ref ref = {fent->tag_handle, fent->tag_id, 0}; 
    449465        struct iovec vector = {&(ucache->b[ment->item].mblk[0]), CACHE_BLOCK_SIZE_K * 1024}; 
    450466        rc = iocommon_vreadorwrite(2, &ref, ment->tag, 1, &vector);  
     467        /* 
    451468        #endif 
    452469        #ifndef FILE_SYSTEM_ENABLED 
    453470        rc = 0; 
    454471        #endif 
     472        */ 
    455473 
    456474        lock_unlock(blk_lock); 
     
    468486} 
    469487 
    470 /* This function is meant to be called only inside remove_mem. */ 
    471 /* Returns 0 on success, -1 on failure */ 
     488/** 
     489 * This function is meant to be called only inside remove_mem. 
     490 * Returns 0 on success, -1 on failure  
     491 */ 
    472492int flush_block(struct file_ent_s *fent, struct mem_ent_s *ment) 
    473493{ 
    474494    int rc = 0; 
    475     #ifdef FILE_SYSTEM_ENABLED 
     495    /*#ifdef FILE_SYSTEM_ENABLED*/ 
    476496    PVFS_object_ref ref = {fent->tag_handle, fent->tag_id, 0}; 
    477497    struct iovec vector = {&(ucache->b[ment->item].mblk[0]), CACHE_BLOCK_SIZE_K * 1024}; 
    478498    rc = iocommon_vreadorwrite(2, &ref, ment->tag, 1, &vector); 
     499    /* 
    479500    #endif 
    480501    #ifndef FILE_SYSTEM_ENABLED 
    481502    rc = 0; 
    482503    #endif 
     504    */ 
    483505    return rc; 
    484506} 
    485507 
    486508 
    487 /* For testing purposes only */ 
     509/**  
     510 * For testing purposes only! 
     511 */ 
    488512int wipe_ucache(void) 
    489513{ 
     
    517541} 
    518542 
    519 /** Removes all memory entries in the mtbl corresponding to the file info  
     543/**  
     544 * Removes all memory entries in the mtbl corresponding to the file info  
    520545 * provided as parameters. It also removes the mtbl and the file entry from  
    521546 * the cache. 
     
    530555} 
    531556 
    532 /** Dumps all cache related information. */ 
     557/**  
     558 * Dumps all cache related information.  
     559 */ 
    533560int ucache_info(FILE *out, char *flags) 
    534561{ 
     
    745772} 
    746773 
    747 /** Returns a pointer to the lock corresponding to the block_index. 
    748     If the index is out of range, then 0 is returned. 
     774/**  
     775 * Returns a pointer to the lock corresponding to the block_index. 
     776 * If the index is out of range, then 0 is returned. 
    749777 */ 
    750778inline ucache_lock_t *get_lock(uint16_t block_index) 
     
    760788/* Beginning of internal only (static) functions */ 
    761789 
    762 /** Initializes the proper lock based on the LOCK_TYPE  
     790/**  
     791 * Initializes the proper lock based on the LOCK_TYPE  
    763792 * Returns 0 on success, -1 on error 
    764793 */ 
     
    789818} 
    790819 
    791 /** Returns 0 when lock is locked; otherwise, return -1 and sets errno */ 
     820/**  
     821 * Returns 0 when lock is locked; otherwise, return -1 and sets errno. 
     822 */ 
    792823inline int lock_lock(ucache_lock_t * lock) 
    793824{ 
     
    817848} 
    818849 
    819 /** If successful, return zero; otherwise, return -1 and sets errno */ 
     850/**  
     851 * If successful, return zero; otherwise, return -1 and sets errno.  
     852 */ 
    820853inline int lock_unlock(ucache_lock_t * lock) 
    821854{ 
     
    832865} 
    833866 
    834 /** Upon successful completion, returns zero  
     867/**  
     868 * Upon successful completion, returns zero  
    835869 * Otherwise, returns -1 and sets errno. 
    836870 */ 
     
    842876#endif 
    843877 
    844 /** Upon successful completion, returns zero. 
     878/**  
     879 * Upon successful completion, returns zero. 
    845880 * Otherwise, returns -1. 
    846881 * The functions have the same return policy. 
     
    861896#endif 
    862897 
    863 /* Tries the lock to see if it's available: 
     898/**  
     899 * Tries the lock to see if it's available: 
    864900 * Returns 0 if lock has not been aquired ie: success 
    865901 * Otherwise, returns -1 
     
    901937 
    902938/* Dirty List Iterator */ 
    903 /** Returns true if current index is NIL, otherwise, returns 0 */ 
     939/**  
     940 * Returns true if current index is NIL, otherwise, returns 0. 
     941 */ 
    904942static inline unsigned char dirty_done(uint16_t index) 
    905943{ 
     
    907945} 
    908946 
    909 /** Returns the next index in the dirty list for the provided mtbl and index */ 
     947/**  
     948 * Returns the next index in the dirty list for the provided mtbl and index  
     949 */ 
    910950static inline uint16_t dirty_next(struct mem_table_s *mtbl, uint16_t index) 
    911951{ 
     
    914954 
    915955/*  Memory Entry Chain Iterator */ 
    916 /** Returns true if current index is NIL, otherwise, returns 0 */ 
     956/**  
     957 * Returns true if current index is NIL, otherwise, returns 0. 
     958 */ 
    917959static inline unsigned char ment_done(uint16_t index) 
    918960{ 
     
    920962} 
    921963 
    922 /** Returns the next index in the memory entry chain for the provided mtbl  
     964/**  
     965 * Returns the next index in the memory entry chain for the provided mtbl  
    923966 * and index.  
    924967 */ 
     
    929972 
    930973/*  File Entry Chain Iterator   */ 
    931 /** Returns true if current index is NIL, otherwise, returns 0 */ 
     974/**  
     975 * Returns true if current index is NIL, otherwise, returns 0  
     976 */ 
    932977static unsigned char file_done(uint16_t index) 
    933978{ 
     
    935980} 
    936981 
    937 /** Returns the next index in the file entry chain for the provided mtbl  
     982/**  
     983 * Returns the next index in the file entry chain for the provided mtbl  
    938984 * and index.  
    939985 */ 
     
    943989} 
    944990 
    945 /**This function should only be called when the ftbl has no free mtbls.  
     991/** 
     992 * This function should only be called when the ftbl has no free mtbls.  
    946993 * It initizializes MTBL_PER_BLOCK additional mtbls in the block provided, 
    947994 * meaning this block will no longer be used for storing file data but  
     
    9731020    ftbl->free_mtbl_ent = start_mtbl;    
    9741021} 
    975  
     1022/** 
     1023 * Initializes a memory entry. 
     1024 */ 
    9761025static inline int init_memory_entry(struct mem_table_s *mtbl, int16_t index) 
    9771026{ 
     
    9891038} 
    9901039 
    991 /** Initializes a mtbl which is a hash table of memory entries. 
     1040/**  
     1041 * Initializes a mtbl which is a hash table of memory entries. 
    9921042 * The mtbl will be located at the provided entry index within  
    9931043 * the provided block. 
     
    10211071 
    10221072 
    1023 /** This function asks the file table if a free block is avaialable.  
     1073/**  
     1074 * This function asks the file table if a free block is avaialable.  
    10241075 * If so, returns the block's index; otherwise, returns NIL. 
    10251076 */ 
     
    10391090} 
    10401091 
    1041 /** Accepts an index corresponding to a block that is put back on the file  
     1092/**  
     1093 * Accepts an index corresponding to a block that is put back on the file  
    10421094 * table free list. 
    10431095 */ 
     
    10511103} 
    10521104 
    1053 /** Consults the file table to retrieve an index corresponding to a file entry 
     1105/**  
     1106 * Consults the file table to retrieve an index corresponding to a file entry 
    10541107 * If available, returns the file entry index, otherwise returns NIL. 
    10551108 */ 
     
    10701123} 
    10711124 
    1072 /** Places the file entry located at the provided index back on the file table's 
     1125/**  
     1126 * Places the file entry located at the provided index back on the file table's 
    10731127 * free file entry list. If the index is < FILE_TABLE_HASH_MAX, then set next  
    10741128 * to NIL since this index must remain the head of the linked list. Otherwise, 
     
    10941148} 
    10951149 
    1096 /** Consults the provided mtbl's memory entry free list to get the index of the 
     1150/**  
     1151 * Consults the provided mtbl's memory entry free list to get the index of the 
    10971152 * next free memory entry. Returns the index if one is available, otherwise  
    10981153 * returns NIL. 
     
    11091164} 
    11101165 
    1111 /** Puts the memory entry corresponding to the provided mtbl and entry index  
     1166/**  
     1167 * Puts the memory entry corresponding to the provided mtbl and entry index  
    11121168 * back on the mtbl's memory entry free list.  
    11131169 * 
     
    11341190} 
    11351191 
    1136 /** Perform a file lookup on the ucache using the provided fs_id and handle. 
     1192/**  
     1193 * Perform a file lookup on the ucache using the provided fs_id and handle. 
    11371194 * 
    11381195 * Additional parameters (references) may used that will be set to values  
     
    11981255} 
    11991256 
    1200 /** Function that locates the next free mtbl. 
     1257/**  
     1258 * Function that locates the next free mtbl. 
    12011259 * On success, Returns 1 and sets reference parameters to proper indexes. 
    12021260 * On failure, returns NIL;  
     
    12301288} 
    12311289 
    1232 /** Places memory entries' corresponding blocks  
     1290/**  
     1291 * Places memory entries' corresponding blocks  
    12331292 * back on the ftbl block free list. Reinitializes mtbl. 
    12341293 * Assumes mtbl->ref_cnt is 0.   
     
    12571316} 
    12581317 
    1259 /** Places the provided mtbl back on the ftbl's mtbl free list provided it  
     1318/**  
     1319 * Places the provided mtbl back on the ftbl's mtbl free list provided it  
    12601320 * isn't currently referenced. 
    12611321 */ 
     
    12831343} 
    12841344 
    1285 /** Insert information about file into ucache (no file data inserted) 
     1345/**  
     1346 * Insert information about file into ucache (no file data inserted) 
    12861347 * Returns pointer to mtbl on success. 
    12871348 *  
     
    13821443} 
    13831444 
    1384 /** Remove file entry and memory table of file identified by parameters 
     1445/**  
     1446 * Remove file entry and memory table of file identified by parameters 
    13851447 * Returns 1 following removal 
    13861448 * Returns NIL if file is referenced or if the file could not be located. 
     
    14361498} 
    14371499 
    1438 /** Lookup the memory location of a block of data in cache that is identified  
     1500/**  
     1501 * Lookup the memory location of a block of data in cache that is identified  
    14391502 * by the mtbl and offset parameters. 
    14401503 * 
     
    14951558} 
    14961559 
    1497 /** Update the provided mtbl's LRU doubly-linked list by placing the memory  
     1560/**  
     1561 * Update the provided mtbl's LRU doubly-linked list by placing the memory  
    14981562 * entry, identified by the provided index, at the head of the list (lru_first). 
    1499  * 
    15001563 */ 
    15011564static inline void update_LRU(struct mem_table_s *mtbl, uint16_t index) 
     
    15761639}     
    15771640 
    1578 /** Searches the ftbl for the mtbl with the most entries. 
     1641/**  
     1642 * Searches the ftbl for the mtbl with the most entries. 
    15791643 * Returns the number of memory entries the max mtbl has. The double ptr  
    15801644 * parameter is used to store a reference to the mtbl pointer with the most  
     
    16191683} 
    16201684 
    1621 /** Evicts the LRU memory entry from the tail (lru_last) of the provided 
     1685/**  
     1686 * Evicts the LRU memory entry from the tail (lru_last) of the provided 
    16221687 * mtbl's LRU list. 
    16231688 *  
     
    16471712 
    16481713 
    1649 /** Used to obtain a block for storage of data identified by the offset  
     1714/**  
     1715 * Used to obtain a block for storage of data identified by the offset  
    16501716 * parameter and maintained in the mtbl at the memory entry identified by the  
    16511717 * index parameter. 
     
    17071773} 
    17081774 
    1709 /** Requests a location in memory to place the data identified by the mtbl and  
     1775/**  
     1776 * Requests a location in memory to place the data identified by the mtbl and  
    17101777 * offset parameters. Also inserts the necessary info into the mtbl. 
    17111778 * 
     
    17811848} 
    17821849 
    1783 /** Removes all table info regarding the block identified by the mtbl and 
     1850/**  
     1851 * Removes all table info regarding the block identified by the mtbl and 
    17841852 * offset provided the block isn't locked.  
    17851853 * 
     
    18661934 
    18671935/* The following two functions are provided for error checking purposes. */ 
     1936/** 
     1937 * Prints the Least Recently Used (LRU) list. 
     1938 */ 
    18681939void print_LRU(struct mem_table_s *mtbl) 
    18691940{ 
     
    18871958} 
    18881959 
     1960/** 
     1961 * Prints the list of dirty (modified) blocks that should eventually be  
     1962 * flushed to disk. 
     1963 */ 
    18891964void print_dirty(struct mem_table_s *mtbl) 
    18901965{ 
  • trunk/src/client/usrint/ucache.h

    r9151 r9165  
    55 */ 
    66 
     7/**  
     8 * \file  
     9 * \ingroup usrint 
     10 * ucache routines 
     11 */ 
    712#ifndef UCACHE_H 
    813#define UCACHE_H 1 
    914 
    10 #include <stdio.h> 
    1115#include <stdint.h> 
    12 #include <string.h> 
    1316#include <pthread.h> 
    1417#include <sys/shm.h>