[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] nbd: fix trim/discard commands with a length bi
From: |
Eric Blake |
Subject: |
Re: [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 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
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 <address@hidden>
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 <address@hidden>
Cc: address@hidden
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
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
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [Nbd] [PATCH] nbd: fix trim/discard commands with a length bigger than NBD_MAX_BUFFER_SIZE, (continued)
- Re: [Qemu-devel] [Nbd] [PATCH] nbd: fix trim/discard commands with a length bigger than NBD_MAX_BUFFER_SIZE, Alex Bligh, 2016/05/10
- Re: [Qemu-devel] [Nbd] [PATCH] nbd: fix trim/discard commands with a length bigger than NBD_MAX_BUFFER_SIZE, Eric Blake, 2016/05/10
- Re: [Qemu-devel] [Nbd] [PATCH] nbd: fix trim/discard commands with a length bigger than NBD_MAX_BUFFER_SIZE, Alex Bligh, 2016/05/10
- Re: [Qemu-devel] [Nbd] [PATCH] nbd: fix trim/discard commands with a length bigger than NBD_MAX_BUFFER_SIZE, Quentin Casasnovas, 2016/05/10
- Re: [Qemu-devel] [Nbd] [PATCH] nbd: fix trim/discard commands with a length bigger than NBD_MAX_BUFFER_SIZE, Quentin Casasnovas, 2016/05/10
- Re: [Qemu-devel] [Nbd] [PATCH] nbd: fix trim/discard commands with a length bigger than NBD_MAX_BUFFER_SIZE, Eric Blake, 2016/05/10
- Re: [Qemu-devel] [Nbd] [PATCH] nbd: fix trim/discard commands with a length bigger than NBD_MAX_BUFFER_SIZE, MichaĆ Belczyk, 2016/05/10
- Re: [Qemu-devel] [Nbd] [PATCH] nbd: fix trim/discard commands with a length bigger than NBD_MAX_BUFFER_SIZE, Wouter Verhelst, 2016/05/11
- Re: [Qemu-devel] [Nbd] [PATCH] nbd: fix trim/discard commands with a length bigger than NBD_MAX_BUFFER_SIZE, Wouter Verhelst, 2016/05/11
- Re: [Qemu-devel] [Nbd] [PATCH] nbd: fix trim/discard commands with a length bigger than NBD_MAX_BUFFER_SIZE, Alex Bligh, 2016/05/12
Re: [Qemu-devel] [PATCH] nbd: fix trim/discard commands with a length bigger than NBD_MAX_BUFFER_SIZE,
Eric Blake <=