[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 27/61: ext2fs: improve diskfs_node_iterate
From: |
Samuel Thibault |
Subject: |
[hurd] 27/61: ext2fs: improve diskfs_node_iterate |
Date: |
Tue, 27 May 2014 08:32:11 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 85f3757d3ce0e9700cd647420e0257b69b91b9e9
Author: Justus Winter <address@hidden>
Date: Tue Apr 29 18:28:22 2014 +0200
ext2fs: improve diskfs_node_iterate
Currently, diskfs_node_iterate iterates twice over all nodes in the
cache. The first time only to determine the number of nodes currently
in the cache. Simply count them instead.
* ext2fs/inode.c (nodehash_nr_items): New variable.
(diskfs_cached_lookup): Increment nodehash_nr_items.
(diskfs_node_norefs): Decrement nodehash_nr_items.
(diskfs_node_iterate): Fix the type of num_nodes, use nodehash_nr_items.
---
ext2fs/inode.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/ext2fs/inode.c b/ext2fs/inode.c
index e75c63f..ed78265 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. */
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 16/61: build: Remove configure check for libcrypt., (continued)
- [hurd] 16/61: build: Remove configure check for libcrypt., Samuel Thibault, 2014/05/27
- [hurd] 28/61: fatfs: improve diskfs_node_iterate, Samuel Thibault, 2014/05/27
- [hurd] 26/61: fatfs: simplify expression, Samuel Thibault, 2014/05/27
- [hurd] 29/61: tmpfs: improve diskfs_node_iterate, Samuel Thibault, 2014/05/27
- [hurd] 07/61: libports: fix notify_port_t receiver lookups, Samuel Thibault, 2014/05/27
- [hurd] 14/61: libpager: fix notify_port_t receiver lookups, Samuel Thibault, 2014/05/27
- [hurd] 34/61: libihash: reduce the default maximum load factor to 75%, Samuel Thibault, 2014/05/27
- [hurd] 17/61: Add TODO about fork() making rpctrace emit an error, Samuel Thibault, 2014/05/27
- [hurd] 33/61: ext2fs: cache the superblock, Samuel Thibault, 2014/05/27
- [hurd] 35/61: libihash: fix type of max_load, Samuel Thibault, 2014/05/27
- [hurd] 27/61: ext2fs: improve diskfs_node_iterate,
Samuel Thibault <=
- [hurd] 39/61: trans/fakeroot: remove spurious semicolon, Samuel Thibault, 2014/05/27
- [hurd] 36/61: libihash: use an integer hash function on the keys, Samuel Thibault, 2014/05/27
- [hurd] 41/61: trans/fakeroot: use C99-style struct initialization, Samuel Thibault, 2014/05/27
- [hurd] 40/61: trans/fakeroot: fix comparison between signed and unsigned, Samuel Thibault, 2014/05/27
- [hurd] 32/61: fatfs: use two distinct pager buckets for the disk and file pager, Samuel Thibault, 2014/05/27
- [hurd] 24/61: ext2fs: simplify expression, Samuel Thibault, 2014/05/27
- [hurd] 47/61: include: install refcount.h, Samuel Thibault, 2014/05/27
- [hurd] 50/61: exec: add missing includes, Samuel Thibault, 2014/05/27
- [hurd] 23/61: ext2fs: fix type of inum, Samuel Thibault, 2014/05/27
- [hurd] 22/61: exec: abbreviate the task name if necessary, Samuel Thibault, 2014/05/27