kernel: finish work of removing interruptible mutexes

This commit is contained in:
Matheus
2024-12-24 21:30:25 -03:00
parent 48643c4868
commit a6c169e5e6
42 changed files with 169 additions and 169 deletions
+6 -6
View File
@@ -21,7 +21,7 @@ static uintmax_t currentinode;
static vfsops_t vfsops;
static vops_t vnops;
#define INTERNAL_LOCK(v) MUTEX_ACQUIRE(&(v)->lock, false)
#define INTERNAL_LOCK(v) MUTEX_ACQUIRE(&(v)->lock)
#define INTERNAL_UNLOCK(v) MUTEX_RELEASE(&(v)->lock);
static int devfs_mount(vfs_t **vfs, vnode_t *mountpoint, vnode_t *backing, void *data) {
@@ -112,7 +112,7 @@ int devfs_lookup(vnode_t *node, char *name, vnode_t **result, cred_t *cred) {
void *v;
INTERNAL_LOCK(node);
MUTEX_ACQUIRE(&tablelock, false);
MUTEX_ACQUIRE(&tablelock);
int error = hashtable_get(&devnode->children, &v, name, strlen(name));
MUTEX_RELEASE(&tablelock);
if (error) {
@@ -518,7 +518,7 @@ int devfs_register(devops_t *devops, char *name, int type, int major, int minor,
int key[2] = {major, minor};
MUTEX_ACQUIRE(&tablelock, false);
MUTEX_ACQUIRE(&tablelock);
int error = hashtable_set(&devtable, master, key, sizeof(key), true);
MUTEX_RELEASE(&tablelock);
if (error) {
@@ -550,7 +550,7 @@ int devfs_register(devops_t *devops, char *name, int type, int major, int minor,
VOP_RELEASE(dir);
if (error) {
MUTEX_ACQUIRE(&tablelock, false);
MUTEX_ACQUIRE(&tablelock);
__assert(hashtable_remove(&devtable, key, sizeof(key) == 0));
MUTEX_RELEASE(&tablelock);
slab_free(nodecache, master);
@@ -570,7 +570,7 @@ int devfs_register(devops_t *devops, char *name, int type, int major, int minor,
// allocate a pointer node to the master node associated with device major and minor
int devfs_getnode(vnode_t *physical, int major, int minor, vnode_t **node) {
int key[2] = {major, minor};
MUTEX_ACQUIRE(&tablelock, false);
MUTEX_ACQUIRE(&tablelock);
void *r;
int err = hashtable_get(&devtable, &r, key, sizeof(key));
MUTEX_RELEASE(&tablelock);
@@ -596,7 +596,7 @@ int devfs_getnode(vnode_t *physical, int major, int minor, vnode_t **node) {
void devfs_remove(char *name, int major, int minor) {
int key[2] = {major, minor};
// remove devtable reference
MUTEX_ACQUIRE(&tablelock, false);
MUTEX_ACQUIRE(&tablelock);
__assert(hashtable_remove(&devtable, key, sizeof(key)) == 0);
MUTEX_RELEASE(&tablelock);
+13 -13
View File
@@ -176,7 +176,7 @@ typedef uint32_t blockptr_t;
#define ASSERT_UNCLEAN(fs, x) \
if (!(x)) { \
printf("ext2: assert %s on line %d on function %s failed. setting filesystem as unclean\n", #x, __LINE__, __func__); \
MUTEX_ACQUIRE(&fs->superblocklock, false); \
MUTEX_ACQUIRE(&fs->superblocklock); \
fs->superblock.state = SB_STATE_UNCLEAN; \
syncsuperblock(fs); \
MUTEX_RELEASE(&fs->superblocklock); \
@@ -219,7 +219,7 @@ static int syncsuperblock(ext2fs_t *fs) {
}
static int changedircount(ext2fs_t *fs, int bg, int change) {
MUTEX_ACQUIRE(&fs->descriptorlock, false);
MUTEX_ACQUIRE(&fs->descriptorlock);
blockgroupdesc_t desc;
size_t count;
int e = vfs_read(fs->backing, &desc, sizeof(blockgroupdesc_t), DESC_GETDISKOFFSET(fs, bg), &count, 0);
@@ -237,7 +237,7 @@ static int changedircount(ext2fs_t *fs, int bg, int change) {
// allocates either a block or an inode
static int allocatestructure(ext2fs_t *fs, uintmax_t *retid, bool inode) {
MUTEX_ACQUIRE(&fs->descriptorlock, false);
MUTEX_ACQUIRE(&fs->descriptorlock);
uint8_t *bm = NULL;
uintmax_t bg = inode ? fs->lowestfreeinodebg : fs->lowestfreeblockbg;
@@ -331,7 +331,7 @@ static int allocatestructure(ext2fs_t *fs, uintmax_t *retid, bool inode) {
*retid = structurefound;
// update superblock unallocated structure count
MUTEX_ACQUIRE(&fs->superblocklock, false);
MUTEX_ACQUIRE(&fs->superblocklock);
if (inode)
fs->superblock.unallocatedinodes -= 1;
else
@@ -353,7 +353,7 @@ static int freestructure(ext2fs_t *fs, uintmax_t id, bool inode) {
int e = 0;
uint8_t *bm = NULL;
int bg = inode ? INODE_GETGROUP(fs, id) : BLOCK_GETGROUP(fs, id);
MUTEX_ACQUIRE(&fs->descriptorlock, false);
MUTEX_ACQUIRE(&fs->descriptorlock);
blockgroupdesc_t desc;
size_t readc;
@@ -407,7 +407,7 @@ static int freestructure(ext2fs_t *fs, uintmax_t id, bool inode) {
}
// update superblock unallocated structure count
MUTEX_ACQUIRE(&fs->superblocklock, false);
MUTEX_ACQUIRE(&fs->superblocklock);
if (inode)
fs->superblock.unallocatedinodes += 1;
else
@@ -455,7 +455,7 @@ static int writeinode(ext2fs_t *fs, inode_t *buffer, int inode) {
if (count != sizeof(blockgroupdesc_t))
return EIO;
MUTEX_ACQUIRE(&fs->inodewritelock, false);
MUTEX_ACQUIRE(&fs->inodewritelock);
// write inode from buffer
e = vfs_write(fs->backing, buffer, sizeof(inode_t), INODE_GETDISKOFFSET(fs, BLOCK_GETDISKOFFSET(fs, desc.inodetable), inode), &count, 0);
MUTEX_RELEASE(&fs->inodewritelock);
@@ -1189,7 +1189,7 @@ static int ext2_lookup(vnode_t *vnode, char *name, vnode_t **result, cred_t *cre
if (err)
goto cleanup;
MUTEX_ACQUIRE(&fs->inodetablelock, false);
MUTEX_ACQUIRE(&fs->inodetablelock);
void *tablev;
// check if it isn't already in the inode table
@@ -1501,7 +1501,7 @@ static int internalcreate(vnode_t *parent, char *name, vattr_t *attr, int type,
if (err)
goto cleanup;
MUTEX_ACQUIRE(&fs->inodetablelock, false);
MUTEX_ACQUIRE(&fs->inodetablelock);
err = hashtable_set(&fs->inodetable, newnode, &newnode->id, sizeof(newnode->id), true);
MUTEX_RELEASE(&fs->inodetablelock);
ASSERT_UNCLEAN(fs, err == 0);
@@ -1591,7 +1591,7 @@ static int ext2_munmap(vnode_t *node, void *addr, uintmax_t offset, int flags, c
static int handleinodeunlink(ext2fs_t *fs, ext2node_t *node, int inode, ext2node_t *known) {
bool isdir = false;
void *v;
MUTEX_ACQUIRE(&fs->inodetablelock, false);
MUTEX_ACQUIRE(&fs->inodetablelock);
int err = hashtable_get(&fs->inodetable, &v, &inode, sizeof(inode));
if (err == ENOENT) {
__assert(known == NULL);
@@ -1805,7 +1805,7 @@ static int ext2_sync(vnode_t *vnode) {
}
static int ext2_lock(vnode_t *vnode) {
MUTEX_ACQUIRE(&vnode->lock, false);
MUTEX_ACQUIRE(&vnode->lock);
return 0;
}
@@ -1828,7 +1828,7 @@ static int ext2_inactive(vnode_t *vnode) {
} else {
// the node does not have any more links on the file system nor references and
// we should free it completely from the filesystem.
MUTEX_ACQUIRE(&fs->inodetablelock, false);
MUTEX_ACQUIRE(&fs->inodetablelock);
__assert(hashtable_remove(&fs->inodetable, &node->id, sizeof(node->id)) == 0);
MUTEX_RELEASE(&fs->inodetablelock);
@@ -1845,7 +1845,7 @@ static int ext2_inactive(vnode_t *vnode) {
static int ext2_root(vfs_t *vfs, vnode_t **vnodep) {
ext2fs_t *fs = (ext2fs_t *)vfs;
int err = 0;
MUTEX_ACQUIRE(&fs->rootlock, false);
MUTEX_ACQUIRE(&fs->rootlock);
if (fs->root) {
*vnodep = &fs->root->vnode;
goto leave;
+8 -8
View File
@@ -71,7 +71,7 @@ static int growtable(int newcount) {
file_t *fd_get(int fd) {
proc_t *proc = current_thread()->proc;
MUTEX_ACQUIRE(&proc->fdmutex, false);
MUTEX_ACQUIRE(&proc->fdmutex);
file_t *file = fd < proc->fdcount ? proc->fd[fd].file : NULL;
if (file)
@@ -85,7 +85,7 @@ file_t *fd_get(int fd) {
int fd_setflags(int fd, int flags) {
int error = 0;
proc_t *proc = current_thread()->proc;
MUTEX_ACQUIRE(&proc->fdmutex, false);
MUTEX_ACQUIRE(&proc->fdmutex);
if (proc->fd[fd].file)
proc->fd[fd].flags = flags;
@@ -99,7 +99,7 @@ int fd_setflags(int fd, int flags) {
int fd_getflags(int fd, int *flags) {
int error = 0;
proc_t *proc = current_thread()->proc;
MUTEX_ACQUIRE(&proc->fdmutex, false);
MUTEX_ACQUIRE(&proc->fdmutex);
if (proc->fd[fd].file)
*flags = proc->fd[fd].flags;
@@ -120,7 +120,7 @@ int fd_new(int flags, file_t **rfile, int *rfd) {
return ENOMEM;
proc_t *proc = current_thread()->proc;
MUTEX_ACQUIRE(&proc->fdmutex, false);
MUTEX_ACQUIRE(&proc->fdmutex);
// find first free fd
int fd = getfree(proc->fdfirst);
@@ -149,7 +149,7 @@ int fd_new(int flags, file_t **rfile, int *rfd) {
int fd_close(int fd) {
proc_t *proc = current_thread()->proc;
MUTEX_ACQUIRE(&proc->fdmutex, false);
MUTEX_ACQUIRE(&proc->fdmutex);
file_t *file = fd < proc->fdcount ? proc->fd[fd].file : NULL;
if (file) {
@@ -173,7 +173,7 @@ int fd_close(int fd) {
int fd_clone(proc_t *targproc) {
proc_t *proc = current_thread()->proc;
int error = 0;
MUTEX_ACQUIRE(&proc->fdmutex, false);
MUTEX_ACQUIRE(&proc->fdmutex);
targproc->fdcount = proc->fdcount;
targproc->fdfirst = proc->fdfirst;
@@ -199,7 +199,7 @@ int fd_clone(proc_t *targproc) {
int fd_insert(file_t *file, int *fdp) {
proc_t *proc = current_thread()->proc;
int err = 0;
MUTEX_ACQUIRE(&proc->fdmutex, false);
MUTEX_ACQUIRE(&proc->fdmutex);
int fd = getfree(0);
if (fd == -1) {
@@ -226,7 +226,7 @@ int fd_dup(int oldfd, int newfd, bool exact, int fdflags, int *retfd) {
if (newfd < 0 || newfd >= FDTABLE_LIMIT)
return EBADF;
MUTEX_ACQUIRE(&proc->fdmutex, false);
MUTEX_ACQUIRE(&proc->fdmutex);
file_t *file = oldfd < proc->fdcount ? proc->fd[oldfd].file : NULL;
if (file == NULL) {
+1 -1
View File
@@ -17,7 +17,7 @@ static uintmax_t currentinode;
static vops_t vnops;
#define INTERNAL_LOCK(v) MUTEX_ACQUIRE(&(v)->lock, false)
#define INTERNAL_LOCK(v) MUTEX_ACQUIRE(&(v)->lock)
#define INTERNAL_UNLOCK(v) MUTEX_RELEASE(&(v)->lock)
int pipefs_close(vnode_t *node, int flags, cred_t *cred) {
+1 -1
View File
@@ -13,7 +13,7 @@
static scache_t *nodecache;
static uintmax_t currentinode;
#define INTERNAL_LOCK(v) MUTEX_ACQUIRE(&(v)->lock, false)
#define INTERNAL_LOCK(v) MUTEX_ACQUIRE(&(v)->lock)
#define INTERNAL_UNLOCK(v) MUTEX_RELEASE(&(v)->lock)
int sockfs_open(vnode_t **node, int flags, cred_t *cred) {
+1 -1
View File
@@ -503,7 +503,7 @@ static int tmpfs_sync(vnode_t *node) {
}
static int tmpfs_lock(vnode_t *node) {
MUTEX_ACQUIRE(&node->lock, false);
MUTEX_ACQUIRE(&node->lock);
return 0;
}
+3 -3
View File
@@ -243,7 +243,7 @@ int vfs_write_iovec(vnode_t *node, iovec_iterator_t *iovec_iterator, size_t size
goto leave;
}
MUTEX_ACQUIRE(&node->size_lock, false);
MUTEX_ACQUIRE(&node->size_lock);
vattr_t attr;
VOP_LOCK(node);
@@ -365,7 +365,7 @@ int vfs_read_iovec(vnode_t *node, iovec_iterator_t *iovec_iterator, size_t size,
size_t nodesize = 0;
MUTEX_ACQUIRE(&node->size_lock, false);
MUTEX_ACQUIRE(&node->size_lock);
if (node->type == V_TYPE_REGULAR) {
vattr_t attr;
VOP_LOCK(node);
@@ -837,7 +837,7 @@ int vfs_lookup(vnode_t **result, vnode_t *start, char *path, char *lastcomp, int
vnode_t *derefstart = current;
if (*linkderef == '/' && current_thread() && current_thread()->proc) {
MUTEX_ACQUIRE(&current_thread()->proc->mutex, false);
MUTEX_ACQUIRE(&current_thread()->proc->mutex);
derefstart = current_thread()->proc->root;
VOP_HOLD(derefstart);
MUTEX_RELEASE(&current_thread()->proc->mutex);