diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2001-01-30 00:38:45 +0000 |
---|---|---|
committer | Marcus Brinkmann <marcus@gnu.org> | 2001-01-30 00:38:45 +0000 |
commit | 51fec467c4b771db8ffc6a10a07dbf781a905482 (patch) | |
tree | bc6874275df06dce99b6efa911a21dce0c76a408 /nfs/cache.c | |
parent | 7e4eb0479fbf73dccfc342efc9bca7322135f6f9 (diff) |
2000-12-26 Neal H Walfield <neal@cs.uml.edu>
* cache.c: Change cache/hash table size to 509, a prime. Use
memcpy/memcmp not bcopy/bcmp. Verify return value from malloc and
check the result of rpc transaction _and_ do not act if failed.
* main.c: Correct the wording of the help messages. Do not
bother initializing global variable to 0. Use memcpy/memcmp not
bcopy/bcmp. Verify return value from malloc and check the result
of rpc transaction _and_ do not act if failed.
* mount.c: Check return values of initialize_rpc. Use
memcpy/memcmp not bcopy/bcmp. Verify return value from malloc and
strdup. Correct comments.
(mount_root): Check result of connect. Handle errors
consistently. Reverse loops that are if (! c) {} else when
appropriate.
* mount.h: Protect header with #ifdef.
* name-cache.c: Correct dangerous NPARTIALS macro. Use
memcpy/memcmp not bcopy/bcmp.
(find_cache): Use PARTIAL_THRESH, not the constant.
* nfs-spec.h: Protect header with #ifdef.
* nfs.c: Use memcpy/memcmp not bcopy/bcmp.
* nfs.h: Likewise.
* ops.c (netfs_attempt_mkdir): Check return values of initialize_rpc.
Use memcpy/memcmp not bcopy/bcmp. Verify return value from malloc and
check the result of rpc transaction _and_ do not act if failed.
(netfs_attempt_link): Unlock the directory before the rpc transaction.
Check the result of rpc transaction _and_ do not act if failed.
* pager.c: Remove, we do not use it.
* rpc.c: Use memcpy/memcmp not bcopy/bcmp. Verify return value from
malloc and check the result of rpc transaction _and_ do not act if
failed.
(initialize_rpc): Use AUTH_NONE, not the depreciated
AUTH_NULL. Return sane values on failure.
(generate_xid): Make inline.
(link_rpc): New function. Complements unlink_rpc.
(conduct_rpc): Use link_rpc.
(rpc_receive_thread): Reroll to a single loop.
Diffstat (limited to 'nfs/cache.c')
-rw-r--r-- | nfs/cache.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/nfs/cache.c b/nfs/cache.c index 183660b0..3cdb527f 100644 --- a/nfs/cache.c +++ b/nfs/cache.c @@ -23,8 +23,11 @@ #include <string.h> #include <netinet/in.h> -/* Hash table containing all the nodes currently active. */ -#define CACHESIZE 512 +/* Hash table containing all the nodes currently active. + XXX Was 512, however, a prime is much nice for the hash + function. 509 is nice as not only is it prime, it keeps + the array within a page or two */ +#define CACHESIZE 509 static struct node *nodehash [CACHESIZE]; /* Compute and return a hash key for NFS file handle DATA of LEN bytes. */ @@ -44,7 +47,8 @@ hash (int *data, size_t len) /* Lookup the file handle P (length LEN) in the hash table. If it is not present, initialize a new node structure and insert it into the hash table. Whichever course, a new reference is generated and the - node is returned in *NPP. */ + node is returned in *NPP; the lock on the node, (*NPP)->LOCK, is + held. */ void lookup_fhandle (void *p, size_t len, struct node **npp) { @@ -58,7 +62,7 @@ lookup_fhandle (void *p, size_t len, struct node **npp) for (np = nodehash[h]; np; np = np->nn->hnext) { if (np->nn->handle.size != len - || bcmp (np->nn->handle.data, p, len) != 0) + || memcmp (np->nn->handle.data, p, len) != 0) continue; np->references++; @@ -68,9 +72,12 @@ lookup_fhandle (void *p, size_t len, struct node **npp) return; } + /* Could not find it */ nn = malloc (sizeof (struct netnode)); + assert (nn); + nn->handle.size = len; - bcopy (p, nn->handle.data, len); + memcpy (nn->handle.data, p, len); nn->stat_updated = 0; nn->dtrans = NOT_POSSIBLE; nn->dead_dir = 0; @@ -112,8 +119,9 @@ forked_node_delete (any_t arg) }; /* Called by libnetfs when node NP has no more references. (See - <hurd/libnetfs.h> for details. Just clear local state and remove - from the hash table. */ + <hurd/libnetfs.h> for details. Just clear its local state and + remove it from the hash table. Called and expected to leave with + NETFS_NODE_REFCNT_LOCK held. */ void netfs_node_norefs (struct node *np) { @@ -122,6 +130,7 @@ netfs_node_norefs (struct node *np) struct fnd *args; args = malloc (sizeof (struct fnd)); + assert (args); np->references++; spin_unlock (&netfs_node_refcnt_lock); @@ -153,7 +162,7 @@ netfs_node_norefs (struct node *np) /* Change the file handle used for node NP to be the handle at P. Make sure the hash table stays up to date. Return the address - after the hnadle. */ + after the handle. The lock on the node should be held. */ int * recache_handle (int *p, struct node *np) { @@ -165,14 +174,17 @@ recache_handle (int *p, struct node *np) else len = ntohl (*p++); + /* Unlink it */ spin_lock (&netfs_node_refcnt_lock); *np->nn->hprevp = np->nn->hnext; if (np->nn->hnext) np->nn->hnext->nn->hprevp = np->nn->hprevp; + /* Change the name */ np->nn->handle.size = len; - bcopy (p, np->nn->handle.data, len); + memcpy (np->nn->handle.data, p, len); + /* Reinsert it */ h = hash (p, len); np->nn->hnext = nodehash[h]; if (np->nn->hnext) @@ -183,4 +195,3 @@ recache_handle (int *p, struct node *np) return p + len / sizeof (int); } - |