<br><br><div class="gmail_quote">On Thu, Nov 10, 2011 at 6:13 PM, rohan puri <span dir="ltr">&lt;<a href="mailto:rohan.puri15@gmail.com">rohan.puri15@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br><div class="gmail_quote"><div><div class="h5">On Thu, Nov 10, 2011 at 4:50 PM, sumeet gandhare <span dir="ltr">&lt;<a href="mailto:sumeetgandhare@gmail.com" target="_blank">sumeetgandhare@gmail.com</a>&gt;</span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Hi All,<br>  I am trying to understand the scsi upper layer and middle layer code and found the function sd_prep_fn which seems to convert a request to a scsi command. I want to know when this function sd_prep_fn gets invoked.<br>


<br>It seems sd_probe_async invokes <br><pre>   <a href="http://lxr.linux.no/linux+*/+code=blk_queue_prep_rq" target="_blank">blk_queue_prep_rq</a>(<a href="http://lxr.linux.no/linux+*/+code=sdp" target="_blank">sdp</a>-&gt;<a href="http://lxr.linux.no/linux+*/+code=request_queue" target="_blank">request_queue</a>, <a href="http://lxr.linux.no/linux+*/+code=sd_prep_fn" target="_blank">sd_prep_fn</a>);<br>


<br>Further following code is invoking the prep_rq_fn<br><br>which is the blk_peek_request <br><br><a href="http://lxr.linux.no/#linux+v3.1/block/blk-core.c%23L1879" target="_blank">http://lxr.linux.no/#linux+v3.1/block/blk-core.c#L1879</a><br>


<br>and blk_peek_request is getting invoked from<br><br>scsi_request_fn <br><a href="http://lxr.linux.no/#linux+v3.1/drivers/scsi/scsi_lib.c%23L1493" target="_blank">http://lxr.linux.no/#linux+v3.1/drivers/scsi/scsi_lib.c#L1493</a><br>

<br>
scsi_request_fn is registered with the block layer as a request function at the following code<br><br><a href="http://lxr.linux.no/#linux+v3.1/drivers/scsi/scsi_lib.c%23L1688" target="_blank">http://lxr.linux.no/#linux+v3.1/drivers/scsi/scsi_lib.c#L1688</a><br>


<br>And scsi_alloc_queue is invoked from scsi_alloc_sdev<br><a href="http://lxr.linux.no/#linux+v3.1/drivers/scsi/scsi_scan.c%23L238" target="_blank">http://lxr.linux.no/#linux+v3.1/drivers/scsi/scsi_scan.c#L238</a><br><br>

scsi_alloc_sdev is invoked as a part of scsi lun discovery from lots of places<br>
<br><a href="http://lxr.linux.no/#linux+v3.1/drivers/scsi/scsi_scan.c%23L1004" target="_blank">http://lxr.linux.no/#linux+v3.1/drivers/scsi/scsi_scan.c#L1004</a><br><br><a href="http://lxr.linux.no/#linux+v3.1/drivers/scsi/scsi_scan.c%23L1306" target="_blank">http://lxr.linux.no/#linux+v3.1/drivers/scsi/scsi_scan.c#L1306</a><br>


<br>The confusion I have is that the sd.c upper layer driver has not registered for a request function using blk_init_queue<br><br>Any help would be appreciated.<br><br>Thanks<br><font color="#888888">Sumeet<br></font></pre>


<br></div></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></blockquote></div>Hello Sumeet,<br><br>sd_prep_fn function is set to the request queue&#39;s prep_rq_fn member as you have mentioned.<br><br>Now this function gets called in <br><br>ret = q-&gt;prep_rq_fn(q, rq); in function blk_peek_request() which is called from scsi_request_fn() in file scsi_lib.c<br>

<br>Regards,<span class="HOEnZb"><font color="#888888"><br>Rohan Puri<br>
</font></span></blockquote></div><br>Hi Rohan,<br> Thanks for your response and help.<br> It seems there is scsi_prep_fn too. I thought the blk_peek_request() invokes scsi_prep_fn and not sd_prep_fn.<br><br><a href="http://lxr.linux.no/#linux+v3.1/drivers/scsi/scsi_lib.c#L1248">http://lxr.linux.no/#linux+v3.1/drivers/scsi/scsi_lib.c#L1248</a><br>
<br>scsi_prep_fn is registered here<br><br><a href="http://lxr.linux.no/#linux+v3.1/drivers/scsi/scsi_lib.c#L1684">http://lxr.linux.no/#linux+v3.1/drivers/scsi/scsi_lib.c#L1684</a><br><br><br>Please could you confirm.<br>
<br>Thanks<br>Sumeet<br>