kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Help understanding block layer sample in LDD3
@ 2016-07-29  9:44 François
  2016-07-29 10:28 ` Pranay Srivastava
  0 siblings, 1 reply; 5+ messages in thread
From: François @ 2016-07-29  9:44 UTC (permalink / raw)
  To: kernelnewbies

Hi there,

I've been reading LDD3's chapter 16 on block devices a few times, and have made toys 
block layers module. Now I've been looking at the up-to-date examples provided by martinez javier[1],
but still there's a fundamental concept I fail to understand.

Considering only the RM_FULL and RM_SIMPLE cases, a request queue is created, bound with a lock, and associated
with a request function.

In the simple case, that function "sbull_request" processes each request from the request queue, and delegates
the work to "sbull_transfer", which basically performs some arithmetic and does the actual data copy.
This function is given a sector, a number of sectors, a pointer to a buffer, and a read or write parameter
extracted from the request using blk_rq_pos(), blk_rq_cur_sectors(), req->buffer and rq_data_dir() respectively.
 
On the other hand, the same mechanism is used, but a different function is associated: "sbull_full_request".
That function also extracts requests and delegates the actual work to "sbull_xfer_request" which iterates on
the request's bio, calls "sbull_xfer_bio" which itself iterates on the bio's segments and finally, 
calls the same "sbull_transfer" function.

What I fail to understand is: how (with the same initialization) the behaviour of the module using those two
somehow different mechanism is equivalent.

One has to understand the full complexity of the underlying data structure (requests having bio, having segments)
while the other only reads the containing structure (the struct request) and do the same job, without iterations.

Bonus point, to give some context: I'm writing an asynchronous block-layer which has to split requests into custom subrequest.
I'm wondering which approach (between those two) I should pickup.

Thanks for reading so far, and for any hints :) 


[1] https://github.com/martinezjavier/ldd3/blob/master/sbull/sbull.c
-- 
Fran?ois

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

end of thread, other threads:[~2016-07-29 13:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-29  9:44 Help understanding block layer sample in LDD3 François
2016-07-29 10:28 ` Pranay Srivastava
2016-07-29 10:45   ` François
2016-07-29 10:56     ` Pranay Srivastava
2016-07-29 13:16       ` François

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).