<div dir="ltr"><div><div><u><b>Setting of sd_prep_fn()</b></u><br>sd_probe is called<b><i> whenever a</i></b> <b><i>new scsi device is attached to the system. </i></b><br><br>sd_probe calls -> sd_probe_async-><br>
inside sd_probe_async, request prep fn is set to <b>sd_prep_fn</b><br>>>>>like this blk_queue_prep_rq(sdp->request_queue, sd_prep_fn);<br><br><br><u><b>Calling of sd_prep_fn</b></u><br></div><div>
?????<br>
<br></div><div>Is this request queue sdp->request_queue, different from the request queue, <br>for which scsi_prep_fn is used??<br><br>Are they on different layers ?<br><br>Is there some relation between them ?<br><br>
<br></div><div><br></div>Thanks<br></div>Nidhi<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Nov 5, 2013 at 6:13 PM, nidhi mittal hada <span dir="ltr"><<a href="mailto:nidhimittal19@gmail.com" target="_blank">nidhimittal19@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">scsi_alloc_sdev(must be called once for each scsi device) -->calls<br>scsi_alloc_queue (that sets up sdev->request_queue <br>
sets up scsi_request_fn and <br>
sets up req prep function as scsi_prep_fn)<br><br><font size="1">1738 struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)<br>1739 {<br>1740 struct request_queue *q;<br>
1742 q = __scsi_alloc_queue(sdev->host, scsi_request_fn);>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><br>
1743 if (!q)<br>1744 return NULL;<br>1746 blk_queue_prep_rq(q, scsi_prep_fn);>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><br>
1747 blk_queue_softirq_done(q, scsi_softirq_done);<br>1748 blk_queue_rq_timed_out(q, scsi_times_out);<br>1749 blk_queue_lld_busy(q, scsi_lld_busy);<br>1750 return q;<br>1751 }<br></font>And after this call sdev_request_queue is allocated................<br>
<br>Now, scsi_request_fn should be called while processing each request in this sdev->request_queue...<br>Please correct me if i m wrong.<br>Now, inside scsi_request_fn, we get next queueable request by calling <br>blk_peek_request - to fetch request from request queue ..<br>
<br>blk_peek_request -> calls __elv_next_request to fetch next request-<br>and calls prep_rq_fn(q, rq);<br><br><br><span style="color:rgb(116,27,71)"><b><font>which is scsi_prep_fn not the sd_prep_fn isnt it ??</font></b></span><br>
<br><br></div><div class="gmail_extra">Then where is sd_prep_fn is used for ??<br><br></div><div class="gmail_extra">Thanks<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div class="gmail_extra">
Nidhi<br><br><br></div></font></span><div><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, Nov 5, 2013 at 5:39 PM, Jack Wang <span dir="ltr"><<a href="mailto:xjtuwjp@gmail.com" target="_blank">xjtuwjp@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hi Nidhi,<br>
<br>
About the function call trace you can use ftrace to find out, another<br>
useful tool is scsi_logging_level to set more verbose logging output for<br>
scsi core.<br>
<br>
Regards<br>
Jack<br>
<div>On 11/05/2013 12:48 PM, nidhi mittal hada wrote:<br>
><br>
> Hi All<br>
><br>
> i have got a requirement where I need to encrypt/decrypt data that goes<br>
> from scsi layer to a particular block device.<br>
> As per my understanding till now on scsi subsystem in linux, i think i<br>
> need to<br>
> use crypto api and call appropriate encrypt/decrypt function from sd<br>
> driver for block device.<br>
><br>
> I need to locate that specific function where this change needs to be<br>
> made ...<br>
> I know basic block device driver writing in linux .. But not able to fit<br>
> scsi in this picture.<br>
><br>
> I have few basic doubts.. kindly help in resolving ...<br>
><br>
> 1) Now, as example block device driver sbull, as given LDD, works on<br>
> request queue, fetches req from this queue, using function req =<br>
> elv_next_request(q)),<br>
> in request function.<br>
> what is corresponding function in sd layer ?<br>
> That is the function where i have req->buffer in hand with me..<br>
><br>
><br>
> 2) For a write operation from initiator to disk<br>
> is the hierarchy like this<br>
</div>> *sd_prep_fn*<br>
<div>> generic block device request structure -> converted into scsi specific<br>
> request structure<br>
> OR<br>
> what is scsi_prep_fn for??<br>
><br>
> 3)How is Scpnt pointer that is req-> special is used in sd_prep_func..<br>
> is processed? i mean which layer picks Scpnt up and processes ??<br>
><br>
> 4)Any document any URL any kind of instruction will be extremely helpful.<br>
><br>
</div>> 5)Whenever a *new scsi device is attached *sd_probe is called<br>
<div>> sd_async_probe() is the async part of sd_probe() So when this is called<br>
> the prep_fn is set to sd_prep_fn and hence this will be called.<br>
><br>
</div>> *But i thought sd_prep_fn should be called for each and every request<br>
> .....??*<br>
<div>> Kindly help me to clear the confusion ..<br>
><br>
><br>
> Thanks<br>
> Nidhi<br>
><br>
><br>
><br>
><br>
</div>> _______________________________________________<br>
> Kernelnewbies mailing list<br>
> <a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
> <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
><br>
<br>
</blockquote></div><br><br clear="all"><br><br>
</div></div></div></div>
</blockquote></div><br><br clear="all"><br>-- <br>Thanks & Regards <br>Nidhi Mittal Hada<br><br><a href="http://nidhi-searchingmyself.blogspot.com/" target="_blank">http://nidhi-searchingmyself.blogspot.com/</a><br><br>
</div>