On Wed, Sep 10, 2008 at 12:51 AM, Rohit Sharma <imreckless@xxxxxxxxx> wrote: > I was going through block drivers, > i am not able to associate request queues and bio structures. > How are the requests processed using bio structures. > Can anyone provide me with block driver example or tutorial. > looking at block/scsi_ioctl.c:sg_io() function - does line 207 and 241 answer your question? 207 rq = blk_get_request(q, writing ? WRITE : READ, GFP_KERNEL); 208 if (!rq) 209 return -ENOMEM; 210 211 if (blk_fill_sghdr_rq(q, rq, hdr, file)) { 212 blk_put_request(rq); 213 return -EFAULT; 214 } 215 216 if (hdr->iovec_count) { 217 const int size = sizeof(struct sg_iovec) * hdr->iovec_count; 218 struct sg_iovec *iov; 219 220 iov = kmalloc(size, GFP_KERNEL); 221 if (!iov) { 222 ret = -ENOMEM; 223 goto out; 224 } 225 226 if (copy_from_user(iov, hdr->dxferp, size)) { 227 kfree(iov); 228 ret = -EFAULT; 229 goto out; 230 } 231 232 ret = blk_rq_map_user_iov(q, rq, iov, hdr->iovec_count, 233 hdr->dxfer_len); 234 kfree(iov); 235 } else if (hdr->dxfer_len) 236 ret = blk_rq_map_user(q, rq, hdr->dxferp, hdr->dxfer_len); 237 238 if (ret) 239 goto out; 240 241 bio = rq->bio; 242 memset(sense, 0, sizeof(sense)); 243 rq->sense = sense; 244 rq->sense_len = 0; 245 rq->retries = 0; 246 247 start_time = jiffies; 248 249 /* ignore return value. All information is passed back to caller 250 * (if he doesn't check that is his problem). 251 * N.B. a non-zero SCSI status is _not_ necessarily an error. 252 */ 253 blk_execute_rq(q, bd_disk, rq, 0); 254 255 hdr->duration = jiffies_to_msecs(jiffies - start_time); 256 257 return blk_complete_sghdr_rq(rq, hdr, bio); -- Regards, Peter Teoh -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ