bsg: add SCSI transport-level request support
This enables bsg to handle SCSI transport-level request like SAS management protocol (SMP). - add BSG_SUB_PROTOCOL_{SCSI_CMD, SCSI_TMF, SCSI_TRANSPORT} definitions. - SCSI transport-level requests skip blk_verify_command(). Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
This commit is contained in:
parent
2c9ecdf40a
commit
15d10b611f
27
block/bsg.c
27
block/bsg.c
|
@ -208,7 +208,11 @@ static int blk_fill_sgv4_hdr_rq(request_queue_t *q, struct request *rq,
|
||||||
if (copy_from_user(rq->cmd, (void *)(unsigned long)hdr->request,
|
if (copy_from_user(rq->cmd, (void *)(unsigned long)hdr->request,
|
||||||
hdr->request_len))
|
hdr->request_len))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
if (blk_verify_command(rq->cmd, has_write_perm))
|
|
||||||
|
if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
|
||||||
|
if (blk_verify_command(rq->cmd, has_write_perm))
|
||||||
|
return -EPERM;
|
||||||
|
} else if (!capable(CAP_SYS_RAWIO))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -232,6 +236,8 @@ static int blk_fill_sgv4_hdr_rq(request_queue_t *q, struct request *rq,
|
||||||
static int
|
static int
|
||||||
bsg_validate_sgv4_hdr(request_queue_t *q, struct sg_io_v4 *hdr, int *rw)
|
bsg_validate_sgv4_hdr(request_queue_t *q, struct sg_io_v4 *hdr, int *rw)
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
if (hdr->guard != 'Q')
|
if (hdr->guard != 'Q')
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (hdr->request_len > BLK_MAX_CDB)
|
if (hdr->request_len > BLK_MAX_CDB)
|
||||||
|
@ -240,13 +246,22 @@ bsg_validate_sgv4_hdr(request_queue_t *q, struct sg_io_v4 *hdr, int *rw)
|
||||||
hdr->din_xfer_len > (q->max_sectors << 9))
|
hdr->din_xfer_len > (q->max_sectors << 9))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
/* not supported currently */
|
switch (hdr->protocol) {
|
||||||
if (hdr->protocol || hdr->subprotocol)
|
case BSG_PROTOCOL_SCSI:
|
||||||
return -EINVAL;
|
switch (hdr->subprotocol) {
|
||||||
|
case BSG_SUB_PROTOCOL_SCSI_CMD:
|
||||||
|
case BSG_SUB_PROTOCOL_SCSI_TRANSPORT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = -EINVAL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
*rw = hdr->dout_xfer_len ? WRITE : READ;
|
*rw = hdr->dout_xfer_len ? WRITE : READ;
|
||||||
|
return ret;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
#ifndef BSG_H
|
#ifndef BSG_H
|
||||||
#define BSG_H
|
#define BSG_H
|
||||||
|
|
||||||
|
#define BSG_PROTOCOL_SCSI 0
|
||||||
|
|
||||||
|
#define BSG_SUB_PROTOCOL_SCSI_CMD 0
|
||||||
|
#define BSG_SUB_PROTOCOL_SCSI_TMF 1
|
||||||
|
#define BSG_SUB_PROTOCOL_SCSI_TRANSPORT 2
|
||||||
|
|
||||||
struct sg_io_v4 {
|
struct sg_io_v4 {
|
||||||
__s32 guard; /* [i] 'Q' to differentiate from v3 */
|
__s32 guard; /* [i] 'Q' to differentiate from v3 */
|
||||||
__u32 protocol; /* [i] 0 -> SCSI , .... */
|
__u32 protocol; /* [i] 0 -> SCSI , .... */
|
||||||
|
|
Loading…
Reference in New Issue