函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:block\scsi_ioctl.c Create Date:2022-07-27 19:11:51
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:sg_io

函数原型:static int sg_io(struct request_queue *q, struct gendisk *bd_disk, struct sg_io_hdr *hdr, fmode_t mode)

返回类型:int

参数:

类型参数名称
struct request_queue *q
struct gendisk *bd_disk
struct sg_io_hdr *hdr
fmode_tmode
284  ret等于0
285  writing等于0
286  at_head等于0
291  如果 [i] 'S' for SCSI generic (required) 不等于'S'则返回:负EINVAL
294  如果 [i] byte count of data transfer 大于queue_max_hw_sectors(q)左移9位则返回:负EIO
297  如果 [i] byte count of data transfer switch [i] data transfer direction
299  默认
300  返回:负EINVAL
301  : [i] data transfer direction 恒等于.g. a SCSI WRITE command
302  writing等于1
303  退出
304  : [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  : [i] data transfer direction 恒等于.g. a SCSI READ command
306  退出
308  如果 [i] 0 -> default, see SG_FLAG... 按位与SG_FLAG_Q_AT_HEADat_head等于1
311  ret等于负ENOMEM
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.
313  如果是错误则返回:错误
315  req等于scsi_req(rq)
317  如果 [i] SCSI command length 大于BLK_MAX_CDB
318  cmd等于分配内存并置零
319  如果非cmd则转到:out_put_request
323  ret等于blk_fill_sghdr_rq(q, rq, hdr, mode)
324  如果ret小于0则转到:out_free_cdb
327  ret等于0
328  如果 [i] 0 implies no scatter gather
330  struct iovec * iov = NULL
333  如果in_compat_syscall()则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)
337  否则ret等于mport_iovec() - Copy an array of &struct iovec from userspace* into the kernel, check that it is valid, and initialize a new* &struct iov_iter iterator to access it.*@type: One of %READ or %WRITE.*@uvector: Pointer to the userspace array.
342  如果ret小于0则转到:out_free_cdb
346  Cap the iov_iter by given limit; note that the second argument is* *not* the new size - it's upper limit for such. Passing it a value* greater than the amount of data in iov_iter is fine - it'll just do* nothing in that case.
348  ret等于lk_rq_map_user_iov - map user data to a request, for passthrough requests*@q: request queue where request should be inserted*@rq: request to map data to*@map_data: pointer to the rq_map_data holding pages (if necessary)*@iter: iovec iterator*@gfp_mask:
349  释放内存
350  否则如果 [i] byte count of data transfer ret等于REQ_BLOCK_PC请求
354  如果ret则转到:out_free_cdb
357  bio等于bio
358  retries等于0
360  start_time等于jiffies
366  将请求插入队列执行
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  返回:ret
调用者
名称描述
scsi_cmd_ioctl