All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@fb.com>
To: Bart Van Assche <Bart.VanAssche@sandisk.com>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Cc: "hch@lst.de" <hch@lst.de>, "ming.lei@redhat.com" <ming.lei@redhat.com>
Subject: Re: [PATCH 5/6] mtip32xx: convert internal command issue to block IO path
Date: Thu, 27 Apr 2017 17:35:39 -0600	[thread overview]
Message-ID: <5b667f22-d12a-7e57-237a-155faba55409@fb.com> (raw)
In-Reply-To: <1493335751.2625.19.camel@sandisk.com>

On 04/27/2017 05:29 PM, Bart Van Assche wrote:
> On Thu, 2017-04-27 at 16:51 -0600, Jens Axboe wrote:
>> @@ -1114,10 +1121,16 @@ static int mtip_exec_internal_command(struct mtip_port *port,
>>  					u32 opts,
>>  					unsigned long timeout)
>>  {
>> -	struct mtip_cmd_sg *command_sg;
>>  	DECLARE_COMPLETION_ONSTACK(wait);
>>  	struct mtip_cmd *int_cmd;
>>  	struct driver_data *dd = port->dd;
>> +	struct request *rq;
>> +	struct mtip_int_cmd icmd = {
>> +		.fis_len = fis_len,
>> +		.buffer = buffer,
>> +		.buf_len = buf_len,
>> +		.opts = opts
>> +	};
>>  	int rv = 0;
>>  	unsigned long start;
>>  
>> @@ -1132,6 +1145,8 @@ static int mtip_exec_internal_command(struct mtip_port *port,
>>  		dbg_printk(MTIP_DRV_NAME "Unable to allocate tag for PIO cmd\n");
>>  		return -EFAULT;
>>  	}
>> +	rq = blk_mq_rq_from_pdu(int_cmd);
>> +	rq->end_io_data = &icmd;
>>  
>>  	set_bit(MTIP_PF_IC_ACTIVE_BIT, &port->flags);
>>  
>> @@ -1158,30 +1173,10 @@ static int mtip_exec_internal_command(struct mtip_port *port,
>>  	/* Copy the command to the command table */
>>  	memcpy(int_cmd->command, fis, fis_len*4);
>>  
>> -	/* Populate the SG list */
>> -	int_cmd->command_header->opts =
>> -		 __force_bit2int cpu_to_le32(opts | fis_len);
>> -	if (buf_len) {
>> -		command_sg = int_cmd->command + AHCI_CMD_TBL_HDR_SZ;
>> -
>> -		command_sg->info =
>> -			__force_bit2int cpu_to_le32((buf_len-1) & 0x3FFFFF);
>> -		command_sg->dba	=
>> -			__force_bit2int cpu_to_le32(buffer & 0xFFFFFFFF);
>> -		command_sg->dba_upper =
>> -			__force_bit2int cpu_to_le32((buffer >> 16) >> 16);
>> -
>> -		int_cmd->command_header->opts |=
>> -			__force_bit2int cpu_to_le32((1 << 16));
>> -	}
>> -
>> -	/* Populate the command header */
>> -	int_cmd->command_header->byte_count = 0;
>> -
>>  	start = jiffies;
>>  
>> -	/* Issue the command to the hardware */
>> -	mtip_issue_non_ncq_command(port, MTIP_TAG_INTERNAL);
>> +	/* insert request and run queue */
>> +	blk_execute_rq_nowait(rq->q, NULL, rq, true, NULL);
>>  
>>  	/* Wait for the command to complete or timeout. */
>>  	rv = wait_for_completion_interruptible_timeout(&wait,
> 
> Hello Jens,
> 
> What will happen upon timeout? Will the end_io_data pointer be dereferenced if
> a timeout occurs? Can that cause the completion function to access data on the
> stack after it has been freed?

Good point - since we know get timeouts courtesy of blk-mq, I will kill
this individual timeout to avoid having any races there.

-- 
Jens Axboe

  reply	other threads:[~2017-04-27 23:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-27 22:51 [PATCH 0/6] Fixup mtip32xx for scheduling Jens Axboe
2017-04-27 22:51 ` [PATCH 1/6] mtip32xx: get rid of 'atomic' argument to mtip_exec_internal_command() Jens Axboe
2017-04-27 23:19   ` Bart Van Assche
2017-04-27 22:51 ` [PATCH 2/6] mtip32xx: kill atomic argument to mtip_quiesce_io() Jens Axboe
2017-04-27 23:20   ` Bart Van Assche
2017-04-27 22:51 ` [PATCH 3/6] mtip32xx: abstract out "are any commands active" helper Jens Axboe
2017-04-27 23:21   ` Bart Van Assche
2017-04-27 22:51 ` [PATCH 4/6] blk-mq: don't bypass scheduler for reserved requests Jens Axboe
2017-04-28  4:04   ` Ming Lei
2017-04-28  4:13     ` Jens Axboe
2017-04-27 22:51 ` [PATCH 5/6] mtip32xx: convert internal command issue to block IO path Jens Axboe
2017-04-27 23:29   ` Bart Van Assche
2017-04-27 23:35     ` Jens Axboe [this message]
2017-04-27 22:51 ` [PATCH 6/6] Revert "mtip32xx: pass BLK_MQ_F_NO_SCHED" Jens Axboe
2017-04-28  4:06   ` Ming Lei
2017-04-27 23:12 ` [PATCH 0/6] Fixup mtip32xx for scheduling Jens Axboe
2017-04-28 14:01 [PATCH v2 " Jens Axboe
2017-04-28 14:01 ` [PATCH 5/6] mtip32xx: convert internal command issue to block IO path Jens Axboe
2017-04-28 14:31 [PATCH v2a 0/6]: Fixup mtip32xx for scheduling Jens Axboe
2017-04-28 14:31 ` [PATCH 5/6] mtip32xx: convert internal command issue to block IO path Jens Axboe
2017-04-28 14:49   ` Christoph Hellwig
2017-04-28 16:43     ` 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=5b667f22-d12a-7e57-237a-155faba55409@fb.com \
    --to=axboe@fb.com \
    --cc=Bart.VanAssche@sandisk.com \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    /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.