[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 29/61: tmpfs: improve diskfs_node_iterate
From: |
Samuel Thibault |
Subject: |
[hurd] 29/61: tmpfs: 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 151133a33c18e9ba103cea77a269b56c6f5cf23a
Author: Justus Winter <address@hidden>
Date: Wed Apr 30 02:08:41 2014 +0200
tmpfs: improve diskfs_node_iterate
Currently, diskfs_node_iterate iterates twice over all nodes. The
first time only to determine the number of nodes. Simply count them
instead.
* tmpfs/node.c (all_nodes_nr_items): New variable.
(diskfs_free_node): Decrement all_nodes_nr_items.
(diskfs_node_norefs): Likewise.
(diskfs_cached_lookup): Increment all_nodes_nr_items.
(diskfs_node_iterate): Fix type of sum_nodes, use all_nodes_nr_items.
---
tmpfs/node.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/tmpfs/node.c b/tmpfs/node.c
index bc0ad64..acc029a 100644
--- a/tmpfs/node.c
+++ b/tmpfs/node.c
@@ -30,6 +30,7 @@ unsigned int num_files;
static unsigned int gen;
struct node *all_nodes;
+static size_t all_nodes_nr_items;
error_t
diskfs_alloc_node (struct node *dp, mode_t mode, struct node **npp)
@@ -77,6 +78,7 @@ diskfs_free_node (struct node *np, mode_t mode)
*np->dn->hprevp = np->dn->hnext;
if (np->dn->hnext != 0)
np->dn->hnext->dn->hprevp = np->dn->hprevp;
+ all_nodes_nr_items -= 1;
free (np->dn);
np->dn = 0;
@@ -120,6 +122,7 @@ diskfs_node_norefs (struct node *np)
*np->dn->hprevp = np->dn->hnext;
if (np->dn->hnext != 0)
np->dn->hnext->dn->hprevp = np->dn->hprevp;
+ all_nodes_nr_items -= 1;
np->dn->hnext = 0;
np->dn->hprevp = 0;
}
@@ -186,6 +189,7 @@ diskfs_cached_lookup (ino_t inum, struct node **npp)
dn->hnext->dn->hprevp = &dn->hnext;
dn->hprevp = &all_nodes;
all_nodes = np;
+ all_nodes_nr_items += 1;
pthread_spin_unlock (&diskfs_node_refcnt_lock);
st = &np->dn_stat;
@@ -222,7 +226,7 @@ error_t
diskfs_node_iterate (error_t (*fun) (struct node *))
{
error_t err = 0;
- unsigned int num_nodes = 0;
+ size_t num_nodes;
struct node *node, **node_list, **p;
pthread_spin_lock (&diskfs_node_refcnt_lock);
@@ -233,8 +237,7 @@ diskfs_node_iterate (error_t (*fun) (struct node *))
diskfs_node_refcnt_lock, but we can't hold this while locking the
individual node locks). */
- for (node = all_nodes; node != 0; node = node->dn->hnext)
- num_nodes++;
+ num_nodes = all_nodes_nr_items;
p = node_list = alloca (num_nodes * sizeof (struct node *));
for (node = all_nodes; node != 0; node = node->dn->hnext)
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 03/61: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd, (continued)
- [hurd] 03/61: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd, Samuel Thibault, 2014/05/27
- [hurd] 19/61: Add missing receiver lookup fix, Samuel Thibault, 2014/05/27
- [hurd] 13/61: libpager: fix notify_port_t receiver lookups, Samuel Thibault, 2014/05/27
- [hurd] 20/61: libdiskfs: set the default sync interval to 30 seconds, Samuel Thibault, 2014/05/27
- [hurd] 12/61: console: fix notify_port_t receiver lookups, Samuel Thibault, 2014/05/27
- [hurd] 21/61: libports: work around bugs in server termination, Samuel Thibault, 2014/05/27
- [hurd] 18/61: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd, Samuel Thibault, 2014/05/27
- [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 <=
- [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, 2014/05/27
- [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