Re: [PATCH 4/4] IB/srpt: Convert to percpu_ida tag allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +static struct srpt_send_ioctx *srpt_tag_to_ioctx(struct srpt_rdma_ch *ch,
> +						 int tag)
> +{
> +	return &((struct srpt_send_ioctx *)ch->sess->sess_cmd_map)[tag];
> +}
> +
> +static int srpt_ioctx_to_tag(struct srpt_rdma_ch *ch,
> +			     struct srpt_send_ioctx *ioctx)
> +{
> +	return ioctx - (struct srpt_send_ioctx *)ch->sess->sess_cmd_map;
> +}

This is really something the core code should be doing..

I have to admit I really don't understand why the target core is trying
to force everyone to use the ida allocator - the 'tag' concept here
isn't really useful to most drivers.

> +	for (i = 0; i < ch->rq_size; i++) {
> +		struct srpt_send_ioctx *ioctx = srpt_tag_to_ioctx(ch, i);
> +
> +		if (srpt_init_ioctx(sdev, &ioctx->ioctx, ch->rsp_size,
> +				    DMA_TO_DEVICE) < 0) {
> +			pr_err("Initialization of I/O context %d/%d failed\n",
> +			       i, ch->rq_size);
> +			goto deregister_session;
> +		}
> +		ioctx->ch = ch;
> +	}

E.g. here it would be really nice if the the driver had to just provide
init_cmd and cleanup_cmd methods, and the core would iterate over
the map, and call them on each cmds without the need for the
casts and pointer arithmetics in each driver.

But I guess for now this will do it:

Reviewed-by: Christoph Hellwig <hch@xxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux