public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [rfc] weirdness in bio_map_user_iov()
@ 2016-09-21 21:52 Al Viro
  2016-09-23 21:47 ` Sagi Grimberg
  0 siblings, 1 reply; 2+ messages in thread
From: Al Viro @ 2016-09-21 21:52 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, linux-kernel

What happens if we feed it a 3-element iovec array, one page in each?
AFAICS, bio_add_pc_page() is called for each of those pages, even if
the previous calls have failed - break is only out of the inner loop.

Sure, failure due to exceeded request size means that everything after
that one will fail, but what of e.g.
                /*
                 * If the queue doesn't support SG gaps and adding this
                 * offset would create a gap, disallow it.
                 */
                if (bvec_gap_to_prev(q, prev, offset))
                        return 0;
in there?  Won't we risk having the first and the third pages added, with
the second one quietly skipped?  Jens, looks like it had come from you
(by way of jejb).  Am I missing something subtle here?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [rfc] weirdness in bio_map_user_iov()
  2016-09-21 21:52 [rfc] weirdness in bio_map_user_iov() Al Viro
@ 2016-09-23 21:47 ` Sagi Grimberg
  0 siblings, 0 replies; 2+ messages in thread
From: Sagi Grimberg @ 2016-09-23 21:47 UTC (permalink / raw)
  To: Al Viro, Jens Axboe; +Cc: linux-block, linux-kernel

Hey Al,

> What happens if we feed it a 3-element iovec array, one page in each?
> AFAICS, bio_add_pc_page() is called for each of those pages, even if
> the previous calls have failed - break is only out of the inner loop.
>
> Sure, failure due to exceeded request size means that everything after
> that one will fail, but what of e.g.
>                 /*
>                  * If the queue doesn't support SG gaps and adding this
>                  * offset would create a gap, disallow it.
>                  */
>                 if (bvec_gap_to_prev(q, prev, offset))
>                         return 0;
> in there?  Won't we risk having the first and the third pages added, with
> the second one quietly skipped?  Jens, looks like it had come from you
> (by way of jejb).  Am I missing something subtle here?

So AFAICT, 'gappy' iovecs will never reach bio_map_user_iov() because it
is checked before in blk_rq_map_user_iov():

         if (map_data)
                 copy = true;
         else if (iov_iter_alignment(iter) & align)
                 copy = true;
         else if (queue_virt_boundary(q))
                 copy = queue_virt_boundary(q) & 
iov_iter_gap_alignment(iter);

if iov_iter_gap_alignment(iter) detects gaps it will use
a nice aligned bounce via bio_copy_user_iov().

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-23 21:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-21 21:52 [rfc] weirdness in bio_map_user_iov() Al Viro
2016-09-23 21:47 ` Sagi Grimberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox