From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y85VH-0007YC-KW for qemu-devel@nongnu.org; Mon, 05 Jan 2015 06:07:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y85VB-00036g-Hu for qemu-devel@nongnu.org; Mon, 05 Jan 2015 06:07:19 -0500 Received: from mx2.parallels.com ([199.115.105.18]:33551) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y85VB-00036Z-BR for qemu-devel@nongnu.org; Mon, 05 Jan 2015 06:07:13 -0500 Message-ID: <54AA7059.7050406@openvz.org> Date: Mon, 5 Jan 2015 14:07:05 +0300 From: "Denis V. Lunev" MIME-Version: 1.0 References: <1419931250-19259-1-git-send-email-den@openvz.org> <1419931250-19259-6-git-send-email-den@openvz.org> <20150105065726.GB1800@ad.nay.redhat.com> In-Reply-To: <20150105065726.GB1800@ad.nay.redhat.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 5/8] block/raw-posix: refactor handle_aiocb_write_zeroes a bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , Peter Lieven , qemu-devel@nongnu.org, Stefan Hajnoczi On 05/01/15 09:57, Fam Zheng wrote: > On Tue, 12/30 12:20, Denis V. Lunev wrote: >> move code dealing with a block device to a separate function. This will >> allow to implement additional processing for an ordinary files. > s/an// > >> Pls note, that xfs_code has been moved before checking for >> s->has_write_zeroes as xfs_write_zeroes does not touch this flag inside. >> This makes code a bit more consistent. >> >> Signed-off-by: Denis V. Lunev >> CC: Kevin Wolf >> CC: Stefan Hajnoczi >> CC: Peter Lieven >> --- >> block/raw-posix.c | 60 +++++++++++++++++++++++++++++++++++-------------------- >> 1 file changed, 38 insertions(+), 22 deletions(-) >> >> diff --git a/block/raw-posix.c b/block/raw-posix.c >> index 25a6947..7866d31 100644 >> --- a/block/raw-posix.c >> +++ b/block/raw-posix.c >> @@ -915,46 +915,62 @@ static int do_fallocate(int fd, int mode, off_t offset, off_t len) >> } >> #endif >> >> -static ssize_t handle_aiocb_write_zeroes(RawPosixAIOData *aiocb) >> +static ssize_t handle_aiocb_write_zeroes_block(RawPosixAIOData *aiocb) >> { >> int ret = -EOPNOTSUPP; >> BDRVRawState *s = aiocb->bs->opaque; >> >> - if (s->has_write_zeroes == 0) { >> + if (!s->has_write_zeroes) { >> return -ENOTSUP; >> } >> >> - if (aiocb->aio_type & QEMU_AIO_BLKDEV) { >> #ifdef BLKZEROOUT >> - do { >> - uint64_t range[2] = { aiocb->aio_offset, aiocb->aio_nbytes }; >> - if (ioctl(aiocb->aio_fildes, BLKZEROOUT, range) == 0) { >> - return 0; >> - } >> - } while (errno == EINTR); >> - >> - ret = -errno; >> -#endif >> - } else { >> -#ifdef CONFIG_XFS >> - if (s->is_xfs) { >> - return xfs_write_zeroes(s, aiocb->aio_offset, aiocb->aio_nbytes); >> + do { >> + uint64_t range[2] = { aiocb->aio_offset, aiocb->aio_nbytes }; >> + if (ioctl(aiocb->aio_fildes, BLKZEROOUT, range) == 0) { >> + return 0; >> } >> -#endif >> + } while (errno == EINTR); >> >> -#ifdef CONFIG_FALLOCATE_ZERO_RANGE >> - ret = do_fallocate(s->fd, FALLOC_FL_ZERO_RANGE, >> - aiocb->aio_offset, aiocb->aio_nbytes); >> + ret = translate_err(-errno); >> #endif >> - } >> >> - ret = translate_err(ret); >> if (ret == -ENOTSUP) { >> s->has_write_zeroes = false; >> } >> return ret; >> } >> >> +static ssize_t handle_aiocb_write_zeroes(RawPosixAIOData *aiocb) >> +{ >> + BDRVRawState *s; >> + >> + if (aiocb->aio_type & QEMU_AIO_BLKDEV) { >> + return handle_aiocb_write_zeroes_block(aiocb); >> + } >> + >> +#ifdef CONFIG_XFS >> + if (s->is_xfs) { > s is not initialized here. > > Also, could you please do these refactoring before adding new code in the > series? That way the new code needn't to be moved, which makes the patches > easier to review. > > Fam ok