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 class="done" id="9c/70/f7aaceb9dc3f8664671fc9fb9c35ea0e0d22_3/2000"> <a href="http://lxr.linux.no/linux+*/+code=blk_queue_prep_rq" class="sref">blk_queue_prep_rq</a>(<a href="http://lxr.linux.no/linux+*/+code=sdp" class="sref">sdp</a>-><a href="http://lxr.linux.no/linux+*/+code=request_queue" class="sref">request_queue</a>, <a href="http://lxr.linux.no/linux+*/+code=sd_prep_fn" class="sref">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#L1879">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#L1493">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#L1688">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#L238">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#L1004">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#L1306">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>Sumeet<br></pre>