The filesystem read and write operations call block device drivers strategy() function. The buffer argument of these functions needs to point to a contiguous area of physical memory because eventually the virtual address pointer will be converted to a physical one before being passed to the host layer.
Unfortunately, the logic in the ROFS mount that reads the master block and the i-node table uses regular malloc() to allocate buffers to read to. Everything works fine if the i-node table occupies less than 1 page (4K) on disk. But if it occupies more than 1 page of memory and underlying physical memory is fragmented one can experience errors like the one in the description of issue #1033.
This patch fixes this issue, by changing two malloc() calls with alloc_phys_contiguous_aligned(). In addition, we improve the code by using std::unique_ptr() to let the compiler emit code to automatically call free_phys_contiguous_aligned() in all cases when the rofs_mount() returns.
The filesystem read and write operations call block device drivers
strategy()
function. The buffer argument of these functions needs to point to a contiguous area of physical memory because eventually the virtual address pointer will be converted to a physical one before being passed to the host layer.Unfortunately, the logic in the ROFS mount that reads the master block and the i-node table uses regular
malloc()
to allocate buffers to read to. Everything works fine if the i-node table occupies less than 1 page (4K) on disk. But if it occupies more than 1 page of memory and underlying physical memory is fragmented one can experience errors like the one in the description of issue #1033.This patch fixes this issue, by changing two
malloc()
calls withalloc_phys_contiguous_aligned()
. In addition, we improve the code by usingstd::unique_ptr()
to let the compiler emit code to automatically callfree_phys_contiguous_aligned()
in all cases when therofs_mount()
returns.Fixes #1033