Skip to content
  • Kevin Wolf's avatar
    5dbd0ce1
    file-posix: Fix alignment after reopen changing O_DIRECT · 5dbd0ce1
    Kevin Wolf authored
    
    
    At the end of a reopen, we already call bdrv_refresh_limits(), which
    should update bs->request_alignment according to the new file
    descriptor. However, raw_probe_alignment() relies on s->needs_alignment
    and just uses 1 if it isn't set. We neglected to update this field, so
    starting with cache=writeback and then reopening with cache=none means
    that we get an incorrect bs->request_alignment == 1 and unaligned
    requests fail instead of being automatically aligned.
    
    Fix this by recalculating s->needs_alignment in raw_refresh_limits()
    before calling raw_probe_alignment().
    
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    Message-Id: <20211104113109.56336-1-kwolf@redhat.com>
    Reviewed-by: default avatarHanna Reitz <hreitz@redhat.com>
    Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    Message-Id: <20211115145409.176785-13-kwolf@redhat.com>
    [hreitz: Fix iotest 142 for block sizes greater than 512 by operating on
             a file with a size of 1 MB]
    Signed-off-by: default avatarHanna Reitz <hreitz@redhat.com>
    Message-Id: <20211116101431.105252-1-hreitz@redhat.com>
    5dbd0ce1
    file-posix: Fix alignment after reopen changing O_DIRECT
    Kevin Wolf authored
    
    
    At the end of a reopen, we already call bdrv_refresh_limits(), which
    should update bs->request_alignment according to the new file
    descriptor. However, raw_probe_alignment() relies on s->needs_alignment
    and just uses 1 if it isn't set. We neglected to update this field, so
    starting with cache=writeback and then reopening with cache=none means
    that we get an incorrect bs->request_alignment == 1 and unaligned
    requests fail instead of being automatically aligned.
    
    Fix this by recalculating s->needs_alignment in raw_refresh_limits()
    before calling raw_probe_alignment().
    
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    Message-Id: <20211104113109.56336-1-kwolf@redhat.com>
    Reviewed-by: default avatarHanna Reitz <hreitz@redhat.com>
    Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    Message-Id: <20211115145409.176785-13-kwolf@redhat.com>
    [hreitz: Fix iotest 142 for block sizes greater than 512 by operating on
             a file with a size of 1 MB]
    Signed-off-by: default avatarHanna Reitz <hreitz@redhat.com>
    Message-Id: <20211116101431.105252-1-hreitz@redhat.com>
Loading