diff options
-rw-r--r-- | ncache.c | 35 | ||||
-rw-r--r-- | ncache.h | 22 | ||||
-rw-r--r-- | node.c | 77 | ||||
-rw-r--r-- | node.h | 10 | ||||
-rw-r--r-- | nsmux.c | 2 | ||||
-rw-r--r-- | options.c | 13 |
6 files changed, 47 insertions, 112 deletions
@@ -36,7 +36,11 @@ ncache_t ncache; /*----------------------------------------------------------------------------*/ /*Cache size (may be overwritten by the user)*/ -int ncache_size = NCACHE_SIZE; +/*int ncache_size = NCACHE_SIZE;*/ +/*Our cache is not really a cache now (actually, it has never been one). Its + main task now will be to maintain additional references to shadow nodes, + which are still in use by some clients and which could possibly go away if + nobody maintained references to them explicitly.*/ /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ @@ -45,14 +49,15 @@ int ncache_size = NCACHE_SIZE; void ncache_init ( - int size_max + /*int size_max*/ + void ) { /*Reset the LRU and MRU ends of the list*/ ncache.mru = ncache.lru = NULL; /*Set the maximal size according to the parameter*/ - ncache.size_max = size_max; + /*ncache.size_max = size_max;*/ /*The cache is empty so far; remark that*/ ncache.size_current = 0; @@ -101,8 +106,9 @@ ncache_node_lookup return err; }/*ncache_node_lookup*/ /*----------------------------------------------------------------------------*/ -/*Removes the given node from the cache*/ -static +/*Removes the given node from the cache. Does not release the reference held + by the cache (for some further finalization actions on the node)*/ +/*Nodes will NOT be removed from the cache automatically*/ void ncache_node_remove ( @@ -139,16 +145,17 @@ ncache_node_remove }/*ncache_node_remove*/ /*----------------------------------------------------------------------------*/ /*Resets the node cache*/ +/*No references to nodes are released*/ void ncache_reset(void) { - /*The node being currently deleted*/ + /*The node being currently removed from the cache*/ node_t * node; /*Acquire a lock on the cache*/ mutex_lock(&ncache.lock); - /*Remove the whole cache chain*/ + /*Release the whole cache chain*/ for(node = ncache.mru; node != NULL; ncache_node_remove(node), node = ncache.mru); /*Release the lock*/ @@ -165,8 +172,8 @@ ncache_node_add /*Acquire a lock on the cache*/ mutex_lock(&ncache.lock); - /*If there already are some nodes in the cache and it is enabled*/ - if((ncache.size_max > 0) || (ncache.size_current > 0)) + /*If there already are some nodes in the cache already*/ + if(ncache.size_current > 0) { /*If the node to be added is not at the MRU end already*/ if(ncache.mru != node) @@ -200,20 +207,20 @@ ncache_node_add } /*While the size of the cache is exceeding the maximal size*/ - node_t * old_lru; +/* node_t * old_lru; for ( old_lru = ncache.lru; ncache.size_current > ncache.size_max; old_lru = ncache.lru ) - { + {*/ /*remove the current LRU end of the list from the cache*/ - ncache_node_remove(old_lru); + /*ncache_node_remove(old_lru);*/ /*release the reference to the node owned by this thread*/ - netfs_nrele(old_lru); - } + /*netfs_nrele(old_lru); + }*/ /*Release the lock on the cache*/ mutex_unlock(&ncache.lock); @@ -36,7 +36,8 @@ /*----------------------------------------------------------------------------*/ /*--------Macros--------------------------------------------------------------*/ /*The default maximal cache size*/ -#define NCACHE_SIZE 256 +/*#define NCACHE_SIZE 256*/ +/*SEE ALSO the comment in ncache.c*/ /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ @@ -51,7 +52,8 @@ struct ncache node_t * lru; /*the maximal number of nodes to cache*/ - int size_max; + /*int size_max;*/ + /*SEE ALSO the comment in ncache.c*/ /*the current length of the cache chain*/ int size_current; @@ -66,7 +68,8 @@ typedef struct ncache ncache_t; /*----------------------------------------------------------------------------*/ /*--------Global Variables----------------------------------------------------*/ /*The cache size (may be overwritten by the user)*/ -extern int cache_size; +/*extern int cache_size;*/ +/*SEE ALSO the comment in ncache.c*/ /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ @@ -75,7 +78,8 @@ extern int cache_size; void ncache_init ( - int size_max + /*int size_max*/ + void ); /*----------------------------------------------------------------------------*/ /*Looks up the lnode and stores the result in `node`; creates a new entry @@ -87,7 +91,17 @@ ncache_node_lookup node_t ** node /*put the result here*/ ); /*----------------------------------------------------------------------------*/ +/*Removes the given node from the cache. Does not release the reference held + by the cache (for some further finalization actions on the node)*/ +/*Nodes will NOT be removed from the cache automatically*/ +void +ncache_node_remove + ( + node_t * node + ); +/*----------------------------------------------------------------------------*/ /*Resets the node cache*/ +/*No references to nodes are released*/ void ncache_reset(void); /*----------------------------------------------------------------------------*/ @@ -34,11 +34,6 @@ #include <stdio.h> #include <argz.h> #include <hurd/fsys.h> - - -/*!!!!!!!REMOVE THIS!!!!!!*/ -#include <sys/file.h> - /*----------------------------------------------------------------------------*/ #include "debug.h" #include "node.h" @@ -1051,75 +1046,3 @@ node_kill_translators } }/*node_kill_translators*/ /*----------------------------------------------------------------------------*/ -/*Constructs a list of translators that were set on the ancestors of `node`*/ -/*TODO: Remove node_list_translators.*/ -error_t -node_list_translators - ( - node_t * node, - char ** trans, /*the malloced list of 0-separated strings*/ - size_t * ntrans /*the number of elements in `trans`*/ - ) - { - /*The size of block of memory for the list of translators*/ - size_t sz = 0; - - /*Used for tracing the lineage of `node`*/ - lnode_t * ln = node->nn->lnode; - - /*Used in computing the lengths of lists of translators in every node - we will go through and for constructing the final list of translators*/ - char * p; - - /*The current position in *data (used in filling out the list of - translators)*/ - char * transp; - - /*The length of the current translator name*/ - size_t complen; - - size_t i; - - /*Trace the lineage of the `node` (including itself) and compute the - total length of the list of translators*/ - for(; ln; sz += node->nn->translen, ln = ln->dir); - - /*Try to allocate a block of memory sufficient for storing the list of - translators*/ - *trans = malloc(sz); - if(!*trans) - return ENOMEM; - - /*No translators at first*/ - *ntrans = 0; - - /*Again trace the lineage of the `node` (including itself)*/ - for(transp = *trans + sz, ln = node->nn->lnode; ln; ln = ln->dir) - { - /*Go through each translator name in the list of names*/ - for - ( - i = 0, p = node->nn->trans + node->nn->translen - 2; - i < node->nn->ntrans; ++i - ) - { - /*position p at the beginning of the current component and - compute its length at the same time*/ - for(complen = 0; *p; --p, ++complen); - --p; - - /*move the current position backwards*/ - transp -= complen + 1; - - /*copy the current translator name into the list*/ - strcpy(transp, p + 2); - - /*we've got another translator*/ - ++*ntrans; - } - } - - /*Everything OK*/ - return 0; - }/*lnode_list_translators*/ -/*----------------------------------------------------------------------------*/ @@ -227,14 +227,4 @@ node_kill_translators node_t * node ); /*----------------------------------------------------------------------------*/ -/*Constructs a list of translators that were set on the ancestors of `node`*/ -/*TODO: Remove node_list_translators.*/ -error_t -node_list_translators - ( - node_t * node, - char ** trans, /*the malloced list of 0-separated strings*/ - size_t * ntrans /*the number of elements in `trans`*/ - ); -/*----------------------------------------------------------------------------*/ #endif /*__NODE_H__*/ @@ -1761,7 +1761,7 @@ main LOG_MSG("Time mapped."); /*Initialize the cache with the required number of nodes*/ - ncache_init(ncache_size); + ncache_init(/*ncache_size*/); LOG_MSG("Cache initialized."); /*Obtain stat information about the underlying node*/ @@ -80,8 +80,9 @@ static int parsing_startup_options_finished; /*Argp options common to both the runtime and the startup parser*/ static const struct argp_option argp_common_options[] = { - {OPT_LONG_CACHE_SIZE, OPT_CACHE_SIZE, "SIZE", 0, - "The maximal number of nodes in the node cache"} + /*{OPT_LONG_CACHE_SIZE, OPT_CACHE_SIZE, "SIZE", 0, + "The maximal number of nodes in the node cache"}*/ + {0} }; /*----------------------------------------------------------------------------*/ /*Argp options only meaningful for startup parsing*/ @@ -147,13 +148,13 @@ argp_parse_common_options /*Go through the possible options*/ switch(key) { - case OPT_CACHE_SIZE: - { + /*case OPT_CACHE_SIZE: + {*/ /*store the new cache-size*/ - ncache_size = strtol(arg, NULL, 10); + /*ncache_size = strtol(arg, NULL, 10); break; - } + }*/ case ARGP_KEY_ARG: /*the directory to mirror*/ { /*try to duplicate the directory name*/ |