Skip to contentSkip to conversation

scsi: return correct status in scsi_host_eh_past_deadline()

PATCH In review Hannes Reinecke 4 participants 5 messages Feb 4, 2020 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: return correct status in scsi_host_eh_past_deadline()

If the user changed the 'eh_deadline' setting to 'off' while evaluating the time_before() call we will return 'true', which is inconsistent with the first conditional, where we return 'false' if 'eh_deadline' is set to 'off'.

---
 drivers/scsi/scsi_error.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_error.c +1 -1
index ae2fa170f6ad..ae29a9b4af56 100644
@@ -113,7 +113,7 @@ static int scsi_host_eh_past_deadline(struct Scsi_Host *shost)
 	    shost->eh_deadline > -1)
 		return 0;
 
-	return 1;
+	return shost->eh_deadline == -1 ? 0 : 1;
 }
 
 /**
Signature · 1 line
2.16.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines · Hannes Reinecke

If the user changed the 'eh_deadline' setting to 'off' while evaluating
the time_before() call we will return 'true', which is inconsistent with the first conditional, where we return 'false' if 'eh_deadline' is set to 'off'.

---
 drivers/scsi/scsi_error.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_error.c +1 -1
index ae2fa170f6ad..ae29a9b4af56 100644
@@ -113,7 +113,7 @@ static int scsi_host_eh_past_deadline(struct
 Scsi_Host *shost)
 	    shost->eh_deadline > -1)
 		return 0;
 
-	return 1;
+	return shost->eh_deadline == -1 ? 0 : 1;
 }
 
Quoted 1 line

/**

Makes sense, looks right to me.

#2 lore raw
In reply to Hannes Reinecke
Quoted 16 lines · Hannes Reinecke

If the user changed the 'eh_deadline' setting to 'off' while evaluating the time_before() call we will return 'true', which is inconsistent with the first conditional, where we return 'false' if 'eh_deadline' is set to 'off'.

---
 drivers/scsi/scsi_error.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_error.c +0 -0
index ae2fa170f6ad..ae29a9b4af56 100644

drivers/scsi/scsi_error.c static int scsi_host_eh_past_deadline(struct Scsi_Host *shost) · line 119

Quoted 8 lines
drivers/scsi/scsi_error.c +1 -1
@@ -113,7 +113,7 @@ static int scsi_host_eh_past_deadline(struct Scsi_Host *shost)
 	    shost->eh_deadline > -1)
 		return 0;
 
-	return 1;
+	return shost->eh_deadline == -1 ? 0 : 1;
 }
 
 /**

Hmm. 4 accesses to shost->eh_deadline in the function? Why don't we just copy it to a local variable and use that.

-Ewan

#3 lore raw
Quoted 20 lines · Ewan D. Milne
Quoted 19 lines · Hannes Reinecke

If the user changed the 'eh_deadline' setting to 'off' while evaluating the time_before() call we will return 'true', which is inconsistent with the first conditional, where we return 'false' if 'eh_deadline' is set to 'off'.

---
  drivers/scsi/scsi_error.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_error.c +0 -0
index ae2fa170f6ad..ae29a9b4af56 100644
@@ -113,7 +113,7 @@ static int scsi_host_eh_past_deadline(struct Scsi_Host *shost)
  	    shost->eh_deadline > -1)
  		return 0;
 
Quoted 8 lines

drivers/scsi/scsi_error.c static int scsi_host_eh_past_deadline(struct Scsi_Host *shost) · line 119

Quoted 5 lines
drivers/scsi/scsi_error.c +1 -1
-	return 1;
+	return shost->eh_deadline == -1 ? 0 : 1;
  }
 
  /**

Hmm. 4 accesses to shost->eh_deadline in the function? Why don't we just copy it to a local variable and use that.

That sounds like a better solution to me and that would also fix the problem described by Hannes.

Bart.

#4 lore raw
In reply to Hannes Reinecke
Quoted 16 lines · Hannes Reinecke

If the user changed the 'eh_deadline' setting to 'off' while evaluating the time_before() call we will return 'true', which is inconsistent with the first conditional, where we return 'false' if 'eh_deadline' is set to 'off'.

---
  drivers/scsi/scsi_error.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_error.c +0 -0
index ae2fa170f6ad..ae29a9b4af56 100644

drivers/scsi/scsi_error.c static int scsi_host_eh_past_deadline(struct Scsi_Host *shost) · line 117

Quoted 6 lines
drivers/scsi/scsi_error.c +1 -1
@@ -113,7 +113,7 @@ static int scsi_host_eh_past_deadline(struct Scsi_Host *shost)
  	    shost->eh_deadline > -1)
  		return 0;
 
-	return 1;
+	return shost->eh_deadline == -1 ? 0 : 1;
  }

This seems like a good opportunity to change the return type of this function from 'int' into 'bool'?

Thanks,

Bart.