From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPiH0-0008CO-Bl for qemu-devel@nongnu.org; Tue, 19 Jul 2016 23:34:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPiGz-0005I9-HH for qemu-devel@nongnu.org; Tue, 19 Jul 2016 23:34:14 -0400 Date: Wed, 20 Jul 2016 11:34:02 +0800 From: Fam Zheng Message-ID: <20160720033402.GA7641@ad.usersys.redhat.com> References: <1468901281-22858-1-git-send-email-eblake@redhat.com> <1468901281-22858-14-git-send-email-eblake@redhat.com> <20160719062131.GG18103@ad.usersys.redhat.com> <578E4708.5080308@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH v5 13/14] nbd: Implement NBD_CMD_WRITE_ZEROES on server List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Eric Blake , Kevin Wolf , "nbd-general@lists.sourceforge.net" , qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz On Tue, 07/19 17:45, Paolo Bonzini wrote: > > > On 19/07/2016 17:28, Eric Blake wrote: > >> If I'm reading the NBD proto.md correctly, this is not enough if > >> NBD_CMD_FLAG_NO_HOLE is specified. We probably need to use a zeroed buffer with > >> blk_pwrite, or pass a new flag (BDRV_RED_NO_HOLE) to blk_pwrite_zeroes to > >> enforce the bdrv_driver_pwritev() branch in bdrv_co_do_pwrite_zeroes(). > > I agree with Eric's interpretation. It's a bit weird to have the > direction inverted, but I'm not sure I see the ambiguity. Can you explain? Write zeroes _means_ "punch hole" on a raw file. In block/raw-posix.c:handle_aiocb_write_zeroes(): > #ifdef CONFIG_FALLOCATE_PUNCH_HOLE > if (s->has_discard && s->has_fallocate) { > int ret = do_fallocate(s->fd, > FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, > aiocb->aio_offset, aiocb->aio_nbytes); > if (ret == 0) { > ret = do_fallocate(s->fd, 0, aiocb->aio_offset, aiocb->aio_nbytes); > if (ret == 0 || ret != -ENOTSUP) { > return ret; > } > s->has_fallocate = false; > } else if (ret != -ENOTSUP) { > return ret; > } else { > s->has_discard = false; > } > } > #endif And unmap is translated to "punch hole", too. In block/raw-posix.c:handle_aiocb_discard(): > #ifdef CONFIG_FALLOCATE_PUNCH_HOLE > ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, > aiocb->aio_offset, aiocb->aio_nbytes); > #endif So I agree that NBD_CMD_FLAG_NO_HOLE is a poorly named flag, because there is always going to be a hole event if it's set. Fam