| Function report | 
| Source Code: block\scsi_ioctl.c | Create Date:2022-07-28 17:36:19 | 
| Last Modify:2020-03-12 14:18:49 | Copyright©Brick | 
| home page | Tree | 
| Annotation kernel can get tool activity | Download SCCT | Chinese | 
Name:sg_io
Proto:static int sg_io(struct request_queue *q, struct gendisk *bd_disk, struct sg_io_hdr *hdr, fmode_t mode)
Type:int
Parameter:
| Type | Parameter | Name | 
|---|---|---|
| struct request_queue * | q | |
| struct gendisk * | bd_disk | |
| struct sg_io_hdr * | hdr | |
| fmode_t | mode | 
| 284 | ret = 0 | 
| 285 | writing = 0 | 
| 286 | at_head = 0 | 
| 291 | If [i] 'S' for SCSI generic (required) != 'S' Then Return -EINVAL | 
| 294 | If [i] byte count of data transfer > queue_max_hw_sectors(q) << 9 Then Return -EIO | 
| 297 | If [i] byte count of data transfer Then switch [i] data transfer direction | 
| 299 | Default | 
| 300 | Return -EINVAL | 
| 301 | Case [i] data transfer direction == .g. a SCSI WRITE command | 
| 302 | writing = 1 | 
| 303 | Break | 
| 304 | Case [i] data transfer direction == reated like SG_DXFER_FROM_DEV with theadditional property than during indirectIO the user buffer is copied into thekernel buffers before the transfer | 
| 305 | Case [i] data transfer direction == .g. a SCSI READ command | 
| 306 | Break | 
| 308 | If [i] 0 -> default, see SG_FLAG... & SG_FLAG_Q_AT_HEAD Then at_head = 1 | 
| 312 | rq = lk_get_request - allocate a request*@q: request queue to allocate a request for*@op: operation (REQ_OP_*) and REQ_* flags, e.g. REQ_SYNC.*@flags: BLK_MQ_REQ_* flags, e.g. BLK_MQ_REQ_NOWAIT. | 
| 317 | If [i] SCSI command length > BLK_MAX_CDB Then | 
| 318 | cmd = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc). | 
| 319 | If Not cmd Then Go to out_put_request | 
| 324 | If ret < 0 Then Go to out_free_cdb | 
| 327 | ret = 0 | 
| 328 | If [i] 0 implies no scatter gather Then | 
| 333 | If in_compat_syscall() Then ret = compat_import_iovec(rq_data_dir(rq), [i], [*io] points to data transfer memory or scatter gather list , [i] 0 implies no scatter gather , 0, & iov, & i) | 
| 342 | If ret < 0 Then Go to out_free_cdb | 
| 350 | Else if [i] byte count of data transfer Then ret = blk_rq_map_user(q, rq, NULL, [i], [*io] points to data transfer memory or scatter gather list , [i] byte count of data transfer , GFP_KERNEL) | 
| 354 | If ret Then Go to out_free_cdb | 
| 358 | retries = 0 | 
| 360 | start_time = jiffies | 
| 368 | [o] time taken by cmd (unit: millisec) = Convert jiffies to milliseconds and back.* Avoid unnecessary multiplications/divisions in the* two most common HZ cases: | 
| 370 | ret = blk_complete_sghdr_rq(rq, hdr, bio) | 
| 372 | out_free_cdb : | 
| 373 | scsi_req_free_cmd(req) | 
| 374 | out_put_request : | 
| 375 | blk_put_request(rq) | 
| 376 | Return ret | 
| Name | Describe | 
|---|---|
| scsi_cmd_ioctl | 
| Source code conversion tool public plug-in interface | X | 
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |