liblightnvm
liblightnvm copied to clipboard
vblk: Reading granularity issue
vblk will send administrative read commands for a predefined number of sectors regardless of the actual number of sectors to be read.
https://github.com/OpenChannelSSD/liblightnvm/blob/master/src/nvm_vblk.c#L575
const size_t cmd_nsectr = vblk->flags & NVM_CMD_VECTOR ? NVM_NADDR_MAX : WS_OPT;
Assume that I have a chunk with 6144 sectors and I want to read only the last sector. This should not be a problem, as the read granularity is a single sector. However, due to the code above, vblk sends read commands for 64 or 24 sectors (on my device). This causes the read to fail, as many of the sectors are out of bounds.
The function above also assumes that reads have to be aligned to the optimal write granularity, which is not ideal.