summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-04-29 18:32:47 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-04-29 18:32:47 +0200
commit8367c755713a92130926e80d19b7df4539b279f6 (patch)
tree8e80c09bd2ca3de7244f0894a48f345c8d3b841b
parentbf66d60c6ecc0d930b2a1df30995ed9cdb871275 (diff)
add ext2fs-improve-diskfs_node_iterate.patch
-rw-r--r--debian/patches/ext2fs-improve-diskfs_node_iterate.patch65
-rw-r--r--debian/patches/series1
2 files changed, 66 insertions, 0 deletions
diff --git a/debian/patches/ext2fs-improve-diskfs_node_iterate.patch b/debian/patches/ext2fs-improve-diskfs_node_iterate.patch
new file mode 100644
index 00000000..7c13875a
--- /dev/null
+++ b/debian/patches/ext2fs-improve-diskfs_node_iterate.patch
@@ -0,0 +1,65 @@
+commit 32b44fe56dab88f63df72bd15b8e0e57be756b2e
+Author: Justus Winter <4winter@informatik.uni-hamburg.de>
+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.
+
+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. */
diff --git a/debian/patches/series b/debian/patches/series
index cad0ebe1..8662284c 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -45,4 +45,5 @@ ext2fs-two-pagers.patch
#ext2fs-cache-superblock.patch
libpager-singlethreaded.patch
libpager-drop-seqnos.patch
+ext2fs-improve-diskfs_node_iterate.patch
xxx-fix-build-paper-over-gnumach-bug.patch