On Tue, May 14, 2019 at 1:30 PM Vojtech Juranek <vjuranek(a)redhat.com> wrote:
> Two tests are marked as expected failure (xfail):
> - write_resource() - not sure how sanlock can succeed with wrong sector
> size - this may be a bug.
I looked on it little bit and it seems to me that this is caused by the
fact
that sanlock doesn't read/write any single block during resource
initialization. Other calls read or write single block during the call and
eventually fail if the sector size is invalid, e.g. if wrong sector size
is
provided during lockspace initialization, it fails when writing leader
record
[1]. However, in case of resource, it writes not only leader record, but
(probably for efficiency) includes also request record and writes
everything
in once [2], so it doesn't fail even when sector size if wrong (as it's
not
used for writing).
If the align is correct, and the block size is not, and sanlock is writing
at once
the entire resource (which is always aligned to 4k) it will probably always
succeed.
It think the main issue is creating a resource that we will fail to use
later. I think
sanlock should check the actual block size (at least for block storage) and
fail
the operation if the block size is not correct.
It would be best if sanlock also fallback to detection using actual read()
if getting
the block size fail using ioctl() - this is how qemu detect the block size:
https://github.com/qemu/qemu/blob/e329ad2ab72c43b56df88b34954c2c7d839bb37...
However, IMHO this still can be an issue when creating buffer to be written
[3], possibly can result into corrupted data. I did a simple tests
when
the
resource was initialized with wrong size and read with correct size, but
it
works, I'm not very sure if this is real issue or not.
Nir, please let me know if I should investigate further.
Lets see what David thinks.