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:
Augustin Cavalier 2024-10-17 16:27:53 -04:00
parent 6260a00f00
commit 5f4e982ea8

View File

@ -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();
}