mirror of
https://review.haiku-os.org/haiku
synced 2024-11-23 07:18:40 +01:00
kernel/cache: Acquire store references in PrecacheIO.
If the file in question is deleted while we are performing asynchronous I/O, and there is nothing else left with a reference to it, then the underlying vnode could wind up getting deleted from under us, since the cache does not maintain a reference to the store unless there are active mappings (areas) associated with the cache. Should fix #19122. At least, I couldn't find any other places that performed asynchronous I/O without properly acquiring and releasing references to the underlying vnode besides this one.
This commit is contained in:
parent
6260a00f00
commit
5f4e982ea8
2
src/system/kernel/cache/file_cache.cpp
vendored
2
src/system/kernel/cache/file_cache.cpp
vendored
@ -128,6 +128,7 @@ PrecacheIO::PrecacheIO(file_cache_ref* ref, off_t offset, generic_size_t size)
|
||||
{
|
||||
fPageCount = (size + B_PAGE_SIZE - 1) / B_PAGE_SIZE;
|
||||
fCache->AcquireRefLocked();
|
||||
fCache->AcquireStoreRef();
|
||||
}
|
||||
|
||||
|
||||
@ -135,6 +136,7 @@ PrecacheIO::~PrecacheIO()
|
||||
{
|
||||
delete[] fPages;
|
||||
delete[] fVecs;
|
||||
fCache->ReleaseStoreRef();
|
||||
fCache->ReleaseRefLocked();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user