qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Lieven <pl@kamp.de>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	"famz@redhat.com" <famz@redhat.com>,
	ronnie sahlberg <ronniesahlberg@gmail.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	Orit Wasserman <owasserm@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCHv5] block: add native support for NFS
Date: Fri, 10 Jan 2014 19:47:27 +0100	[thread overview]
Message-ID: <52D0403F.9090607@kamp.de> (raw)
In-Reply-To: <52D03ACF.5020609@redhat.com>

Am 10.01.2014 19:24, schrieb Paolo Bonzini:
> Il 10/01/2014 19:07, Peter Lieven ha scritto:
>>
>>
>> Von meinem iPad gesendet
>>
>> Am 10.01.2014 um 19:05 schrieb "Paolo Bonzini" <pbonzini@redhat.com>:
>>
>>> Il 10/01/2014 18:16, ronnie sahlberg ha scritto:
>>>> There is a common exception though, for the case where you read past
>>>> the end of file.
>>>> So short reads should normally not happen. Unless QEMU or the guest
>>>> sends a request to libnfs to read past the end of the file.
>>> Yes, this can happen in QEMU and the various drivers are careful to pad
>>> with zeroes.  It could perhaps be moved to block.c, but for now each
>>> driver handles it separately.
>> ok i will add this as well. however, i thought i had seen code for this in block.c  already?,
> No, it corresponds to this code in block/raw-posix.c:
>
> static int aio_worker(void *arg)
> {
>     RawPosixAIOData *aiocb = arg;
>     ssize_t ret = 0;
>
>     switch (aiocb->aio_type & QEMU_AIO_TYPE_MASK) {
>     case QEMU_AIO_READ:
>         ret = handle_aiocb_rw(aiocb);
>         if (ret >= 0 && ret < aiocb->aio_nbytes && aiocb->bs->growable) {
>             iov_memset(aiocb->aio_iov, aiocb->aio_niov, ret,
>                       0, aiocb->aio_nbytes - ret);
>
>             ret = aiocb->aio_nbytes;
>         }
>         if (ret == aiocb->aio_nbytes) {
>             ret = 0;
>         } else if (ret >= 0 && ret < aiocb->aio_nbytes) {
>             ret = -EINVAL;
>         }
>         break;

I am a little confused... but it seems what I had in mind just fills up full sectors....?!

    if (!(bs->zero_beyond_eof && bs->growable)) {
        ret = drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov);
    } else {
        /* Read zeros after EOF of growable BDSes */
        int64_t len, total_sectors, max_nb_sectors;

        len = bdrv_getlength(bs);
        if (len < 0) {
            ret = len;
            goto out;
        }

        total_sectors = DIV_ROUND_UP(len, BDRV_SECTOR_SIZE);
        max_nb_sectors = MAX(0, total_sectors - sector_num);
        if (max_nb_sectors > 0) {
            ret = drv->bdrv_co_readv(bs, sector_num,
                                     MIN(nb_sectors, max_nb_sectors), qiov);
        } else {
            ret = 0;
        }

        /* Reading beyond end of file is supposed to produce zeroes */
        if (ret == 0 && total_sectors < sector_num + nb_sectors) {
            uint64_t offset = MAX(0, total_sectors - sector_num);
            uint64_t bytes = (sector_num + nb_sectors - offset) *
                              BDRV_SECTOR_SIZE;
            qemu_iovec_memset(qiov, offset * BDRV_SECTOR_SIZE, 0, bytes);
        }
    }

Peter



>
> Paolo

      reply	other threads:[~2014-01-10 18:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-26 12:48 [Qemu-devel] [PATCHv5] block: add native support for NFS Peter Lieven
2014-01-03 10:37 ` Stefan Hajnoczi
2014-01-03 10:51   ` Peter Lieven
2014-01-03 11:04   ` Peter Lieven
2014-01-03 11:28   ` Peter Lieven
2014-01-06  1:18     ` Stefan Hajnoczi
2014-01-06  6:53       ` Peter Lieven
2014-01-09 14:13 ` Kevin Wolf
2014-01-09 16:08   ` Peter Lieven
2014-01-10 11:40     ` Kevin Wolf
2014-01-10 12:12       ` Peter Lieven
2014-01-10 12:30         ` Paolo Bonzini
2014-01-10 14:49           ` ronnie sahlberg
2014-01-10 15:05             ` Peter Lieven
2014-01-10 15:46               ` Kevin Wolf
2014-01-10 16:10                 ` Peter Lieven
2014-01-10 17:16                   ` ronnie sahlberg
2014-01-10 18:05                     ` Paolo Bonzini
2014-01-10 18:07                       ` Peter Lieven
2014-01-10 18:24                         ` Paolo Bonzini
2014-01-10 18:47                           ` Peter Lieven [this message]

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=52D0403F.9090607@kamp.de \
    --to=pl@kamp.de \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=owasserm@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=ronniesahlberg@gmail.com \
    --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).