qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 4/7] block: make discard asynchronous
Date: Tue, 15 Jan 2013 09:55:40 +0100	[thread overview]
Message-ID: <20130115085540.GC21625@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1358177218-16802-5-git-send-email-pbonzini@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

  reply	other threads:[~2013-01-15  8:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-14 15:26 [Qemu-devel] [PATCH resend 0/7] Discard improvements Paolo Bonzini
2013-01-14 15:26 ` [Qemu-devel] [PATCH 1/7] raw-posix: support discard on more filesystems Paolo Bonzini
2013-01-14 15:26 ` [Qemu-devel] [PATCH 2/7] raw-posix: remember whether discard failed Paolo Bonzini
2013-01-14 15:26 ` [Qemu-devel] [PATCH 3/7] raw: support discard on block devices Paolo Bonzini
2013-01-14 15:26 ` [Qemu-devel] [PATCH 4/7] block: make discard asynchronous Paolo Bonzini
2013-01-15  8:55   ` Stefan Hajnoczi [this message]
2013-01-14 15:26 ` [Qemu-devel] [PATCH 5/7] ide: fix TRIM with empty range entry Paolo Bonzini
2013-01-14 15:26 ` [Qemu-devel] [PATCH 6/7] ide: issue discard asynchronously but serialize the pieces Paolo Bonzini
2013-01-14 15:26 ` [Qemu-devel] [PATCH 7/7] block: clear dirty bitmap when discarding Paolo Bonzini
2013-01-15  9:05 ` [Qemu-devel] [PATCH resend 0/7] Discard improvements Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130115085540.GC21625@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).