Received: from eggs.gnu.org ([208.118.235.92]:49419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv2J7-0003yI-0l for qemu-devel@nongnu.org; Tue, 15 Jan 2013 03:55:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tv2J6-0000R8-2r for qemu-devel@nongnu.org; Tue, 15 Jan 2013 03:55:44 -0500 Received: from mail-wi0-f172.google.com ([209.85.212.172]:63151) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv2J5-0000R2-Q7 for qemu-devel@nongnu.org; Tue, 15 Jan 2013 03:55:43 -0500 Received: by mail-wi0-f172.google.com with SMTP id o1so2050024wic.5 for ; Tue, 15 Jan 2013 00:55:43 -0800 (PST) Date: Tue, 15 Jan 2013 09:55:40 +0100 From: Stefan Hajnoczi Message-ID: <20130115085540.GC21625@stefanha-thinkpad.redhat.com> References: <1358177218-16802-1-git-send-email-pbonzini@redhat.com> <1358177218-16802-5-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1358177218-16802-5-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH 4/7] block: make discard asynchronous List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On Mon, Jan 14, 2013 at 04:26:55PM +0100, Paolo Bonzini wrote: > +static ssize_t handle_aiocb_discard(RawPosixAIOData *aiocb) > +{ > + int ret = -EOPNOTSUPP; > + BDRVRawState *s = aiocb->bs->opaque; > + > + if (s->has_discard == 0) { > + return 0; > + } > + > + if (aiocb->aio_type & QEMU_AIO_BLKDEV) { > +#ifdef BLKDISCARD > + do { > + uint64_t range[2] = { aiocb->aio_offset, aiocb->aio_nbytes }; > + if (ioctl(aiocb->aio_fildes, BLKDISCARD, range) == 0) { > + return 0; > + } > + } while (errno == EINTR); > + > + ret = -errno; > +#endif > + } else { > +#ifdef CONFIG_XFS > + if (s->is_xfs) { > + return xfs_discard(s, aiocb->aio_offset, aiocb->aio_nbytes); > + } > +#endif > + > +#ifdef CONFIG_FALLOCATE_PUNCH_HOLE > + do { > + if (fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, > + aiocb->aio_offset, aiocb->aio_nbytes) == 0) { It is cleaner to use either aiocb->aio_fildes or s->fd consistently in this function. Minor issue, not worth respinning for. Stefan