diff options
Diffstat (limited to 'ext2fs/inode.c')
-rw-r--r-- | ext2fs/inode.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/ext2fs/inode.c b/ext2fs/inode.c index e75c63f9..ed782657 100644 --- a/ext2fs/inode.c +++ b/ext2fs/inode.c @@ -47,6 +47,7 @@ #endif static struct node *nodehash[INOHSZ]; +static size_t nodehash_nr_items; static error_t read_node (struct node *np); @@ -106,6 +107,7 @@ diskfs_cached_lookup (ino_t inum, struct node **npp) dn->hnext->dn->hprevp = &dn->hnext; dn->hprevp = &nodehash[INOHASH(inum)]; nodehash[INOHASH(inum)] = np; + nodehash_nr_items += 1; pthread_spin_unlock (&diskfs_node_refcnt_lock); @@ -159,6 +161,7 @@ diskfs_node_norefs (struct node *np) *np->dn->hprevp = np->dn->hnext; if (np->dn->hnext) np->dn->hnext->dn->hprevp = np->dn->hprevp; + nodehash_nr_items -= 1; if (np->dn->dirents) free (np->dn->dirents); @@ -549,7 +552,8 @@ error_t diskfs_node_iterate (error_t (*fun)(struct node *)) { error_t err = 0; - int n, num_nodes = 0; + int n; + size_t num_nodes; struct node *node, **node_list, **p; pthread_spin_lock (&diskfs_node_refcnt_lock); @@ -559,10 +563,7 @@ diskfs_node_iterate (error_t (*fun)(struct node *)) during processing (normally we delegate access to hash-table with diskfs_node_refcnt_lock, but we can't hold this while locking the individual node locks). */ - - for (n = 0; n < INOHSZ; n++) - for (node = nodehash[n]; node; node = node->dn->hnext) - num_nodes++; + num_nodes = nodehash_nr_items; /* TODO This method doesn't scale beyond a few dozen nodes and should be replaced. */ |