Re: [PATCH 06/15] hpsa: use scsi_host_busy_iter() to traverse outstanding commands

John Garry
2021-11-26T09:35:41Z

On 25/11/2021 15:10, Hannes Reinecke wrote:
> static void hpsa_drain_accel_commands(struct ctlr_info *h)
> {
> - struct CommandList *c = NULL;
> - int i, accel_cmds_out;
> - int refcount;
> + struct hpsa_command_iter_data iter_data = {
> + .h = h,
> + };
>
> do { /* wait for all outstanding ioaccel commands to drain out */
> - accel_cmds_out = 0;
> - for (i = 0; i < h->nr_cmds; i++) {
> - c = h->cmd_pool + i;
> - refcount = atomic_inc_return(&c->refcount);
> - if (refcount > 1) /* Command is allocated */
> - accel_cmds_out += is_accelerated_cmd(c);
> - cmd_free(h, c);
> - }
> - if (accel_cmds_out <= 0)
> + iter_data.count = 0;
> + scsi_host_busy_iter(h->scsi_host,
> + hpsa_drain_accel_commands_iter,
> + &iter_data);

I haven't following this code exactly, but I assume that you want to
iter the reserved requests as well (or in other places in others drivers
in this series). For that to work we need to call
blk_mq_start_request(), right? I could not see it called.

> + if (iter_data.count <= 0)
> break;
> msleep(100);
> } while (1);
> -- 2.29.2