Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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 activityDownload SCCTChinese

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:

TypeParameterName
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  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
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  If IS_ERR(rq) Then Return PTR_ERR(rq)
315  req = scsi_req(rq)
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
323  ret = blk_fill_sghdr_rq(q, rq, hdr, mode)
324  If ret < 0 Then Go to out_free_cdb
327  ret = 0
328  If [i] 0 implies no scatter gather Then
330  struct iovec * iov = NULL
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)
337  Else 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  If ret < 0 Then Go to 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  kfree(iov)
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
357  bio = bio
358  retries = 0
360  start_time = jiffies
366  lk_execute_rq - insert a request into queue for execution*@q: queue to insert the request in*@bd_disk: matching gendisk*@rq: request to insert*@at_head: insert request at head or tail of queue* Description:* Insert a fully prepared request at the back of
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
Caller
NameDescribe
scsi_cmd_ioctl