qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, qemu-stable@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] nbd: Don't trim unrequested bytes
Date: Wed, 25 May 2016 04:58:33 -0600	[thread overview]
Message-ID: <57458559.1070204@redhat.com> (raw)
In-Reply-To: <18efe9a1-d22c-fa23-66c5-64cc7db0ff02@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1854 bytes --]

On 05/25/2016 02:31 AM, Paolo Bonzini wrote:
> 
> 
> On 25/05/2016 06:37, Eric Blake wrote:
>> Similar to commit df7b97ff, we are mishandling clients that
>> give an unaligned NBD_CMD_TRIM request, and potentially
>> trimming bytes that occur before their request; which in turn
>> can cause potential unintended data loss (unlikely in
>> practice, since most clients are sane and issue aligned trim
>> requests).  However, while we fixed read and write by switching
>> to the byte interfaces of blk_, we don't yet have a byte
>> interface for discard.  On the other hand, trim is advisory, so
>> rounding the user's request to simply ignore the first and last
>> unaligned sectors (or the entire request, if it is sub-sector
>> in length) is just fine.
>>
>> CC: qemu-stable@nongnu.org
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>>  nbd/server.c | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/nbd/server.c b/nbd/server.c
>> index fa862cd..5aed8db 100644
>> --- a/nbd/server.c
>> +++ b/nbd/server.c
>> @@ -1153,8 +1153,12 @@ static void nbd_trip(void *opaque)
>>          break;
>>      case NBD_CMD_TRIM:
>>          TRACE("Request type is TRIM");
>> -        ret = blk_co_discard(exp->blk, (request.from + exp->dev_offset)
>> -                                       / BDRV_SECTOR_SIZE,
>> +        /* Ignore unaligned head or tail, until block layer adds byte
>> +         * interface */
>> +        request.len -= (request.from + request.len) % BDRV_SECTOR_SIZE;

Gaaah - this version can underflow request.len.  v2 coming up.

> Thanks, queued for 2.7.

Fortunately, rebasing a staging queue is easier than dealing with an
incorrect pull request.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

      reply	other threads:[~2016-05-25 10:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-25  4:37 [Qemu-devel] [PATCH] nbd: Don't trim unrequested bytes Eric Blake
2016-05-25  8:31 ` Paolo Bonzini
2016-05-25 10:58   ` Eric Blake [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=57458559.1070204@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    /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).