public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Block <bblock@linux.vnet.ibm.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org,
	Johannes Thumshirn <jthumshirn@suse.de>
Subject: Re: [PATCH 9/9] bsg: split handling of SCSI CDBs vs transport requeues
Date: Tue, 24 Oct 2017 18:58:08 +0200	[thread overview]
Message-ID: <20171024165808.GB26380@bblock-ThinkPad-W530> (raw)
In-Reply-To: <20171003104845.10417-10-hch@lst.de>

> +static int bsg_transport_complete_rq(struct request *rq, struct sg_io_v4 *hdr)
> +{
> +	struct bsg_job *job = blk_mq_rq_to_pdu(rq);
> +	int ret = 0;
> +
> +	/*
> +	 * The assignments below don't make much sense, but are kept for
> +	 * bug by bug backwards compatibility:
> +	 */
> +	hdr->device_status = job->result & 0xff;
> +	hdr->transport_status = host_byte(job->result);
> +	hdr->driver_status = driver_byte(job->result);
> +	hdr->info = 0;
> +	if (hdr->device_status || hdr->transport_status || hdr->driver_status)
> +		hdr->info |= SG_INFO_CHECK;
> +	hdr->response_len = 0;
> +
> +	if (job->result < 0) {
> +		/* we're only returning the result field in the reply */
> +		job->reply_len = sizeof(u32);
> +		ret = job->result;
> +	}
> +
> +	if (job->reply_len && hdr->response) {
> +		int len = min(hdr->max_response_len, job->reply_len);
> +
> +		if (copy_to_user(ptr64(hdr->response), job->reply, len))
> +			ret = -EFAULT;
> +		else
> +			hdr->response_len = len;
> +	}
> +
> +	/* we assume all request payload was transferred, residual == 0 */
> +	hdr->dout_resid = 0;
> +
> +	if (rq->next_rq) {
> +		unsigned int rsp_len = blk_rq_bytes(rq->next_rq);
> +
> +		if (WARN_ON(job->reply_payload_rcv_len > rsp_len))

This gives my a lot of new Warnings when running my tests on zFCP, non
of which happen when I run on 4.13.

After browsing the source some, I figured this is because in comparison
to the old code, blk_rq_bytes() is now called after we finished the
blk-request already and blk_update_bidi_request()+blk_update_request()
was already called. This will update rq->__data_len, and thus the call
here to get rsp_len will get a wrong value. Thus the warnings, and the
following calculation is actually wrong.

I figure you can just replace this call for blk_rq_bytes() with
'job->reply_payload.payload_len'. Its essentially the same value, but
the later is not changed after the job is committed as far as I could see
in the source. Driver makes use of it, but only reading as far as I
could make out after browsing the code for a bit.

I did a quick test with that change in place and that seems to work fine
now. As far as my tests go, they behave as they did before.


                                                    Beste Grüße / Best regards,
                                                      - Benjamin Block

> +			hdr->din_resid = 0;
> +		else
> +			hdr->din_resid = rsp_len - job->reply_payload_rcv_len;
> +	} else {
> +		hdr->din_resid = 0;
> +	}
> +
> +	return ret;
> +}
> +

--
Linux on z Systems Development         /         IBM Systems & Technology Group
		  IBM Deutschland Research & Development GmbH
Vorsitz. AufsR.: Martina Koederitz     /        Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294

  parent reply	other threads:[~2017-10-24 16:58 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-03 10:48 [RFC] bsg-lib interface cleanup Christoph Hellwig
2017-10-03 10:48 ` [PATCH 1/9] bsg-lib: fix use-after-free under memory-pressure Christoph Hellwig
2017-10-04  6:16   ` Hannes Reinecke
2017-10-04  8:54   ` Johannes Thumshirn
2017-10-03 10:48 ` [PATCH 2/9] bfa: don't reset max_segments for every bsg request Christoph Hellwig
2017-10-04  6:16   ` Hannes Reinecke
2017-10-04  8:54   ` Johannes Thumshirn
2017-10-03 10:48 ` [PATCH 3/9] libfc: don't assign resid_len in fc_lport_bsg_request Christoph Hellwig
2017-10-04  6:17   ` Hannes Reinecke
2017-10-04  8:54   ` Johannes Thumshirn
2017-10-03 10:48 ` [PATCH 4/9] qla2xxx: don't break the bsg-lib abstractions Christoph Hellwig
2017-10-04  6:20   ` Hannes Reinecke
2017-10-04  8:54   ` Johannes Thumshirn
2017-10-05 16:58   ` Madhani, Himanshu
2017-10-03 10:48 ` [PATCH 5/9] scsi_transport_sas: check reply payload length instead of bidi request Christoph Hellwig
2017-10-04  6:21   ` Hannes Reinecke
2017-10-04  8:53   ` Johannes Thumshirn
2017-10-03 10:48 ` [PATCH 6/9] bsg-lib: introduce a timeout field in struct bsg_job Christoph Hellwig
2017-10-04  6:21   ` Hannes Reinecke
2017-10-04  8:53   ` Johannes Thumshirn
2017-10-16 16:30   ` Benjamin Block
2017-10-03 10:48 ` [PATCH 7/9] bsg-lib: remove bsg_job.req Christoph Hellwig
2017-10-04  6:22   ` Hannes Reinecke
2017-10-04  8:52   ` Johannes Thumshirn
2017-10-16 16:36   ` Benjamin Block
2017-10-03 10:48 ` [PATCH 8/9] block: pass full fmode_t to blk_verify_command Christoph Hellwig
2017-10-04  6:23   ` Hannes Reinecke
2017-10-04  8:52   ` Johannes Thumshirn
2017-10-16 16:50   ` Benjamin Block
2017-10-03 10:48 ` [PATCH 9/9] bsg: split handling of SCSI CDBs vs transport requeues Christoph Hellwig
2017-10-04  6:26   ` Hannes Reinecke
2017-10-04  7:18   ` Johannes Thumshirn
2017-10-04  7:20     ` Christoph Hellwig
2017-10-04  8:52       ` Johannes Thumshirn
2017-10-04  7:18   ` Johannes Thumshirn
2017-10-19 15:59   ` Benjamin Block
2017-10-20 16:26     ` Christoph Hellwig
2017-10-20 16:47       ` Benjamin Block
2017-10-23  6:16         ` Martin K. Petersen
2017-10-23  6:29           ` Christoph Hellwig
2017-10-23  7:17             ` Martin K. Petersen
2017-10-24 17:46               ` Jens Axboe
2017-10-24 16:58   ` Benjamin Block [this message]
2017-10-04 14:35 ` [RFC] bsg-lib interface cleanup Jens Axboe
2017-10-17  3:50 ` Martin K. Petersen

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=20171024165808.GB26380@bblock-ThinkPad-W530 \
    --to=bblock@linux.vnet.ibm.com \
    --cc=hch@lst.de \
    --cc=jthumshirn@suse.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox