Add function descriptions to BlockFileIO

This commit is contained in:
Jakob Unterwurzacher 2014-11-10 23:15:29 +01:00
parent 7565fb149a
commit 1227df72e2

View File

@ -48,6 +48,12 @@ BlockFileIO::~BlockFileIO() {
delete[] _cache.data;
}
/**
* Serve a read request for the size of one block or less,
* at block-aligned offsets.
* Always requests full blocks form the lower layer, truncates the
* returned data as neccessary.
*/
ssize_t BlockFileIO::cacheReadOneBlock(const IORequest &req) const {
// we can satisfy the request even if _cache.dataLen is too short, because
// we always request a full block during reads..
@ -88,6 +94,13 @@ bool BlockFileIO::cacheWriteOneBlock(const IORequest &req) {
return ok;
}
/**
* Serve a read request of arbitrary size at an arbitrary offset.
* Stitches together multiple blocks to serve large requests, drops
* data from the front of the first block if the request is not aligned.
* Always requests aligned data of the size of one block or less from the
* lower layer.
*/
ssize_t BlockFileIO::read(const IORequest &req) const {
rAssert(_blockSize != 0);
@ -97,7 +110,7 @@ ssize_t BlockFileIO::read(const IORequest &req) const {
if (partialOffset == 0 && req.dataLen <= _blockSize) {
// read completely within a single block -- can be handled as-is by
// readOneBloc().
// readOneBlock().
return cacheReadOneBlock(req);
} else {
size_t size = req.dataLen;