Skip to contentSkip to conversation

nvmet: Do not check for sg_cnt being zero for read/write commands.

PATCH New Parav Pandit 3 participants 6 messages Feb 7, 2017 – Feb 8, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvmet: Do not check for sg_cnt being zero for read/write commands.

sg_cnt cannot be zero for inline or sge mode from the fabric drivers because nvme read/write commands have minimum of one block to be read or written. (nlb dw12 is 0 based value).
So sg_cnt check for 0 is not useful.

Reviewed-by Max Gurtovoy <maxg at mellanox.com>
Signed-off-by Parav Pandit <parav at mellanox.com>
---
 drivers/nvme/target/io-cmd.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/nvme/target/io-cmd.c +0 -5
index 4195115..e6a3a8a 100644
@@ -49,11 +49,6 @@ static void nvmet_execute_rw(struct nvmet_req *req)
 	blk_qc_t cookie;
 	int op, op_flags = 0, i;
 
-	if (!req->sg_cnt) {
-		nvmet_req_complete(req, 0);
-		return;
-	}
-
 	if (req->cmd->rw.opcode == nvme_cmd_write) {
 		op = REQ_OP_WRITE;
 		op_flags = REQ_SYNC | REQ_IDLE;
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 nvmet: Do not check for sg_cnt being zero for read/write commands.

Quoted 4 lines · Parav Pandit

sg_cnt cannot be zero for inline or sge mode from the fabric drivers because nvme read/write commands have minimum of one block to be read or written. (nlb dw12 is 0 based value).
So sg_cnt check for 0 is not useful.

Except that we currently don't verify the data transfer in the SGL matches that in the command. It's been on my todo list for a while, so maybe you can take it off my plate first before we'll aply this patch.

maintainer
#2 lore raw

PATCH 1/1 nvmet: Do not check for sg_cnt being zero for read/write commands.

Quoted 5 lines

Except that we currently don't verify the data transfer in the SGL matches that in the command. It's been on my todo list for a while, so maybe you can take it off my plate first before we'll aply this patch.

Any reason not to take it as is and add the sgl validity check incrementally?

#3 lore raw

PATCH 1/1 nvmet: Do not check for sg_cnt being zero for read/write commands.

Quoted 8 lines · Sagi Grimberg
Quoted 5 lines

Except that we currently don't verify the data transfer in the SGL matches that in the command. It's been on my todo list for a while, so maybe you can take it off my plate first before we'll aply this patch.

Any reason not to take it as is and add the sgl validity check incrementally?

Because that would allow a bad actor host to crash the target easily.

#4 lore raw

PATCH 1/1 nvmet: Do not check for sg_cnt being zero for read/write commands.

In reply to Christoph Hellwig
Quoted 12 lines

-----Original Message-----
From: Christoph Hellwig [mailto:hch at lst.de]
Sent: Wednesday, February 8, 2017 2:24 AM
To: Parav Pandit <parav at mellanox.com>
Cc: hch at lst.de; sagi at grimberg.me; linux-nvme at lists.infradead.org
Subject: Re: [PATCH] nvmet: Do not check for sg_cnt being zero for read/write commands.

Quoted 2 lines · Parav Pandit

sg_cnt cannot be zero for inline or sge mode from the fabric drivers because nvme read/write commands have minimum of one block to be

Quoted 7 lines

read

Quoted 2 lines

or written. (nlb dw12 is 0 based value).
So sg_cnt check for 0 is not useful.

Except that we currently don't verify the data transfer in the SGL matches that in the command. It's been on my todo list for a while, so maybe you can take it off my plate first before we'll aply this patch.

Yes. I hit an error when there was a mismatch between nlba and sge length. That check is needed to fail the nvme requests. I will post that patch soon.

#5 lore raw

PATCH 1/1 nvmet: Do not check for sg_cnt being zero for read/write commands.

In reply to Christoph Hellwig
Quoted 26 lines

-----Original Message-----
From: Parav Pandit
Sent: Wednesday, February 8, 2017 9:11 AM
To: 'Christoph Hellwig' <hch at lst.de>
Cc: sagi at grimberg.me; linux-nvme at lists.infradead.org
Subject: RE: [PATCH] nvmet: Do not check for sg_cnt being zero for read/write commands.

Quoted 15 lines

-----Original Message-----
From: Christoph Hellwig [mailto:hch at lst.de]
Sent: Wednesday, February 8, 2017 2:24 AM
To: Parav Pandit <parav at mellanox.com>
Cc: hch at lst.de; sagi at grimberg.me; linux-nvme at lists.infradead.org
Subject: Re: [PATCH] nvmet: Do not check for sg_cnt being zero for read/write commands.

Quoted 2 lines · Parav Pandit

sg_cnt cannot be zero for inline or sge mode from the fabric drivers because nvme read/write commands have minimum of one block to be

read

Quoted 2 lines

or written. (nlb dw12 is 0 based value).
So sg_cnt check for 0 is not useful.

Quoted 6 lines
Quoted 3 lines

Except that we currently don't verify the data transfer in the SGL matches that in the command. It's been on my todo list for a while, so maybe you can take it off my plate first before we'll aply this patch.

Yes. I hit an error when there was a mismatch between nlba and sge length. That check is needed to fail the nvme requests. I will post that patch soon.

However check for sg_cnt being not zero doesn't catch that error either, so both the checks are unrelated. I think this patch still holds fine?