Commit b035da65 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jiri Slaby

scsi: move the nr_phys_segments assert into scsi_init_io

commit 635d98b1 upstream.

scsi_init_io should only be called for requests that transfer data,
so move the assert that a request has segments from the callers into
scsi_init_io.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent f7c55cea
......@@ -1025,8 +1025,11 @@ static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb,
int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask)
{
struct request *rq = cmd->request;
int error;
int error = scsi_init_sgtable(rq, &cmd->sdb, gfp_mask);
BUG_ON(!rq->nr_phys_segments);
error = scsi_init_sgtable(rq, &cmd->sdb, gfp_mask);
if (error)
goto err_exit;
......@@ -1128,11 +1131,7 @@ int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
* submit a request without an attached bio.
*/
if (req->bio) {
int ret;
BUG_ON(!req->nr_phys_segments);
ret = scsi_init_io(cmd, GFP_ATOMIC);
int ret = scsi_init_io(cmd, GFP_ATOMIC);
if (unlikely(ret))
return ret;
} else {
......@@ -1176,11 +1175,6 @@ int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
return ret;
}
/*
* Filesystem requests must transfer data.
*/
BUG_ON(!req->nr_phys_segments);
cmd = scsi_get_cmd_from_req(sdev, req);
if (unlikely(!cmd))
return BLKPREP_DEFER;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment