lock: merge spinlock and mtx locks into one
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
3e5abada9b
commit
2076f1dae1
32 changed files with 158 additions and 169 deletions
|
|
@ -52,19 +52,18 @@ int dirent_populate_children(dirent_t *dir)
|
|||
kfree(dents);
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
{
|
||||
list_item_t *item = inode->dirents.head;
|
||||
while (item) {
|
||||
dirent_t *dent = item->ptr;
|
||||
list_item_t *next = item->next;
|
||||
list_remove(item);
|
||||
if (dent->inode)
|
||||
inode_dec_ref(dent->inode);
|
||||
dirent_free(dent);
|
||||
item = next;
|
||||
}
|
||||
cleanup: {
|
||||
list_item_t *item = inode->dirents.head;
|
||||
while (item) {
|
||||
dirent_t *dent = item->ptr;
|
||||
list_item_t *next = item->next;
|
||||
list_remove(item);
|
||||
if (dent->inode)
|
||||
inode_dec_ref(dent->inode);
|
||||
dirent_free(dent);
|
||||
item = next;
|
||||
}
|
||||
}
|
||||
list_unlock(&inode->dirents);
|
||||
write_unlock(&inode->rwlock);
|
||||
kfree(dents);
|
||||
|
|
@ -162,21 +161,21 @@ void inode_dec_ref(inode_t *inode)
|
|||
|
||||
void dirent_inc_ref(dirent_t *dent)
|
||||
{
|
||||
spinlock_acquire(&dent->lock);
|
||||
spin_lock(&dent->lock);
|
||||
dent->refcount += 1;
|
||||
spinlock_release(&dent->lock);
|
||||
spin_unlock(&dent->lock);
|
||||
}
|
||||
|
||||
void dirent_dec_ref(dirent_t *dent)
|
||||
{
|
||||
spinlock_acquire(&dent->lock);
|
||||
spin_lock(&dent->lock);
|
||||
if (dent->refcount == 0) {
|
||||
spinlock_release(&dent->lock);
|
||||
spin_unlock(&dent->lock);
|
||||
return;
|
||||
}
|
||||
dent->refcount -= 1;
|
||||
bool freed = (dent->refcount == 0);
|
||||
spinlock_release(&dent->lock);
|
||||
spin_unlock(&dent->lock);
|
||||
|
||||
if (freed) {
|
||||
inode_dec_ref(dent->inode);
|
||||
|
|
|
|||
Loading…
Reference in a new issue