All of lore.kernel.org
 help / color / mirror / Atom feed
* [Question] Accessing read data in bio request
@ 2022-04-14 14:15 Jasper Surmont
  2022-04-18  1:59 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Jasper Surmont @ 2022-04-14 14:15 UTC (permalink / raw)
  To: linux-block

I'm writing a device mapper target, and on a bio (read) request I want
to access (for example just logging) the data that was just read (by
providing a callback to bio->bio_end_io).

I've figured out I could read the data by using bvec_kmap_local() on
each bio_vec to get a pointer to the data. However, if my
understanding is correct this seems like an unefficient way: if the
bio just finished a read then shouldn't the data already be mapped
somewhere? If so, where?

2nd question: using bio_for_each_segment(...) inside the bio_end_io
callback never loops. Is this normal, and if so why?

Thanks!

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

* Re: [Question] Accessing read data in bio request
  2022-04-14 14:15 [Question] Accessing read data in bio request Jasper Surmont
@ 2022-04-18  1:59 ` Jens Axboe
  2022-04-18 13:06   ` Jasper Surmont
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2022-04-18  1:59 UTC (permalink / raw)
  To: Jasper Surmont, linux-block

On 4/14/22 8:15 AM, Jasper Surmont wrote:
> I'm writing a device mapper target, and on a bio (read) request I want
> to access (for example just logging) the data that was just read (by
> providing a callback to bio->bio_end_io).
> 
> I've figured out I could read the data by using bvec_kmap_local() on
> each bio_vec to get a pointer to the data. However, if my
> understanding is correct this seems like an unefficient way: if the
> bio just finished a read then shouldn't the data already be mapped
> somewhere? If so, where?

Not necessarily - if you're doing passthrough or O_DIRECT IO, then
no mapping necessarily exists for any part of the IO.


-- 
Jens Axboe


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

* Re: [Question] Accessing read data in bio request
  2022-04-18  1:59 ` Jens Axboe
@ 2022-04-18 13:06   ` Jasper Surmont
  2022-04-18 15:33     ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Jasper Surmont @ 2022-04-18 13:06 UTC (permalink / raw)
  To: linux-block

Okay thanks! So does this mean that you would suggest doing it with 
bvec_kmap_local()?
Or are there other, maybe better, methods?

Thanks!

On 18/04/2022 04:59, Jens Axboe wrote:
> On 4/14/22 8:15 AM, Jasper Surmont wrote:
>> I'm writing a device mapper target, and on a bio (read) request I want
>> to access (for example just logging) the data that was just read (by
>> providing a callback to bio->bio_end_io).
>>
>> I've figured out I could read the data by using bvec_kmap_local() on
>> each bio_vec to get a pointer to the data. However, if my
>> understanding is correct this seems like an unefficient way: if the
>> bio just finished a read then shouldn't the data already be mapped
>> somewhere? If so, where?
> Not necessarily - if you're doing passthrough or O_DIRECT IO, then
> no mapping necessarily exists for any part of the IO.
>
>

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

* Re: [Question] Accessing read data in bio request
  2022-04-18 13:06   ` Jasper Surmont
@ 2022-04-18 15:33     ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2022-04-18 15:33 UTC (permalink / raw)
  To: Jasper Surmont, linux-block

Please don't top post

On 4/18/22 7:06 AM, Jasper Surmont wrote:
> On 18/04/2022 04:59, Jens Axboe wrote:
>> On 4/14/22 8:15 AM, Jasper Surmont wrote:
>>> I'm writing a device mapper target, and on a bio (read) request I want
>>> to access (for example just logging) the data that was just read (by
>>> providing a callback to bio->bio_end_io).
>>>
>>> I've figured out I could read the data by using bvec_kmap_local() on
>>> each bio_vec to get a pointer to the data. However, if my
>>> understanding is correct this seems like an unefficient way: if the
>>> bio just finished a read then shouldn't the data already be mapped
>>> somewhere? If so, where?
>>
>> Not necessarily - if you're doing passthrough or O_DIRECT IO, then
>> no mapping necessarily exists for any part of the IO.
>
> Okay thanks! So does this mean that you would suggest doing it with
> bvec_kmap_local()? Or are there other, maybe better, methods?

That's the way, yes.

-- 
Jens Axboe


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

end of thread, other threads:[~2022-04-18 15:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14 14:15 [Question] Accessing read data in bio request Jasper Surmont
2022-04-18  1:59 ` Jens Axboe
2022-04-18 13:06   ` Jasper Surmont
2022-04-18 15:33     ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.