summaryrefslogtreecommitdiff
path: root/ext2fs
diff options
context:
space:
mode:
Diffstat (limited to 'ext2fs')
-rw-r--r--ext2fs/Makefile3
-rw-r--r--ext2fs/balloc.c32
-rw-r--r--ext2fs/dir.c8
-rw-r--r--ext2fs/ext2fs.c4
-rw-r--r--ext2fs/ext2fs.h18
-rw-r--r--ext2fs/ialloc.c24
-rw-r--r--ext2fs/inode.c34
-rw-r--r--ext2fs/msg.c19
-rw-r--r--ext2fs/pager.c66
-rw-r--r--ext2fs/pokel.c22
-rw-r--r--ext2fs/storeinfo.c4
-rw-r--r--ext2fs/truncate.c12
12 files changed, 125 insertions, 121 deletions
diff --git a/ext2fs/Makefile b/ext2fs/Makefile
index 8e16ebe6..983dbee3 100644
--- a/ext2fs/Makefile
+++ b/ext2fs/Makefile
@@ -23,7 +23,8 @@ target = ext2fs
SRCS = balloc.c dir.c ext2fs.c getblk.c hyper.c ialloc.c \
inode.c pager.c pokel.c truncate.c storeinfo.c msg.c xinl.c
OBJS = $(SRCS:.c=.o)
-HURDLIBS = diskfs pager iohelp fshelp store threads ports ihash shouldbeinlibc
+HURDLIBS = diskfs pager iohelp fshelp store ports ihash shouldbeinlibc
+OTHERLIBS = -lpthread
include ../Makeconf
diff --git a/ext2fs/balloc.c b/ext2fs/balloc.c
index 7fe82ba0..b2d2eab9 100644
--- a/ext2fs/balloc.c
+++ b/ext2fs/balloc.c
@@ -63,14 +63,14 @@ ext2_free_blocks (block_t block, unsigned long count)
unsigned long i;
struct ext2_group_desc *gdp;
- spin_lock (&global_lock);
+ pthread_spin_lock (&global_lock);
if (block < sblock->s_first_data_block ||
(block + count) > sblock->s_blocks_count)
{
ext2_error ("freeing blocks not in datazone - "
"block = %u, count = %lu", block, count);
- spin_unlock (&global_lock);
+ pthread_spin_unlock (&global_lock);
return;
}
@@ -122,7 +122,7 @@ ext2_free_blocks (block_t block, unsigned long count)
sblock_dirty = 1;
- spin_unlock (&global_lock);
+ pthread_spin_unlock (&global_lock);
alloc_sync (0);
}
@@ -149,7 +149,7 @@ ext2_new_block (block_t goal,
static int goal_hits = 0, goal_attempts = 0;
#endif
- spin_lock (&global_lock);
+ pthread_spin_lock (&global_lock);
#ifdef XXX /* Auth check to use reserved blocks */
if (sblock->s_free_blocks_count <= sblock->s_r_blocks_count &&
@@ -157,7 +157,7 @@ ext2_new_block (block_t goal,
(sb->u.ext2_sb.s_resgid == 0 ||
!in_group_p (sb->u.ext2_sb.s_resgid))))
{
- spin_unlock (&global_lock);
+ pthread_spin_unlock (&global_lock);
return 0;
}
#endif
@@ -264,7 +264,7 @@ repeat:
}
if (k >= groups_count)
{
- spin_unlock (&global_lock);
+ pthread_spin_unlock (&global_lock);
return 0;
}
bh = bptr (gdp->bg_block_bitmap);
@@ -278,7 +278,7 @@ repeat:
if (j >= sblock->s_blocks_per_group)
{
ext2_error ("free blocks count corrupted for block group %d", i);
- spin_unlock (&global_lock);
+ pthread_spin_unlock (&global_lock);
return 0;
}
@@ -312,9 +312,9 @@ got_block:
block is being allocated to a file (see pager.c). */
if (modified_global_blocks)
{
- spin_lock (&modified_global_blocks_lock);
+ pthread_spin_lock (&modified_global_blocks_lock);
clear_bit (tmp, modified_global_blocks);
- spin_unlock (&modified_global_blocks_lock);
+ pthread_spin_unlock (&modified_global_blocks_lock);
}
ext2_debug ("found bit %d", j);
@@ -337,9 +337,9 @@ got_block:
/* (See comment before the clear_bit above) */
if (modified_global_blocks)
{
- spin_lock (&modified_global_blocks_lock);
+ pthread_spin_lock (&modified_global_blocks_lock);
clear_bit (tmp + k, modified_global_blocks);
- spin_unlock (&modified_global_blocks_lock);
+ pthread_spin_unlock (&modified_global_blocks_lock);
}
}
gdp->bg_free_blocks_count -= *prealloc_count;
@@ -369,7 +369,7 @@ got_block:
sblock_dirty = 1;
sync_out:
- spin_unlock (&global_lock);
+ pthread_spin_unlock (&global_lock);
alloc_sync (0);
return j;
@@ -383,7 +383,7 @@ ext2_count_free_blocks ()
struct ext2_group_desc *gdp;
int i;
- spin_lock (&global_lock);
+ pthread_spin_lock (&global_lock);
desc_count = 0;
bitmap_count = 0;
@@ -399,7 +399,7 @@ ext2_count_free_blocks ()
}
printf ("ext2_count_free_blocks: stored = %u, computed = %lu, %lu",
sblock->s_free_blocks_count, desc_count, bitmap_count);
- spin_unlock (&global_lock);
+ pthread_spin_unlock (&global_lock);
return bitmap_count;
#else
return sblock->s_free_blocks_count;
@@ -422,7 +422,7 @@ ext2_check_blocks_bitmap ()
struct ext2_group_desc *gdp;
int i, j;
- spin_lock (&global_lock);
+ pthread_spin_lock (&global_lock);
desc_count = 0;
bitmap_count = 0;
@@ -489,5 +489,5 @@ ext2_check_blocks_bitmap ()
ext2_error ("wrong free blocks count in super block,"
" stored = %lu, counted = %lu",
(unsigned long) sblock->s_free_blocks_count, bitmap_count);
- spin_unlock (&global_lock);
+ pthread_spin_unlock (&global_lock);
}
diff --git a/ext2fs/dir.c b/ext2fs/dir.c
index 714c1b7c..3a3e648d 100644
--- a/ext2fs/dir.c
+++ b/ext2fs/dir.c
@@ -278,9 +278,9 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type,
/* Drop what we *thought* was .. (but isn't any more) and
try *again*. */
diskfs_nput (np);
- mutex_unlock (&dp->lock);
+ pthread_mutex_unlock (&dp->lock);
err = diskfs_cached_lookup (inum, &np);
- mutex_lock (&dp->lock);
+ pthread_mutex_lock (&dp->lock);
if (err)
goto out;
retry_dotdot = inum;
@@ -293,9 +293,9 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type,
/* Lock them in the proper order, and then
repeat the directory scan to see if this is still
right. */
- mutex_unlock (&dp->lock);
+ pthread_mutex_unlock (&dp->lock);
err = diskfs_cached_lookup (inum, &np);
- mutex_lock (&dp->lock);
+ pthread_mutex_lock (&dp->lock);
if (err)
goto out;
retry_dotdot = inum;
diff --git a/ext2fs/ext2fs.c b/ext2fs/ext2fs.c
index 0857a749..993f1997 100644
--- a/ext2fs/ext2fs.c
+++ b/ext2fs/ext2fs.c
@@ -193,7 +193,7 @@ main (int argc, char **argv)
ext2_panic ("can't get root: %s", strerror (err));
else if ((diskfs_root_node->dn_stat.st_mode & S_IFMT) == 0)
ext2_panic ("no root node!");
- mutex_unlock (&diskfs_root_node->lock);
+ pthread_mutex_unlock (&diskfs_root_node->lock);
/* Now that we are all set up to handle requests, and diskfs_root_node is
set properly, it is safe to export our fsys control port to the
@@ -201,7 +201,7 @@ main (int argc, char **argv)
diskfs_startup_diskfs (bootstrap, 0);
/* and so we die, leaving others to do the real work. */
- cthread_exit (0);
+ pthread_exit (NULL);
/* NOTREACHED */
return 0;
}
diff --git a/ext2fs/ext2fs.h b/ext2fs/ext2fs.h
index 2ad4a9df..52bf2b19 100644
--- a/ext2fs/ext2fs.h
+++ b/ext2fs/ext2fs.h
@@ -25,7 +25,7 @@
#include <hurd/iohelp.h>
#include <hurd/diskfs.h>
#include <assert.h>
-#include <rwlock.h>
+#include <pthread.h>
#include <sys/mman.h>
#define __hurd__ /* Enable some hurd-specific fields. */
@@ -80,7 +80,7 @@ struct poke
struct pokel
{
struct poke *pokes, *free_pokes;
- spin_lock_t lock;
+ pthread_spinlock_t lock;
struct pager *pager;
void *image;
};
@@ -161,7 +161,7 @@ struct disknode
struct node *hnext, **hprevp;
/* Lock to lock while fiddling with this inode's block allocation info. */
- struct rwlock alloc_lock;
+ pthread_rwlock_t alloc_lock;
/* Where changes to our indirect blocks are added. */
struct pokel indir_pokel;
@@ -268,9 +268,9 @@ unsigned long groups_count; /* Number of groups in the fs */
/* ---------------------------------------------------------------- */
-spin_lock_t node_to_page_lock;
+pthread_spinlock_t node_to_page_lock;
-spin_lock_t generation_lock;
+pthread_spinlock_t generation_lock;
unsigned long next_generation;
/* ---------------------------------------------------------------- */
@@ -335,7 +335,7 @@ void inode_init (void);
/* What to lock if changing global data data (e.g., the superblock or block
group descriptors or bitmaps). */
-spin_lock_t global_lock;
+pthread_spinlock_t global_lock;
/* Where to record such changes. */
struct pokel global_pokel;
@@ -344,7 +344,7 @@ struct pokel global_pokel;
record which disk blocks are actually modified, so we don't stomp on parts
of the disk which are backed by file pagers. */
char *modified_global_blocks;
-spin_lock_t modified_global_blocks_lock;
+pthread_spinlock_t modified_global_blocks_lock;
extern int global_block_modified (block_t block);
extern void record_global_poke (void *ptr);
@@ -364,9 +364,9 @@ global_block_modified (block_t block)
if (modified_global_blocks)
{
int was_clean;
- spin_lock (&modified_global_blocks_lock);
+ pthread_spin_lock (&modified_global_blocks_lock);
was_clean = !set_bit(block, modified_global_blocks);
- spin_unlock (&modified_global_blocks_lock);
+ pthread_spin_unlock (&modified_global_blocks_lock);
return was_clean;
}
else
diff --git a/ext2fs/ialloc.c b/ext2fs/ialloc.c
index 15c17a4e..aa018d94 100644
--- a/ext2fs/ialloc.c
+++ b/ext2fs/ialloc.c
@@ -62,12 +62,12 @@ diskfs_free_node (struct node *np, mode_t old_mode)
ext2_debug ("freeing inode %u", inum);
- spin_lock (&global_lock);
+ pthread_spin_lock (&global_lock);
if (inum < EXT2_FIRST_INO (sblock) || inum > sblock->s_inodes_count)
{
ext2_error ("reserved inode or nonexistent inode: %Ld", inum);
- spin_unlock (&global_lock);
+ pthread_spin_unlock (&global_lock);
return;
}
@@ -92,7 +92,7 @@ diskfs_free_node (struct node *np, mode_t old_mode)
}
sblock_dirty = 1;
- spin_unlock (&global_lock);
+ pthread_spin_unlock (&global_lock);
alloc_sync(0);
}
@@ -116,7 +116,7 @@ ext2_alloc_inode (ino_t dir_inum, mode_t mode)
struct ext2_group_desc *gdp;
struct ext2_group_desc *tmp;
- spin_lock (&global_lock);
+ pthread_spin_lock (&global_lock);
repeat:
gdp = NULL;
@@ -209,7 +209,7 @@ repeat:
if (!gdp)
{
- spin_unlock (&global_lock);
+ pthread_spin_unlock (&global_lock);
return 0;
}
@@ -254,7 +254,7 @@ repeat:
sblock_dirty = 1;
sync_out:
- spin_unlock (&global_lock);
+ pthread_spin_unlock (&global_lock);
alloc_sync (0);
return inum;
@@ -323,12 +323,12 @@ diskfs_alloc_node (struct node *dir, mode_t mode, struct node **node)
/*
* Set up a new generation number for this inode.
*/
- spin_lock (&generation_lock);
+ pthread_spin_lock (&generation_lock);
sex = diskfs_mtime->seconds;
if (++next_generation < (u_long)sex)
next_generation = sex;
st->st_gen = next_generation;
- spin_unlock (&generation_lock);
+ pthread_spin_unlock (&generation_lock);
alloc_sync (np);
@@ -346,7 +346,7 @@ ext2_count_free_inodes ()
struct ext2_group_desc *gdp;
int i;
- spin_lock (&global_lock);
+ pthread_spin_lock (&global_lock);
desc_count = 0;
bitmap_count = 0;
@@ -363,7 +363,7 @@ ext2_count_free_inodes ()
}
ext2_debug ("stored = %u, computed = %lu, %lu",
sblock->s_free_inodes_count, desc_count, bitmap_count);
- spin_unlock (&global_lock);
+ pthread_spin_unlock (&global_lock);
return desc_count;
#else
return sblock->s_free_inodes_count;
@@ -379,7 +379,7 @@ ext2_check_inodes_bitmap ()
struct ext2_group_desc *gdp;
unsigned long desc_count, bitmap_count, x;
- spin_lock (&global_lock);
+ pthread_spin_lock (&global_lock);
desc_count = 0;
bitmap_count = 0;
@@ -401,5 +401,5 @@ ext2_check_inodes_bitmap ()
"stored = %lu, counted = %lu",
(unsigned long) sblock->s_free_inodes_count, bitmap_count);
- spin_unlock (&global_lock);
+ pthread_spin_unlock (&global_lock);
}
diff --git a/ext2fs/inode.c b/ext2fs/inode.c
index 2da8a95e..2c442795 100644
--- a/ext2fs/inode.c
+++ b/ext2fs/inode.c
@@ -50,7 +50,7 @@ static struct node *nodehash[INOHSZ];
static error_t read_node (struct node *np);
-spin_lock_t generation_lock = SPIN_LOCK_INITIALIZER;
+pthread_spinlock_t generation_lock = PTHREAD_SPINLOCK_INITIALIZER;
/* Initialize the inode hash table. */
void
@@ -70,13 +70,13 @@ diskfs_cached_lookup (ino_t inum, struct node **npp)
struct node *np;
struct disknode *dn;
- spin_lock (&diskfs_node_refcnt_lock);
+ pthread_spin_lock (&diskfs_node_refcnt_lock);
for (np = nodehash[INOHASH(inum)]; np; np = np->dn->hnext)
if (np->cache_id == inum)
{
np->references++;
- spin_unlock (&diskfs_node_refcnt_lock);
- mutex_lock (&np->lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_mutex_lock (&np->lock);
*npp = np;
return 0;
}
@@ -85,20 +85,20 @@ diskfs_cached_lookup (ino_t inum, struct node **npp)
dn = malloc (sizeof (struct disknode));
if (! dn)
{
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
return ENOMEM;
}
dn->dirents = 0;
dn->dir_idx = 0;
dn->pager = 0;
- rwlock_init (&dn->alloc_lock);
+ pthread_rwlock_init (&dn->alloc_lock, NULL);
pokel_init (&dn->indir_pokel, diskfs_disk_pager, disk_image);
/* Create the new node. */
np = diskfs_make_node (dn);
np->cache_id = inum;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
/* Put NP in NODEHASH. */
dn->hnext = nodehash[INOHASH(inum)];
@@ -107,18 +107,18 @@ diskfs_cached_lookup (ino_t inum, struct node **npp)
dn->hprevp = &nodehash[INOHASH(inum)];
nodehash[INOHASH(inum)] = np;
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
/* Get the contents of NP off disk. */
err = read_node (np);
if (!diskfs_check_readonly () && !np->dn_stat.st_gen)
{
- spin_lock (&generation_lock);
+ pthread_spin_lock (&generation_lock);
if (++next_generation < diskfs_mtime->seconds)
next_generation = diskfs_mtime->seconds;
np->dn_stat.st_gen = next_generation;
- spin_unlock (&generation_lock);
+ pthread_spin_unlock (&generation_lock);
np->dn_set_ctime = 1;
}
@@ -138,14 +138,14 @@ ifind (ino_t inum)
{
struct node *np;
- spin_lock (&diskfs_node_refcnt_lock);
+ pthread_spin_lock (&diskfs_node_refcnt_lock);
for (np = nodehash[INOHASH(inum)]; np; np = np->dn->hnext)
{
if (np->cache_id != inum)
continue;
assert (np->references);
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
return np;
}
assert (0);
@@ -540,7 +540,7 @@ diskfs_node_iterate (error_t (*fun)(struct node *))
int n, num_nodes = 0;
struct node *node, **node_list, **p;
- spin_lock (&diskfs_node_refcnt_lock);
+ pthread_spin_lock (&diskfs_node_refcnt_lock);
/* We must copy everything from the hash table into another data structure
to avoid running into any problems with the hash-table being modified
@@ -557,7 +557,7 @@ diskfs_node_iterate (error_t (*fun)(struct node *))
node_list = malloc (num_nodes * sizeof (struct node *));
if (node_list == NULL)
{
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
ext2_debug ("unable to allocate temporary node table");
return ENOMEM;
}
@@ -570,7 +570,7 @@ diskfs_node_iterate (error_t (*fun)(struct node *))
node->references++;
}
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
p = node_list;
while (num_nodes-- > 0)
@@ -578,9 +578,9 @@ diskfs_node_iterate (error_t (*fun)(struct node *))
node = *p++;
if (!err)
{
- mutex_lock (&node->lock);
+ pthread_mutex_lock (&node->lock);
err = (*fun)(node);
- mutex_unlock (&node->lock);
+ pthread_mutex_unlock (&node->lock);
}
diskfs_nrele (node);
}
diff --git a/ext2fs/msg.c b/ext2fs/msg.c
index 727d926d..83939b06 100644
--- a/ext2fs/msg.c
+++ b/ext2fs/msg.c
@@ -23,16 +23,17 @@
#include "ext2fs.h"
-struct mutex printf_lock = MUTEX_INITIALIZER; /* XXX */
+pthread_mutex_t printf_lock = PTHREAD_MUTEX_INITIALIZER; /* XXX */
+
int printf (const char *fmt, ...)
{
va_list arg;
int done;
va_start (arg, fmt);
- mutex_lock (&printf_lock);
+ pthread_mutex_lock (&printf_lock);
done = vprintf (fmt, arg);
- mutex_unlock (&printf_lock);
+ pthread_mutex_unlock (&printf_lock);
va_end (arg);
return done;
}
@@ -43,7 +44,7 @@ void _ext2_error (const char * function, const char * fmt, ...)
{
va_list args;
- mutex_lock(&printf_lock);
+ pthread_mutex_lock (&printf_lock);
va_start (args, fmt);
vsprintf (error_buf, fmt, args);
@@ -51,14 +52,14 @@ void _ext2_error (const char * function, const char * fmt, ...)
fprintf (stderr, "ext2fs: %s: %s: %s\n", diskfs_disk_name, function, error_buf);
- mutex_unlock(&printf_lock);
+ pthread_mutex_unlock (&printf_lock);
}
void _ext2_panic (const char * function, const char * fmt, ...)
{
va_list args;
- mutex_lock(&printf_lock);
+ pthread_mutex_lock (&printf_lock);
va_start (args, fmt);
vsprintf (error_buf, fmt, args);
@@ -67,7 +68,7 @@ void _ext2_panic (const char * function, const char * fmt, ...)
fprintf(stderr, "ext2fs: %s: panic: %s: %s\n",
diskfs_disk_name, function, error_buf);
- mutex_unlock(&printf_lock);
+ pthread_mutex_unlock (&printf_lock);
exit (1);
}
@@ -76,7 +77,7 @@ void ext2_warning (const char * fmt, ...)
{
va_list args;
- mutex_lock(&printf_lock);
+ pthread_mutex_lock (&printf_lock);
va_start (args, fmt);
vsprintf (error_buf, fmt, args);
@@ -84,5 +85,5 @@ void ext2_warning (const char * fmt, ...)
fprintf (stderr, "ext2fs: %s: warning: %s\n", diskfs_disk_name, error_buf);
- mutex_unlock(&printf_lock);
+ pthread_mutex_unlock (&printf_lock);
}
diff --git a/ext2fs/pager.c b/ext2fs/pager.c
index 0136f9b1..f740434a 100644
--- a/ext2fs/pager.c
+++ b/ext2fs/pager.c
@@ -29,7 +29,8 @@ struct port_bucket *pager_bucket;
/* Mapped image of the disk. */
void *disk_image;
-spin_lock_t node_to_page_lock = SPIN_LOCK_INITIALIZER;
+pthread_spinlock_t node_to_page_lock = PTHREAD_SPINLOCK_INITIALIZER;
+
#ifdef DONT_CACHE_MEMORY_OBJECTS
#define MAY_CACHE 0
@@ -42,7 +43,7 @@ spin_lock_t node_to_page_lock = SPIN_LOCK_INITIALIZER;
#ifdef STATS
struct ext2fs_pager_stats
{
- spin_lock_t lock;
+ pthread_spinlock_t lock;
unsigned long disk_pageins;
unsigned long disk_pageouts;
@@ -58,12 +59,13 @@ struct ext2fs_pager_stats
unsigned long file_grows;
};
-static struct ext2fs_pager_stats ext2s_pager_stats;
+static struct ext2fs_pager_stats ext2s_pager_stats =
+ { .lock = PTHREAD_SPINLOCK_INITIALIZER };
#define STAT_INC(field) \
-do { spin_lock (&ext2s_pager_stats.lock); \
+do { pthread_spin_lock (&ext2s_pager_stats.lock); \
ext2s_pager_stats.field++; \
- spin_unlock (&ext2s_pager_stats.lock); } while (0)
+ pthread_spin_unlock (&ext2s_pager_stats.lock); } while (0)
#else /* !STATS */
#define STAT_INC(field) /* nop */0
@@ -75,12 +77,12 @@ do { spin_lock (&ext2s_pager_stats.lock); \
static void *
get_page_buf ()
{
- static struct mutex free_page_bufs_lock = MUTEX_INITIALIZER;
+ static pthread_mutex_t free_page_bufs_lock = PTHREAD_MUTEX_INITIALIZER;
static void *free_page_bufs;
static int num_free_page_bufs;
void *buf;
- mutex_lock (&free_page_bufs_lock);
+ pthread_mutex_lock (&free_page_bufs_lock);
if (num_free_page_bufs > 0)
{
buf = free_page_bufs;
@@ -106,7 +108,7 @@ get_page_buf ()
}
}
- mutex_unlock (&free_page_bufs_lock);
+ pthread_mutex_unlock (&free_page_bufs_lock);
return buf;
}
@@ -124,14 +126,14 @@ free_page_buf (void *buf)
on success otherwise an error code. */
static error_t
find_block (struct node *node, vm_offset_t offset,
- block_t *block, struct rwlock **lock)
+ block_t *block, pthread_rwlock_t **lock)
{
error_t err;
if (!*lock)
{
*lock = &node->dn->alloc_lock;
- rwlock_reader_lock (*lock);
+ pthread_rwlock_rdlock (*lock);
}
if (offset + block_size > node->allocsize)
@@ -158,7 +160,7 @@ file_pager_read_page (struct node *node, vm_offset_t page,
error_t err;
int offs = 0;
int partial = 0; /* A page truncated by the EOF. */
- struct rwlock *lock = NULL;
+ pthread_rwlock_t *lock = NULL;
int left = vm_page_size;
block_t pending_blocks = 0;
int num_pending_blocks = 0;
@@ -271,7 +273,7 @@ file_pager_read_page (struct node *node, vm_offset_t page,
node->dn->last_page_partially_writable = 1;
if (lock)
- rwlock_reader_unlock (lock);
+ pthread_rwlock_unlock (lock);
return err;
}
@@ -365,7 +367,7 @@ file_pager_write_page (struct node *node, vm_offset_t offset, void *buf)
{
error_t err = 0;
struct pending_blocks pb;
- struct rwlock *lock = &node->dn->alloc_lock;
+ pthread_rwlock_t *lock = &node->dn->alloc_lock;
block_t block;
int left = vm_page_size;
@@ -374,7 +376,7 @@ file_pager_write_page (struct node *node, vm_offset_t offset, void *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);
+ pthread_rwlock_rdlock (&node->dn->alloc_lock);
if (offset >= node->allocsize)
left = 0;
@@ -399,7 +401,7 @@ file_pager_write_page (struct node *node, vm_offset_t offset, void *buf)
if (!err)
pending_blocks_write (&pb);
- rwlock_reader_unlock (&node->dn->alloc_lock);
+ pthread_rwlock_unlock (&node->dn->alloc_lock);
return err;
}
@@ -525,7 +527,7 @@ pager_unlock_page (struct user_pager_info *pager, vm_offset_t page)
struct node *node = pager->node;
struct disknode *dn = node->dn;
- rwlock_writer_lock (&dn->alloc_lock);
+ pthread_rwlock_wrlock (&dn->alloc_lock);
partial_page = (page + vm_page_size > node->allocsize);
@@ -567,7 +569,7 @@ pager_unlock_page (struct user_pager_info *pager, vm_offset_t page)
STAT_INC (file_page_unlocks);
- rwlock_writer_unlock (&dn->alloc_lock);
+ pthread_rwlock_unlock (&dn->alloc_lock);
if (err == ENOSPC)
ext2_warning ("This filesystem is out of space, and will now crash. Bye!");
@@ -598,7 +600,7 @@ diskfs_grow (struct node *node, off_t size, struct protid *cred)
block_t new_end_block;
struct disknode *dn = node->dn;
- rwlock_writer_lock (&dn->alloc_lock);
+ pthread_rwlock_wrlock (&dn->alloc_lock);
old_size = node->allocsize;
new_size = round_block (size);
@@ -665,7 +667,7 @@ diskfs_grow (struct node *node, off_t size, struct protid *cred)
node->allocsize = new_size;
- rwlock_writer_unlock (&dn->alloc_lock);
+ pthread_rwlock_unlock (&dn->alloc_lock);
return err;
}
@@ -680,11 +682,11 @@ diskfs_file_update (struct node *node, int wait)
{
struct pager *pager;
- spin_lock (&node_to_page_lock);
+ pthread_spin_lock (&node_to_page_lock);
pager = node->dn->pager;
if (pager)
ports_port_ref (pager);
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
if (pager)
{
@@ -704,11 +706,11 @@ flush_node_pager (struct node *node)
struct pager *pager;
struct disknode *dn = node->dn;
- spin_lock (&node_to_page_lock);
+ pthread_spin_lock (&node_to_page_lock);
pager = dn->pager;
if (pager)
ports_port_ref (pager);
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
if (pager)
{
@@ -745,11 +747,11 @@ pager_clear_user_data (struct user_pager_info *upi)
{
struct pager *pager;
- spin_lock (&node_to_page_lock);
+ pthread_spin_lock (&node_to_page_lock);
pager = upi->node->dn->pager;
if (pager && pager_get_upi (pager) == upi)
upi->node->dn->pager = 0;
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
diskfs_nrele_light (upi->node);
}
@@ -789,7 +791,7 @@ diskfs_get_filemap (struct node *node, vm_prot_t prot)
|| S_ISREG (node->dn_stat.st_mode)
|| (S_ISLNK (node->dn_stat.st_mode)));
- spin_lock (&node_to_page_lock);
+ pthread_spin_lock (&node_to_page_lock);
do
{
struct pager *pager = node->dn->pager;
@@ -820,7 +822,7 @@ diskfs_get_filemap (struct node *node, vm_prot_t prot)
{
diskfs_nrele_light (node);
free (upi);
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
return MACH_PORT_NULL;
}
@@ -829,7 +831,7 @@ diskfs_get_filemap (struct node *node, vm_prot_t prot)
}
}
while (right == MACH_PORT_NULL);
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
mach_port_insert_right (mach_task_self (), right, right,
MACH_MSG_TYPE_MAKE_SEND);
@@ -844,11 +846,11 @@ drop_pager_softrefs (struct node *node)
{
struct pager *pager;
- spin_lock (&node_to_page_lock);
+ pthread_spin_lock (&node_to_page_lock);
pager = node->dn->pager;
if (pager)
ports_port_ref (pager);
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
if (MAY_CACHE && pager)
{
@@ -866,11 +868,11 @@ allow_pager_softrefs (struct node *node)
{
struct pager *pager;
- spin_lock (&node_to_page_lock);
+ pthread_spin_lock (&node_to_page_lock);
pager = node->dn->pager;
if (pager)
ports_port_ref (pager);
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
if (MAY_CACHE && pager)
pager_change_attributes (pager, 1, MEMORY_OBJECT_COPY_DELAY, 0);
diff --git a/ext2fs/pokel.c b/ext2fs/pokel.c
index 85b4d2d1..a8b16c97 100644
--- a/ext2fs/pokel.c
+++ b/ext2fs/pokel.c
@@ -25,7 +25,7 @@
void
pokel_init (struct pokel *pokel, struct pager *pager, void *image)
{
- pokel->lock = SPIN_LOCK_INITIALIZER;
+ pokel->lock = PTHREAD_SPINLOCK_INITIALIZER;
pokel->pokes = NULL;
pokel->free_pokes = NULL;
pokel->pager = pager;
@@ -59,7 +59,7 @@ pokel_add (struct pokel *pokel, void *loc, vm_size_t length)
ext2_debug ("adding %p[%ul] (range 0x%x to 0x%x)", loc, length, offset, end);
- spin_lock (&pokel->lock);
+ pthread_spin_lock (&pokel->lock);
pl = pokel->pokes;
while (pl != NULL)
@@ -97,7 +97,7 @@ pokel_add (struct pokel *pokel, void *loc, vm_size_t length)
pokel->pokes = pl;
}
- spin_unlock (&pokel->lock);
+ pthread_spin_unlock (&pokel->lock);
}
/* Move all pending pokes from POKEL into its free list. If SYNC is true,
@@ -107,10 +107,10 @@ _pokel_exec (struct pokel *pokel, int sync, int wait)
{
struct poke *pl, *pokes, *last = NULL;
- spin_lock (&pokel->lock);
+ pthread_spin_lock (&pokel->lock);
pokes = pokel->pokes;
pokel->pokes = NULL;
- spin_unlock (&pokel->lock);
+ pthread_spin_unlock (&pokel->lock);
for (pl = pokes; pl; last = pl, pl = pl->next)
if (sync)
@@ -121,10 +121,10 @@ _pokel_exec (struct pokel *pokel, int sync, int wait)
if (last)
{
- spin_lock (&pokel->lock);
+ pthread_spin_lock (&pokel->lock);
last->next = pokel->free_pokes;
pokel->free_pokes = pokes;
- spin_unlock (&pokel->lock);
+ pthread_spin_unlock (&pokel->lock);
}
}
@@ -152,13 +152,13 @@ pokel_inherit (struct pokel *pokel, struct pokel *from)
assert (pokel->image == from->image);
/* Take all pokes from FROM... */
- spin_lock (&from->lock);
+ pthread_spin_lock (&from->lock);
pokes = from->pokes;
from->pokes = NULL;
- spin_unlock (&from->lock);
+ pthread_spin_unlock (&from->lock);
/* And put them in POKEL. */
- spin_lock (&pokel->lock);
+ pthread_spin_lock (&pokel->lock);
last = pokel->pokes;
if (last)
{
@@ -168,5 +168,5 @@ pokel_inherit (struct pokel *pokel, struct pokel *from)
}
else
pokel->pokes = pokes;
- spin_unlock (&pokel->lock);
+ pthread_spin_unlock (&pokel->lock);
}
diff --git a/ext2fs/storeinfo.c b/ext2fs/storeinfo.c
index 395ab5ca..5d21b05e 100644
--- a/ext2fs/storeinfo.c
+++ b/ext2fs/storeinfo.c
@@ -45,7 +45,7 @@ diskfs_S_file_get_storage_info (struct protid *cred,
if (! runs)
return ENOMEM;
- mutex_lock (&node->lock);
+ pthread_mutex_lock (&node->lock);
/* NUM_FS_BLOCKS counts down the blocks in the file that we've not
enumerated yet; when it hits zero, we can stop. */
@@ -100,7 +100,7 @@ diskfs_S_file_get_storage_info (struct protid *cred,
run->length += 1 << log2_dev_blocks_per_fs_block;
}
- mutex_unlock (&node->lock);
+ pthread_mutex_unlock (&node->lock);
if (! err)
err = store_clone (store, &file_store);
diff --git a/ext2fs/truncate.c b/ext2fs/truncate.c
index 2058a1c1..37e360bb 100644
--- a/ext2fs/truncate.c
+++ b/ext2fs/truncate.c
@@ -224,11 +224,11 @@ force_delayed_copies (struct node *node, off_t length)
{
struct pager *pager;
- spin_lock (&node_to_page_lock);
+ pthread_spin_lock (&node_to_page_lock);
pager = node->dn->pager;
if (pager)
ports_port_ref (pager);
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
if (pager)
{
@@ -254,11 +254,11 @@ enable_delayed_copies (struct node *node)
{
struct pager *pager;
- spin_lock (&node_to_page_lock);
+ pthread_spin_lock (&node_to_page_lock);
pager = node->dn->pager;
if (pager)
ports_port_ref (pager);
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
if (pager)
{
@@ -317,7 +317,7 @@ diskfs_truncate (struct node *node, off_t length)
force_delayed_copies (node, length);
- rwlock_writer_lock (&node->dn->alloc_lock);
+ pthread_rwlock_wrlock (&node->dn->alloc_lock);
/* Update the size on disk; fsck will finish freeing blocks if necessary
should we crash. */
@@ -363,7 +363,7 @@ diskfs_truncate (struct node *node, off_t length)
/* Now we can permit delayed copies again. */
enable_delayed_copies (node);
- rwlock_writer_unlock (&node->dn->alloc_lock);
+ pthread_rwlock_unlock (&node->dn->alloc_lock);
return err;
}