Commit 294682cc authored by Andrey Shinkevich's avatar Andrey Shinkevich Committed by Eric Blake
Browse files

block: workaround for unaligned byte range in fallocate()



Revert the commit 118f9944 'block/io.c: fix for the allocation failure'
and use better error handling for file systems that do not support
fallocate() for an unaligned byte range. Allow falling back to pwrite
in case fallocate() returns EINVAL.

Suggested-by: default avatarKevin Wolf <kwolf@redhat.com>
Suggested-by: default avatarEric Blake <eblake@redhat.com>
Signed-off-by: default avatarAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Reviewed-by: default avatarDenis V. Lunev <den@openvz.org>
Message-Id: <1566913973-15490-1-git-send-email-andrey.shinkevich@virtuozzo.com>
Signed-off-by: default avatarEric Blake <eblake@redhat.com>
parent 5de47735
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1588,6 +1588,13 @@ static int handle_aiocb_write_zeroes(void *opaque)
    if (s->has_write_zeroes) {
        int ret = do_fallocate(s->fd, FALLOC_FL_ZERO_RANGE,
                               aiocb->aio_offset, aiocb->aio_nbytes);
        if (ret == -EINVAL) {
            /*
             * Allow falling back to pwrite for file systems that
             * do not support fallocate() for an unaligned byte range.
             */
            return -ENOTSUP;
        }
        if (ret == 0 || ret != -ENOTSUP) {
            return ret;
        }
+1 −1
Original line number Diff line number Diff line
@@ -1746,7 +1746,7 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
            assert(!bs->supported_zero_flags);
        }

        if (ret < 0 && !(flags & BDRV_REQ_NO_FALLBACK)) {
        if (ret == -ENOTSUP && !(flags & BDRV_REQ_NO_FALLBACK)) {
            /* Fall back to bounce buffer if write zeroes is unsupported */
            BdrvRequestFlags write_flags = flags & ~BDRV_REQ_ZERO_WRITE;