diff options
author | Roland McGrath <roland@gnu.org> | 2001-04-15 22:30:07 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2001-04-15 22:30:07 +0000 |
commit | 2f7f90ce15cce79ef83a8d273e3a27b5b527c7d7 (patch) | |
tree | 09a6e59e3a04367a3b6de603743852cef8bfdcc8 /tmpfs/node.c | |
parent | 01a41bf0c6cb18922a5b6a3d7fd8bd4cfdd18368 (diff) |
2001-04-15 Neal H Walfield <neal@cs.uml.edu>
* dir.c (diskfs_get_directs): Total rewrite.
(diskfs_lookup_hard): Likewise.
(diskfs_enter_hard): Count node size in the size of the dirent so
diskfs_get_directs does not have to guess; this is only a few
bytes different. Check the amount of space correctly, i.e.
we cannot compare bytes and pages.
* node.c: (diskfs_free_node): We already hold
diskfs_node_refcnt_lock; do not try to lock it again.
(diskfs_cached_lookup): Use diskfs_nref, that is why we have it.
Link the nodes correctly.
(diskfs_set_translator): Add or remove S_IPTRANS from
np->dn_stat.st_mode as appropriate.
(diskfs_truncate): Set the new np->dn_stat.st_size.
(diskfs_grow): Move the assert up.
Diffstat (limited to 'tmpfs/node.c')
-rw-r--r-- | tmpfs/node.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/tmpfs/node.c b/tmpfs/node.c index 92768ee8..cfaa2d90 100644 --- a/tmpfs/node.c +++ b/tmpfs/node.c @@ -74,10 +74,8 @@ diskfs_free_node (struct node *np, mode_t mode) free (np->dn); np->dn = 0; - spin_lock (&diskfs_node_refcnt_lock); --num_files; tmpfs_space_used -= sizeof *np->dn; - spin_unlock (&diskfs_node_refcnt_lock); } void @@ -150,31 +148,36 @@ recompute_blocks (struct node *np) st->st_blocks = (st->st_blocks + 511) / 512; } +/* Fetch inode INUM, set *NPP to the node structure; + gain one user reference and lock the node. */ error_t diskfs_cached_lookup (int inum, struct node **npp) { struct disknode *dn = (void *) inum; struct node *np; + assert (npp); + if (dn->hprevp != 0) /* There is already a node. */ { np = *dn->hprevp; assert (np->dn == dn); assert (*dn->hprevp == np); - spin_lock (&diskfs_node_refcnt_lock); - np->references++; - spin_unlock (&diskfs_node_refcnt_lock); + + diskfs_nref (np); } else + /* Create the new node. */ { struct stat *st; - /* Create the new node. */ np = diskfs_make_node (dn); np->cache_id = (ino_t) dn; spin_lock (&diskfs_node_refcnt_lock); dn->hnext = all_nodes; + if (dn->hnext) + dn->hnext->dn->hprevp = &dn->hnext; dn->hprevp = &all_nodes; all_nodes = np; spin_unlock (&diskfs_node_refcnt_lock); @@ -303,6 +306,7 @@ diskfs_set_translator (struct node *np, { free (np->dn->trans); new = 0; + np->dn_stat.st_mode &= ~S_IPTRANS; } else { @@ -310,6 +314,7 @@ diskfs_set_translator (struct node *np, if (new == 0) return ENOSPC; memcpy (new, name, namelen); + np->dn_stat.st_mode |= S_IPTRANS; } adjust_used (namelen - np->dn->translen); np->dn->trans = new; @@ -400,6 +405,7 @@ diskfs_truncate (struct node *np, off_t size) adjust_used (size - np->allocsize); np->dn_stat.st_blocks += (size - np->allocsize) / 512; + np->dn_stat.st_size = size; np->allocsize = size; return 0; @@ -412,11 +418,11 @@ diskfs_truncate (struct node *np, off_t size) error_t diskfs_grow (struct node *np, off_t size, struct protid *cred) { + assert (np->dn->type == DT_REG); + if (np->allocsize >= size) return 0; - assert (np->dn->type == DT_REG); - size = round_page (size); if (round_page (tmpfs_space_used + size) / vm_page_size > tmpfs_page_limit) return ENOSPC; |