Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74665016 authored by Christoph Hellwig's avatar Christoph Hellwig
Browse files

scsi: convert host_busy to atomic_t



Avoid taking the host-wide host_lock to check the per-host queue limit.
Instead we do an atomic_inc_return early on to grab our slot in the queue,
and if necessary decrement it after finishing all checks.

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>
Reviewed-by: default avatarWebb Scales <webbnh@hp.com>
Acked-by: default avatarJens Axboe <axboe@kernel.dk>
Tested-by: default avatarBart Van Assche <bvanassche@acm.org>
Tested-by: default avatarRobert Elliott <elliott@hp.com>
parent 7ae65c0f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2512,7 +2512,7 @@ static void asc_prt_scsi_host(struct Scsi_Host *s)

	printk("Scsi_Host at addr 0x%p, device %s\n", s, dev_name(boardp->dev));
	printk(" host_busy %u, host_no %d,\n",
	       s->host_busy, s->host_no);
	       atomic_read(&s->host_busy), s->host_no);

	printk(" base 0x%lx, io_port 0x%lx, irq %d,\n",
	       (ulong)s->base, (ulong)s->io_port, boardp->irq);
@@ -3346,7 +3346,7 @@ static void asc_prt_driver_conf(struct seq_file *m, struct Scsi_Host *shost)

	seq_printf(m,
		   " host_busy %u, max_id %u, max_lun %llu, max_channel %u\n",
		   shost->host_busy, shost->max_id,
		   atomic_read(&shost->host_busy), shost->max_id,
		   shost->max_lun, shost->max_channel);

	seq_printf(m,
+2 −2
Original line number Diff line number Diff line
@@ -2971,7 +2971,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
	 */
	for (;;) {
		spin_lock_irqsave(session->host->host_lock, flags);
		if (!session->host->host_busy) { /* OK for ERL == 0 */
		if (!atomic_read(&session->host->host_busy)) { /* OK for ERL == 0 */
			spin_unlock_irqrestore(session->host->host_lock, flags);
			break;
		}
@@ -2979,7 +2979,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
		msleep_interruptible(500);
		iscsi_conn_printk(KERN_INFO, conn, "iscsi conn_destroy(): "
				  "host_busy %d host_failed %d\n",
				  session->host->host_busy,
				  atomic_read(&session->host->host_busy),
				  session->host->host_failed);
		/*
		 * force eh_abort() to unblock
+3 −2
Original line number Diff line number Diff line
@@ -813,7 +813,7 @@ void sas_scsi_recover_host(struct Scsi_Host *shost)
	spin_unlock_irq(shost->host_lock);

	SAS_DPRINTK("Enter %s busy: %d failed: %d\n",
		    __func__, shost->host_busy, shost->host_failed);
		    __func__, atomic_read(&shost->host_busy), shost->host_failed);
	/*
	 * Deal with commands that still have SAS tasks (i.e. they didn't
	 * complete via the normal sas_task completion mechanism),
@@ -858,7 +858,8 @@ void sas_scsi_recover_host(struct Scsi_Host *shost)
		goto retry;

	SAS_DPRINTK("--- Exit %s: busy: %d failed: %d tries: %d\n",
		    __func__, shost->host_busy, shost->host_failed, tries);
		    __func__, atomic_read(&shost->host_busy),
		    shost->host_failed, tries);
}

enum blk_eh_timer_return sas_scsi_timed_out(struct scsi_cmnd *cmd)
+1 −1
Original line number Diff line number Diff line
@@ -959,7 +959,7 @@ static inline void update_can_queue(struct Scsi_Host *host, u_int in_ptr, u_int
	/* Temporary workaround until bug is found and fixed (one bug has been found
	   already, but fixing it makes things even worse) -jj */
	int num_free = QLOGICPTI_REQ_QUEUE_LEN - REQ_QUEUE_DEPTH(in_ptr, out_ptr) - 64;
	host->can_queue = host->host_busy + num_free;
	host->can_queue = atomic_read(&host->host_busy) + num_free;
	host->sg_tablesize = QLOGICPTI_MAX_SG(num_free);
}

+1 −1
Original line number Diff line number Diff line
@@ -600,7 +600,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
			if (level > 3)
				scmd_printk(KERN_INFO, cmd,
					    "scsi host busy %d failed %d\n",
					    cmd->device->host->host_busy,
					    atomic_read(&cmd->device->host->host_busy),
					    cmd->device->host->host_failed);
		}
	}
Loading