Skip to contentSkip to conversation

iscsi: return data transfer residual for data-out commands

PATCH In review Tony Battersby 3 participants 3 messages Nov 7, 2007

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

PATCH 1/1 iscsi: return data transfer residual for data-out commands

Currently, the iSCSI driver returns the data transfer residual for data-in commands (e.g. read) but not data-out commands (e.g. write). This patch makes it return the data transfer residual for both types of commands.

---

drivers/scsi/libiscsi.c renamed from drivers/scsi/libiscsi.c.orig +0 -3
@@ -291,9 +291,6 @@ invalid_datalen:
 			   min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE));
 	}
 
-	if (sc->sc_data_direction == DMA_TO_DEVICE)
-		goto out;
-
 	if (rhdr->flags & ISCSI_FLAG_CMD_UNDERFLOW) {
 		int res_count = be32_to_cpu(rhdr->residual_count);
 
#1 lore raw
Quoted 4 lines · Tony Battersby

Currently, the iSCSI driver returns the data transfer residual for data-in commands (e.g. read) but not data-out commands (e.g. write). This patch makes it return the data transfer residual for both types of commands.

All types of commands, also good for BIDI ;)

Quoted 8 lines

---

drivers/scsi/libiscsi.c invalid_datalen: · line 296

Quoted 9 lines
drivers/scsi/libiscsi.c renamed from drivers/scsi/libiscsi.c.orig +0 -3
@@ -291,9 +291,6 @@ invalid_datalen:
 			   min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE));
 	}
 
-	if (sc->sc_data_direction == DMA_TO_DEVICE)
-		goto out;
-
 	if (rhdr->flags & ISCSI_FLAG_CMD_UNDERFLOW) {
 		int res_count = be32_to_cpu(rhdr->residual_count);
 

Thanks, this looks right to me. (And good catch)
I have went through the code and it looks like the right thing to do. "svn blame" annotates this code to the patch (r527) that libiscsi was cut out of iscsi_tcp so perhaps then it made sense, but does not anymore. It is also needed for the bidi patches, as currently bidi commands have a sc_data_direction == DMA_TO_DEVICE.

Pleas accept this patch
Boaz

#2 lore raw
Quoted 15 lines · Boaz Harrosh
Quoted 4 lines · Tony Battersby

Currently, the iSCSI driver returns the data transfer residual for data-in commands (e.g. read) but not data-out commands (e.g. write). This patch makes it return the data transfer residual for both types of commands.

All types of commands, also good for BIDI ;)

Quoted 8 lines

---

drivers/scsi/libiscsi.c renamed from drivers/scsi/libiscsi.c.orig +0 -0
@@ -291,9 +291,6 @@ invalid_datalen:
 			   min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE));
 	}
 
Quoted 11 lines

drivers/scsi/libiscsi.c invalid_datalen: · line 296

Quoted 8 lines
drivers/scsi/libiscsi.c renamed from drivers/scsi/libiscsi.c.orig +0 -3
-	if (sc->sc_data_direction == DMA_TO_DEVICE)
-		goto out;
-
 	if (rhdr->flags & ISCSI_FLAG_CMD_UNDERFLOW) {
 		int res_count = be32_to_cpu(rhdr->residual_count);
 

Thanks, this looks right to me. (And good catch)
I have went through the code and it looks like the right thing to do.
"svn blame" annotates this code to the patch (r527) that libiscsi was cut out of iscsi_tcp so perhaps then it made sense

Actually I think we always had it in one way or another. Maybe because of the code moves svn blame goofed.

I think it was originally done because we probably thought we could not get underflow or overflow on a write. I do not know for sure though, but it may have been a workaround for some old firmware on another target that was fixed a long time ago.

The patch looks ok. Thanks.

James please apply with his other patch

http://marc.info/?l=linux-scsi&m=119334187619290&w=2

for scsi-rc-fixes when you get a chance. Thanks.