[PATCH] libata: replace ap_lock w/ ap->lock in ata_scsi_error()

ap_lock was used because &ap->host_set->lock was too long and used a
lot. Now that &ap->host_set->lock is replaced with ap->lock, there's
no reason to keep ap_lock.

[ed. note: that's not entirely true. ap_lock is a local variable,
caching the results of a de-ref. In theory, if the compiler is smart
enough, this patch is cosmetic. However, since this is not a fast
path (it is the error path), this patch is nonetheless acceptable,
even though it _may_ introduce a performance regression.]

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

authored by Tejun Heo and committed by Jeff Garzik e30349d2 0662c58b

+11 -12
+11 -12
drivers/scsi/libata-eh.c
··· 190 void ata_scsi_error(struct Scsi_Host *host) 191 { 192 struct ata_port *ap = ata_shost_to_port(host); 193 - spinlock_t *ap_lock = ap->lock; 194 int i, repeat_cnt = ATA_EH_MAX_REPEAT; 195 unsigned long flags; 196 ··· 216 struct scsi_cmnd *scmd, *tmp; 217 int nr_timedout = 0; 218 219 - spin_lock_irqsave(ap_lock, flags); 220 221 list_for_each_entry_safe(scmd, tmp, &host->eh_cmd_q, eh_entry) { 222 struct ata_queued_cmd *qc; ··· 255 if (nr_timedout) 256 __ata_port_freeze(ap); 257 258 - spin_unlock_irqrestore(ap_lock, flags); 259 } else 260 - spin_unlock_wait(ap_lock); 261 262 repeat: 263 /* invoke error handler */ 264 if (ap->ops->error_handler) { 265 /* fetch & clear EH info */ 266 - spin_lock_irqsave(ap_lock, flags); 267 268 memset(&ap->eh_context, 0, sizeof(ap->eh_context)); 269 ap->eh_context.i = ap->eh_info; ··· 272 ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS; 273 ap->pflags &= ~ATA_PFLAG_EH_PENDING; 274 275 - spin_unlock_irqrestore(ap_lock, flags); 276 277 /* invoke EH. if unloading, just finish failed qcs */ 278 if (!(ap->pflags & ATA_PFLAG_UNLOADING)) ··· 284 * recovered the port but before this point. Repeat 285 * EH in such case. 286 */ 287 - spin_lock_irqsave(ap_lock, flags); 288 289 if (ap->pflags & ATA_PFLAG_EH_PENDING) { 290 if (--repeat_cnt) { 291 ata_port_printk(ap, KERN_INFO, 292 "EH pending after completion, " 293 "repeating EH (cnt=%d)\n", repeat_cnt); 294 - spin_unlock_irqrestore(ap_lock, flags); 295 goto repeat; 296 } 297 ata_port_printk(ap, KERN_ERR, "EH pending after %d " ··· 301 /* this run is complete, make sure EH info is clear */ 302 memset(&ap->eh_info, 0, sizeof(ap->eh_info)); 303 304 - /* Clear host_eh_scheduled while holding ap_lock such 305 * that if exception occurs after this point but 306 * before EH completion, SCSI midlayer will 307 * re-initiate EH. 308 */ 309 host->host_eh_scheduled = 0; 310 311 - spin_unlock_irqrestore(ap_lock, flags); 312 } else { 313 WARN_ON(ata_qc_from_tag(ap, ap->active_tag) == NULL); 314 ap->ops->eng_timeout(ap); ··· 320 scsi_eh_flush_done_q(&ap->eh_done_q); 321 322 /* clean up */ 323 - spin_lock_irqsave(ap_lock, flags); 324 325 if (ap->pflags & ATA_PFLAG_LOADING) { 326 ap->pflags &= ~ATA_PFLAG_LOADING; ··· 337 ap->pflags &= ~ATA_PFLAG_EH_IN_PROGRESS; 338 wake_up_all(&ap->eh_wait_q); 339 340 - spin_unlock_irqrestore(ap_lock, flags); 341 342 DPRINTK("EXIT\n"); 343 }
··· 190 void ata_scsi_error(struct Scsi_Host *host) 191 { 192 struct ata_port *ap = ata_shost_to_port(host); 193 int i, repeat_cnt = ATA_EH_MAX_REPEAT; 194 unsigned long flags; 195 ··· 217 struct scsi_cmnd *scmd, *tmp; 218 int nr_timedout = 0; 219 220 + spin_lock_irqsave(ap->lock, flags); 221 222 list_for_each_entry_safe(scmd, tmp, &host->eh_cmd_q, eh_entry) { 223 struct ata_queued_cmd *qc; ··· 256 if (nr_timedout) 257 __ata_port_freeze(ap); 258 259 + spin_unlock_irqrestore(ap->lock, flags); 260 } else 261 + spin_unlock_wait(ap->lock); 262 263 repeat: 264 /* invoke error handler */ 265 if (ap->ops->error_handler) { 266 /* fetch & clear EH info */ 267 + spin_lock_irqsave(ap->lock, flags); 268 269 memset(&ap->eh_context, 0, sizeof(ap->eh_context)); 270 ap->eh_context.i = ap->eh_info; ··· 273 ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS; 274 ap->pflags &= ~ATA_PFLAG_EH_PENDING; 275 276 + spin_unlock_irqrestore(ap->lock, flags); 277 278 /* invoke EH. if unloading, just finish failed qcs */ 279 if (!(ap->pflags & ATA_PFLAG_UNLOADING)) ··· 285 * recovered the port but before this point. Repeat 286 * EH in such case. 287 */ 288 + spin_lock_irqsave(ap->lock, flags); 289 290 if (ap->pflags & ATA_PFLAG_EH_PENDING) { 291 if (--repeat_cnt) { 292 ata_port_printk(ap, KERN_INFO, 293 "EH pending after completion, " 294 "repeating EH (cnt=%d)\n", repeat_cnt); 295 + spin_unlock_irqrestore(ap->lock, flags); 296 goto repeat; 297 } 298 ata_port_printk(ap, KERN_ERR, "EH pending after %d " ··· 302 /* this run is complete, make sure EH info is clear */ 303 memset(&ap->eh_info, 0, sizeof(ap->eh_info)); 304 305 + /* Clear host_eh_scheduled while holding ap->lock such 306 * that if exception occurs after this point but 307 * before EH completion, SCSI midlayer will 308 * re-initiate EH. 309 */ 310 host->host_eh_scheduled = 0; 311 312 + spin_unlock_irqrestore(ap->lock, flags); 313 } else { 314 WARN_ON(ata_qc_from_tag(ap, ap->active_tag) == NULL); 315 ap->ops->eng_timeout(ap); ··· 321 scsi_eh_flush_done_q(&ap->eh_done_q); 322 323 /* clean up */ 324 + spin_lock_irqsave(ap->lock, flags); 325 326 if (ap->pflags & ATA_PFLAG_LOADING) { 327 ap->pflags &= ~ATA_PFLAG_LOADING; ··· 338 ap->pflags &= ~ATA_PFLAG_EH_IN_PROGRESS; 339 wake_up_all(&ap->eh_wait_q); 340 341 + spin_unlock_irqrestore(ap->lock, flags); 342 343 DPRINTK("EXIT\n"); 344 }