summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2000-01-16 14:05:00 +0000
committerMark Kettenis <kettenis@gnu.org>2000-01-16 14:05:00 +0000
commit7a0d1e344904291f5f48ddbc4fbb501f76f15ea0 (patch)
treee642041fd9d718a77c6a0d707fe47049d574d2aa
parent48fb9bd3a3ccfc0377a5d5015dbe7a0bae6eeafc (diff)
2000-01-16 Mark Kettenis <kettenis@gnu.org>
* pager.c (file_pager_write_page): Lock NODE->dn->alloc_lock before accessing NODE->allocsize. Fixes Debian bug #40302.
-rw-r--r--ext2fs/pager.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/ext2fs/pager.c b/ext2fs/pager.c
index 8981390e..bf57d9ed 100644
--- a/ext2fs/pager.c
+++ b/ext2fs/pager.c
@@ -367,12 +367,17 @@ file_pager_write_page (struct node *node, vm_offset_t offset, void *buf)
{
error_t err = 0;
struct pending_blocks pb;
- struct rwlock *lock = 0;
+ struct rwlock *lock = &node->dn->alloc_lock;
block_t block;
int left = vm_page_size;
pending_blocks_init (&pb, buf);
+ /* Holding NODE->dn->alloc_lock effectively locks NODE->allocsize,
+ at least for the cases we care about: pager_unlock_page,
+ diskfs_grow and diskfs_truncate. */
+ rwlock_reader_lock (&node->dn->alloc_lock);
+
if (offset >= node->allocsize)
left = 0;
else if (offset + left > node->allocsize)
@@ -396,8 +401,7 @@ file_pager_write_page (struct node *node, vm_offset_t offset, void *buf)
if (!err)
pending_blocks_write (&pb);
- if (lock)
- rwlock_reader_unlock (lock);
+ rwlock_reader_unlock (&node->dn->alloc_lock);
return err;
}