All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shaohua Li <shli@fb.com>
To: linux-ide@vger.kernel.org
Cc: Kernel-team@fb.com, Jens Axboe <axboe@fb.com>,
	Tejun Heo <tj@kernel.org>, Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH v2 3/3] libata: use blk taging
Date: Fri, 9 Jan 2015 10:15:29 -0800	[thread overview]
Message-ID: <20150109181529.GA1301458@devbig257.prn2.facebook.com> (raw)
In-Reply-To: <546516bb62c91671b1464e6a7c68eebc8422efe5.1418928090.git.shli@fb.com>

Ping!

On Thu, Dec 18, 2014 at 10:46:22AM -0800, Shaohua Li wrote:
> libata uses its own tag management which is duplication and the
> implementation is poor. And if we switch to blk-mq, tag is build-in.
> It's time to switch to generic taging.
> 
> The SAS driver has its own tag management, and looks we can't directly
> map the host controler tag to SATA tag. So I just bypassed the SAS case.
> 
> Cc: Jens Axboe <axboe@fb.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Christoph Hellwig <hch@infradead.org>
> Signed-off-by: Shaohua Li <shli@fb.com>
> ---
>  drivers/ata/libata-core.c | 20 ++++++++++++++------
>  drivers/ata/libata-scsi.c |  4 +++-
>  drivers/ata/libata.h      |  2 +-
>  include/linux/libata.h    |  1 +
>  4 files changed, 19 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index 5c84fb5..a27d00f 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -1585,8 +1585,9 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
>  	else
>  		tag = 0;
>  
> -	if (test_and_set_bit(tag, &ap->qc_allocated))
> -		BUG();
> +	BUG_ON((!ap->scsi_host && test_and_set_bit(tag, &ap->qc_allocated)) ||
> +		(ap->scsi_host && dev->sdev &&
> +			blk_queue_find_tag(dev->sdev->request_queue, tag)));
>  	qc = __ata_qc_from_tag(ap, tag);
>  
>  	qc->tag = tag;
> @@ -4737,7 +4738,7 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
>   *	None.
>   */
>  
> -static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap)
> +static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap, int blktag)
>  {
>  	struct ata_queued_cmd *qc = NULL;
>  	unsigned int max_queue = ap->host->n_tags;
> @@ -4747,6 +4748,12 @@ static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap)
>  	if (unlikely(ap->pflags & ATA_PFLAG_FROZEN))
>  		return NULL;
>  
> +	if (ap->scsi_host) {
> +		qc = __ata_qc_from_tag(ap, blktag);
> +		qc->tag = blktag;
> +		return qc;
> +	}
> +
>  	for (i = 0, tag = ap->last_tag + 1; i < max_queue; i++, tag++) {
>  		tag = tag < max_queue ? tag : 0;
>  
> @@ -4773,12 +4780,12 @@ static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap)
>   *	None.
>   */
>  
> -struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev)
> +struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev, int blktag)
>  {
>  	struct ata_port *ap = dev->link->ap;
>  	struct ata_queued_cmd *qc;
>  
> -	qc = ata_qc_new(ap);
> +	qc = ata_qc_new(ap, blktag);
>  	if (qc) {
>  		qc->scsicmd = NULL;
>  		qc->ap = ap;
> @@ -4812,7 +4819,8 @@ void ata_qc_free(struct ata_queued_cmd *qc)
>  	tag = qc->tag;
>  	if (likely(ata_tag_valid(tag))) {
>  		qc->tag = ATA_TAG_POISON;
> -		clear_bit(tag, &ap->qc_allocated);
> +		if (!ap->scsi_host)
> +			clear_bit(tag, &ap->qc_allocated);
>  	}
>  }
>  
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index e364e86..94339c2 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -756,7 +756,7 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev,
>  {
>  	struct ata_queued_cmd *qc;
>  
> -	qc = ata_qc_new_init(dev);
> +	qc = ata_qc_new_init(dev, cmd->request->tag);
>  	if (qc) {
>  		qc->scsicmd = cmd;
>  		qc->scsidone = cmd->scsi_done;
> @@ -3666,6 +3666,8 @@ int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht)
>  		 */
>  		shost->max_host_blocked = 1;
>  
> +		scsi_init_shared_tag_map(shost, host->n_tags);
> +
>  		rc = scsi_add_host_with_dma(ap->scsi_host,
>  						&ap->tdev, ap->host->dev);
>  		if (rc)
> diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
> index 5f4e0cc..4040513 100644
> --- a/drivers/ata/libata.h
> +++ b/drivers/ata/libata.h
> @@ -63,7 +63,7 @@ extern struct ata_link *ata_dev_phys_link(struct ata_device *dev);
>  extern void ata_force_cbl(struct ata_port *ap);
>  extern u64 ata_tf_to_lba(const struct ata_taskfile *tf);
>  extern u64 ata_tf_to_lba48(const struct ata_taskfile *tf);
> -extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev);
> +extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev, int tag);
>  extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
>  			   u64 block, u32 n_block, unsigned int tf_flags,
>  			   unsigned int tag);
> diff --git a/include/linux/libata.h b/include/linux/libata.h
> index 2d18241..5f1c5606 100644
> --- a/include/linux/libata.h
> +++ b/include/linux/libata.h
> @@ -1344,6 +1344,7 @@ extern struct device_attribute *ata_common_sdev_attrs[];
>  	.ioctl			= ata_scsi_ioctl,		\
>  	.queuecommand		= ata_scsi_queuecmd,		\
>  	.can_queue		= ATA_DEF_QUEUE,		\
> +	.tag_alloc_policy	= BLK_TAG_ALLOC_RR,		\
>  	.this_id		= ATA_SHT_THIS_ID,		\
>  	.cmd_per_lun		= ATA_SHT_CMD_PER_LUN,		\
>  	.emulated		= ATA_SHT_EMULATED,		\
> -- 
> 1.8.1
> 

  reply	other threads:[~2015-01-09 18:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-18 18:46 [PATCH v2 1/3] block: support different tag allocation policy Shaohua Li
2014-12-18 18:46 ` [PATCH v2 2/3] blk-mq: add " Shaohua Li
2014-12-22 23:25   ` Jens Axboe
2015-01-02 19:43     ` Shaohua Li
2014-12-18 18:46 ` [PATCH v2 3/3] libata: use blk taging Shaohua Li
2015-01-09 18:15   ` Shaohua Li [this message]
2015-01-09 21:43     ` Tejun Heo
2015-01-09 21:59       ` Shaohua Li
2015-01-09 22:12         ` Shaohua Li
2015-01-14  8:08           ` Dan Williams
2015-01-14 16:30             ` Shaohua Li
2015-01-14 17:09               ` Dan Williams
     [not found]               ` <CAPcyv4hMwpGzeaovnXtqyYFM46wodRamZd7CNVoR43JJYh0Tjg@mail.gmail.com>
2015-01-14 17:13                 ` Shaohua Li
2015-01-14 17:37                   ` Dan Williams
2015-01-15  9:28                     ` Christoph Hellwig
2015-01-15 15:02                       ` Tejun Heo
2015-01-15 18:40                       ` Shaohua Li
2015-01-15 18:57                         ` Tejun Heo
2015-01-15 18:59                         ` Dan Williams
2015-01-15 19:03                           ` Tejun Heo
2015-01-15 19:15                           ` Jens Axboe
2015-01-15 19:51                             ` Dan Williams
2015-01-15 22:28                               ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150109181529.GA1301458@devbig257.prn2.facebook.com \
    --to=shli@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=axboe@fb.com \
    --cc=hch@infradead.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.