On Wed, Feb 17, 2021 at 08:57:36AM -0600, Eric Blake wrote:
Do you also want to tweak the sentence in nbdkit-truncate-filter.pod
that mentions cache and cow filters?
Fixed in my copy.
> +++ b/filters/cache/blk.c
> int
> blk_set_size (uint64_t new_size)
> {
> - if (bitmap_resize (&bm, new_size) == -1)
> + size = new_size;
> +
> + if (bitmap_resize (&bm, size) == -1)
> return -1;
>
> - if (ftruncate (fd, new_size) == -1) {
> + if (ftruncate (fd, ROUND_UP (size, blksize)) == -1) {
So the underlying fd is aligned...
> nbdkit_error ("ftruncate: %m");
> return -1;
> }
>
> - if (lru_set_size (new_size) == -1)
> + if (lru_set_size (size) == -1)
...while the lru size is still the original size.
My reading of the bitmap_resize function (which is also used by the
LRU code) is that rounds up, so we're OK here. However the bitmap
code _is_ quite complicated ...
Well, the tests pass anyway :-)
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/