qemu-trivial.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Quentin Casasnovas <quentin.casasnovas@oracle.com>,
	qemu-devel <qemu-devel@nongnu.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	qemu-trivial@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] nbd: fix trim/discard commands with a length bigger than NBD_MAX_BUFFER_SIZE
Date: Tue, 10 May 2016 14:34:18 -0600	[thread overview]
Message-ID: <573245CA.1030104@redhat.com> (raw)
In-Reply-To: <1462524302-15558-1-git-send-email-quentin.casasnovas@oracle.com>

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

On 05/06/2016 02:45 AM, Quentin Casasnovas wrote:
> When running fstrim on a filesystem mounted through qemu-nbd with
> --discard=on, fstrim would fail with I/O errors:
> 
>   $ fstrim /k/spl/ice/
>   fstrim: /k/spl/ice/: FITRIM ioctl failed: Input/output error
> 
> and qemu-nbd was spitting these:
> 
>   nbd.c:nbd_co_receive_request():L1232: len (94621696) is larger than max len (33554432)

Your patch duplicates what is already present in qemu:

commit eb38c3b67018ff8069e4f674a28661931a8a3e4f
Author: Paolo Bonzini <pbonzini@redhat.com>
Date:   Thu Jan 7 14:32:42 2016 +0100

    nbd-server: do not check request length except for reads and writes

    Only reads and writes need to allocate memory correspondent to the
    request length.  Other requests can be sent to the storage without
    allocating any memory, and thus any request length is acceptable.

    Reported-by: Sitsofe Wheeler <sitsofe@yahoo.com>
    Cc: qemu-block@nongnu.org
    Reviewed-by: Max Reitz <mreitz@redhat.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

For the purposes of qemu-stable, it's better to backport the existing
patch than to write a new version of it.

It also helps to state what version of qemu you were testing, as it is
obviously not the (soon-to-be-released) version 2.6 which already has
the fix.

>  nbd.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/nbd.c b/nbd.c
> index b3d9654..e733669 100644
> --- a/nbd.c
> +++ b/nbd.c
> @@ -1209,6 +1209,11 @@ static ssize_t nbd_co_send_reply(NBDRequest *req, struct nbd_reply *reply,
>      return rc;
>  }
>  
> +static bool nbd_should_check_request_size(const struct nbd_request *request)
> +{
> +        return (request->type & NBD_CMD_MASK_COMMAND) != NBD_CMD_TRIM;
> +}
> +
>  static ssize_t nbd_co_receive_request(NBDRequest *req, struct nbd_request *request)
>  {
>      NBDClient *client = req->client;
> @@ -1227,7 +1232,8 @@ static ssize_t nbd_co_receive_request(NBDRequest *req, struct nbd_request *reque
>          goto out;
>      }
>  
> -    if (request->len > NBD_MAX_BUFFER_SIZE) {
> +    if (nbd_should_check_request_size(request) &&
> +        request->len > NBD_MAX_BUFFER_SIZE) {
>          LOG("len (%u) is larger than max len (%u)",
>              request->len, NBD_MAX_BUFFER_SIZE);
>          rc = -EINVAL;
> 

-- 
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 --]

  parent reply	other threads:[~2016-05-10 20:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-06  8:45 [Qemu-trivial] [PATCH] nbd: fix trim/discard commands with a length bigger than NBD_MAX_BUFFER_SIZE Quentin Casasnovas
2016-05-10 14:01 ` [Qemu-trivial] [Qemu-devel] " Eric Blake
2016-05-10 15:08   ` [Qemu-trivial] [Nbd] " Alex Bligh
2016-05-10 15:29     ` Eric Blake
2016-05-10 15:38       ` Alex Bligh
2016-05-10 15:45         ` Quentin Casasnovas
2016-05-10 15:49           ` Alex Bligh
2016-05-10 16:04             ` Quentin Casasnovas
2016-05-10 16:23               ` Alex Bligh
2016-05-10 16:27                 ` Quentin Casasnovas
2016-05-11  9:38                 ` Paolo Bonzini
2016-05-11 14:08                   ` Eric Blake
2016-05-11 14:55                     ` Alex Bligh
2016-05-11 15:08                       ` Paolo Bonzini
2016-05-10 17:55         ` Paolo Bonzini
2016-05-11 21:12         ` Wouter Verhelst
2016-05-12 15:33           ` Alex Bligh
2016-05-10 15:41       ` Alex Bligh
2016-05-10 15:46         ` Eric Blake
2016-05-10 15:52           ` Alex Bligh
2016-05-10 15:54           ` Quentin Casasnovas
2016-05-10 16:33             ` Quentin Casasnovas
2016-05-10 20:24               ` Eric Blake
2016-05-10 19:13         ` Michał Belczyk
2016-05-11 21:10       ` Wouter Verhelst
2016-05-11 21:06     ` Wouter Verhelst
2016-05-12 15:03       ` Alex Bligh
2016-05-10 20:34 ` Eric Blake [this message]
2016-05-11  8:34   ` [Qemu-trivial] " Quentin Casasnovas
2016-05-11 14:11     ` Eric Blake

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=573245CA.1030104@redhat.com \
    --to=eblake@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=quentin.casasnovas@oracle.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).