[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 4/7] block: make discard asynchronous
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH 4/7] block: make discard asynchronous |
Date: |
Tue, 15 Jan 2013 09:55:40 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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
- [Qemu-devel] [PATCH resend 0/7] Discard improvements, Paolo Bonzini, 2013/01/14
- [Qemu-devel] [PATCH 1/7] raw-posix: support discard on more filesystems, Paolo Bonzini, 2013/01/14
- [Qemu-devel] [PATCH 2/7] raw-posix: remember whether discard failed, Paolo Bonzini, 2013/01/14
- [Qemu-devel] [PATCH 3/7] raw: support discard on block devices, Paolo Bonzini, 2013/01/14
- [Qemu-devel] [PATCH 4/7] block: make discard asynchronous, Paolo Bonzini, 2013/01/14
- Re: [Qemu-devel] [PATCH 4/7] block: make discard asynchronous,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH 5/7] ide: fix TRIM with empty range entry, Paolo Bonzini, 2013/01/14
- [Qemu-devel] [PATCH 6/7] ide: issue discard asynchronously but serialize the pieces, Paolo Bonzini, 2013/01/14
- [Qemu-devel] [PATCH 7/7] block: clear dirty bitmap when discarding, Paolo Bonzini, 2013/01/14
- Re: [Qemu-devel] [PATCH resend 0/7] Discard improvements, Stefan Hajnoczi, 2013/01/15