mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
fs: fix some sync locking issues
This commit is contained in:
@@ -1771,7 +1771,9 @@ static int ext2_sync(vnode_t *vnode) {
|
|||||||
int e = vmmcache_syncvnode(vnode, 0, UINT64_MAX);
|
int e = vmmcache_syncvnode(vnode, 0, UINT64_MAX);
|
||||||
ext2fs_t *fs = (ext2fs_t *)vnode->vfs;
|
ext2fs_t *fs = (ext2fs_t *)vnode->vfs;
|
||||||
// TODO don't sync the entire disk but rather only the inodes and blocks
|
// TODO don't sync the entire disk but rather only the inodes and blocks
|
||||||
|
VOP_LOCK(fs->backing);
|
||||||
int e2 = vmmcache_syncvnode(fs->backing, 0, UINT64_MAX);
|
int e2 = vmmcache_syncvnode(fs->backing, 0, UINT64_MAX);
|
||||||
|
VOP_UNLOCK(fs->backing);
|
||||||
// only the first errors are reported
|
// only the first errors are reported
|
||||||
return e ? e : e2;
|
return e ? e : e2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,11 +215,13 @@ static int writenocache(vnode_t *node, page_t *page, uintmax_t pageoffset) {
|
|||||||
// don't keep the pages in the cache!
|
// don't keep the pages in the cache!
|
||||||
// if its a file, do the proper filesystem sync.
|
// if its a file, do the proper filesystem sync.
|
||||||
// if its a block device, sync only the page we just dirtied
|
// if its a block device, sync only the page we just dirtied
|
||||||
|
VOP_LOCK(node);
|
||||||
int e;
|
int e;
|
||||||
if (node->type == V_TYPE_REGULAR)
|
if (node->type == V_TYPE_REGULAR)
|
||||||
e = VOP_SYNC(node);
|
e = VOP_SYNC(node);
|
||||||
else
|
else
|
||||||
e = vmmcache_syncvnode(node, pageoffset, PAGE_SIZE);
|
e = vmmcache_syncvnode(node, pageoffset, PAGE_SIZE);
|
||||||
|
VOP_UNLOCK(node);
|
||||||
|
|
||||||
// try to turn it into anonymous memory
|
// try to turn it into anonymous memory
|
||||||
vmmcache_evict(page);
|
vmmcache_evict(page);
|
||||||
@@ -288,7 +290,9 @@ int vfs_write(vnode_t *node, void *buffer, size_t size, uintmax_t offset, size_t
|
|||||||
|
|
||||||
size_t writesize = min(PAGE_SIZE - startoffset, size);
|
size_t writesize = min(PAGE_SIZE - startoffset, size);
|
||||||
void *address = MAKE_HHDM(pmm_getpageaddress(page));
|
void *address = MAKE_HHDM(pmm_getpageaddress(page));
|
||||||
|
|
||||||
memcpy((void *)((uintptr_t)address + startoffset), buffer, writesize);
|
memcpy((void *)((uintptr_t)address + startoffset), buffer, writesize);
|
||||||
|
|
||||||
vmmcache_makedirty(page);
|
vmmcache_makedirty(page);
|
||||||
*written += writesize;
|
*written += writesize;
|
||||||
pageoffset += 1;
|
pageoffset += 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user