K 10
svn:author
V 6
iulius
K 8
svn:date
V 27
2008-11-29T11:07:02.863356Z
K 7
svn:log
V 1345
Allow the use of buffers larger than 2 GB with buffindexed.

Patch from Kirill Berezin.


Idea of the patch:

  if (mmapwrite(ovbuff->fd, &ovindexhead, sizeof(OVINDEXHEAD),
      ovbuff->base + ov.blocknum * OV_BLOCKSIZE) != sizeof(OVINDEXHEAD)) {

This is a part of current ovsetcurindexblock function.  Third argument is
the offset from the beginning of buffer:  ovbuff->base is off_t and
ov.blocknum is unsigned int.  For the case of INN compiled without
--enable-largefiles it works fine, but in other case the size of off_t
is 8 bytes and unsigned int still uses 4 bytes.

Now say we have a 5Gb buffer, which is roughly equal to 625000 8000 byte
blocks, and we are going to access to block # 620000 that is equal to
offset of 4960000000 bytes, or about at very end of the buffer.  BUT C
standard does not require to cast all parts of statement to type of
argument with longest size before calculation of result, instead is
requires a cast of arguments of current operation only.
As a result, because multiplication is operation with higher priority
and the size of blocknum is 4 bytes and constant have no size hints, we
will have an offset somewhere in the beginning of buffer instead of very
end of it.
To resolve such a limitation, a macro (OV_OFFSET) now calculates the
offset (changing blocknum type to off_t instead of unsigned int).

END
