fs: fix some sync locking issues

This commit is contained in:
Matheus
2024-09-18 19:04:59 -03:00
parent 7460e8b707
commit 947623b5f6
2 changed files with 6 additions and 0 deletions
+2
View File
@@ -1771,7 +1771,9 @@ static int ext2_sync(vnode_t *vnode) {
int e = vmmcache_syncvnode(vnode, 0, UINT64_MAX);
ext2fs_t *fs = (ext2fs_t *)vnode->vfs;
// 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);
VOP_UNLOCK(fs->backing);
// only the first errors are reported
return e ? e : e2;
}
+4
View File
@@ -215,11 +215,13 @@ static int writenocache(vnode_t *node, page_t *page, uintmax_t pageoffset) {
// don't keep the pages in the cache!
// if its a file, do the proper filesystem sync.
// if its a block device, sync only the page we just dirtied
VOP_LOCK(node);
int e;
if (node->type == V_TYPE_REGULAR)
e = VOP_SYNC(node);
else
e = vmmcache_syncvnode(node, pageoffset, PAGE_SIZE);
VOP_UNLOCK(node);
// try to turn it into anonymous memory
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);
void *address = MAKE_HHDM(pmm_getpageaddress(page));
memcpy((void *)((uintptr_t)address + startoffset), buffer, writesize);
vmmcache_makedirty(page);
*written += writesize;
pageoffset += 1;