[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 33/61: ext2fs: cache the superblock
From: |
Samuel Thibault |
Subject: |
[hurd] 33/61: ext2fs: cache the superblock |
Date: |
Tue, 27 May 2014 08:32:12 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 134b450cb65b1986c78e0b292cff78c2f1882a2b
Author: Justus Winter <address@hidden>
Date: Thu Apr 24 17:44:14 2014 +0200
ext2fs: cache the superblock
Previously, the superblock was mmaped and a pointer stored in sblock
by map_hypermetadata. This memory is backed by our disk pager.
This is rather unfortunate, as this means that whenever we read a
value from that location, we might generate a request our disk pager.
This amplifies the so-called thread-storm problem.
Rather than relying on a mmaped region of memory, just use the data
loaded by get_hypermetadata.
* ext2fs/hyper.c (get_hypermetadata): Do not free sblock.
(mapped_sblock): New variable.
(map_hypermetadata): Map the superblock to mapped_sblock instead.
(diskfs_set_hypermetadata): Copy superblock into mapped_superblock.
* ext2fs/ext2fs.h (get_hypermetadata, map_hypermetadata): Adjust
comments accordingly.
---
ext2fs/ext2fs.h | 8 ++++++--
ext2fs/hyper.c | 19 +++++++++++--------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/ext2fs/ext2fs.h b/ext2fs/ext2fs.h
index e01d1a5..3422af2 100644
--- a/ext2fs/ext2fs.h
+++ b/ext2fs/ext2fs.h
@@ -297,10 +297,14 @@ unsigned log2_stat_blocks_per_fs_block;
/* A handy page of page-aligned zeros. */
vm_address_t zeroblock;
-/* Get the superblock from the disk, & setup various global info from it. */
+/* Get the superblock from the disk, point `sblock' to it, and setup
+ various global info from it. */
void get_hypermetadata ();
-/* Map `sblock' and `group_desc_image' pointers to disk cache. */
+/* Map `group_desc_image' pointers to disk cache. Also, establish a
+ non-exported mapping to the superblock that will be used by
+ diskfs_set_hypermetadata to update the superblock from the cache
+ `sblock' points to. */
void map_hypermetadata ();
/* ---------------------------------------------------------------- */
diff --git a/ext2fs/hyper.c b/ext2fs/hyper.c
index 5bcc2ab..5f288bf 100644
--- a/ext2fs/hyper.c
+++ b/ext2fs/hyper.c
@@ -61,7 +61,9 @@ get_hypermetadata (void)
error_t err;
size_t read = 0;
- assert (! sblock);
+ if (sblock != NULL)
+ munmap (sblock, SBLOCK_SIZE);
+
err = store_read (store, SBLOCK_OFFS >> store->log2_block_size,
SBLOCK_SIZE, (void **)&sblock, &read);
if (err || read != SBLOCK_SIZE)
@@ -161,19 +163,19 @@ get_hypermetadata (void)
zeroblock = (vm_address_t) mmap (0, block_size, PROT_READ, MAP_ANON, 0,
0);
assert (zeroblock != (vm_address_t) MAP_FAILED);
}
-
- munmap (sblock, SBLOCK_SIZE);
- sblock = NULL;
}
+static struct ext2_super_block *mapped_sblock;
+
void
map_hypermetadata (void)
{
- sblock = (struct ext2_super_block *) boffs_ptr (SBLOCK_OFFS);
+ mapped_sblock = (struct ext2_super_block *) boffs_ptr (SBLOCK_OFFS);
/* Cache a convenient pointer to the block group descriptors for allocation.
These are stored in the filesystem blocks following the superblock. */
- group_desc_image = (struct ext2_group_desc *) bptr (bptr_block (sblock) + 1);
+ group_desc_image =
+ (struct ext2_group_desc *) bptr (bptr_block (mapped_sblock) + 1);
}
error_t
@@ -196,8 +198,9 @@ diskfs_set_hypermetadata (int wait, int clean)
if (sblock_dirty)
{
sblock_dirty = 0;
- disk_cache_block_ref_ptr (sblock);
- record_global_poke (sblock);
+ memcpy (mapped_sblock, sblock, SBLOCK_SIZE);
+ disk_cache_block_ref_ptr (mapped_sblock);
+ record_global_poke (mapped_sblock);
}
sync_global (wait);
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 21/61: libports: work around bugs in server termination, (continued)
- [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, 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 <=
- [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
- [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