<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<br></div><div class="gmail_extra">Nidhi<br><br><br></div><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 class="im">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 class="im">> 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 class="im">> 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 class="im">> 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">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>