linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: linux-kernel@vger.kernel.org, stefanha@redhat.com,
	stable@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
	Jens Axboe <axboe@kernel.dk>,
	"open list:BLOCK LAYER" <linux-block@vger.kernel.org>
Subject: Re: [PATCH v2] block: bio_map_user_iov should not be limited to BIO_MAX_PAGES
Date: Thu, 18 Apr 2019 11:36:03 +0200	[thread overview]
Message-ID: <1cb6a060-79ee-c665-5a68-4f173ff03416@redhat.com> (raw)
In-Reply-To: <20190418092918.GB15834@ming.t460p>

On 18/04/19 11:29, Ming Lei wrote:
> On Thu, Apr 18, 2019 at 10:42:21AM +0200, Paolo Bonzini wrote:
>> On 18/04/19 04:19, Ming Lei wrote:
>>> Hi Paolo,
>>>
>>> On Wed, Apr 17, 2019 at 01:52:07PM +0200, Paolo Bonzini wrote:
>>>> Because bio_kmalloc uses inline iovecs, the limit on the number of entries
>>>> is not BIO_MAX_PAGES but rather UIO_MAXIOV, which indeed is already checked
>>>> in bio_kmalloc.  This could cause SG_IO requests to be truncated and the HBA
>>>> to report a DMA overrun.
>>>
>>> BIO_MAX_PAGES only limits the single bio's max vector number, if one bio
>>> can't hold all user space request, new bio will be allocated and appended
>>> to the passthrough request if queue limits aren't reached.
>>
>> Stupid question: where?  I don't see any place starting at
>> blk_rq_map_user_iov (and then __blk_rq_map_user_iov->bio_map_user_iov)
>> that would allocate a second bio.  The only bio_kmalloc in that path is
>> the one I'm patching.
> 
> Each bio is created inside __blk_rq_map_user_iov() which is run inside
> a loop, and the created bio is added to request via blk_rq_append_bio(),
> see the following code:

Uff, I can't read apparently. :(  This is the commit that introduced it:

    commit 4d6af73d9e43f78651a43ee4c5ad221107ac8365
    Author: Christoph Hellwig <hch@lst.de>
    Date:   Wed Mar 2 18:07:14 2016 +0100

    block: support large requests in blk_rq_map_user_iov
    
    This patch adds support for larger requests in blk_rq_map_user_iov by
    allowing it to build multiple bios for a request.  This functionality
    used to exist for the non-vectored blk_rq_map_user in the past, and
    this patch reuses the existing functionality for it on the unmap side,
    which stuck around.  Thanks to the iov_iter API supporting multiple
    bios is fairly trivial, as we can just iterate the iov until we've
    consumed the whole iov_iter.
    
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Reported-by: Jeff Lien <Jeff.Lien@hgst.com>
    Tested-by: Jeff Lien <Jeff.Lien@hgst.com>
    Reviewed-by: Keith Busch <keith.busch@intel.com>
    Signed-off-by: Jens Axboe <axboe@fb.com>

Paolo

  reply	other threads:[~2019-04-18  9:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-17 11:52 [PATCH v2] block: bio_map_user_iov should not be limited to BIO_MAX_PAGES Paolo Bonzini
2019-04-18  2:19 ` Ming Lei
2019-04-18  2:30   ` Ming Lei
2019-04-18  8:42   ` Paolo Bonzini
2019-04-18  9:29     ` Ming Lei
2019-04-18  9:36       ` Paolo Bonzini [this message]
2019-04-18  9:43         ` Ming Lei

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=1cb6a060-79ee-c665-5a68-4f173ff03416@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=stefanha@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /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).