Flexible I/O Tester development
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Damien Le Moal <damien.lemoal@wdc.com>,
	fio@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Cc: Matias Bjorling <matias.bjorling@wdc.com>,
	Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
	Dmitry Fomichev <dmitry.fomichev@wdc.com>
Subject: Re: [PATCH 2/8] sg: Avoid READ CAPACITY failures
Date: Wed, 20 Feb 2019 08:03:03 -0800	[thread overview]
Message-ID: <1550678583.93548.21.camel@acm.org> (raw)
In-Reply-To: <20190220071725.8487-3-damien.lemoal@wdc.com>

On Wed, 2019-02-20 at 16:17 +0900, Damien Le Moal wrote:
> From: Dmitry Fomichev <dmitry.fomichev@wdc.com>
> 
> Some SCSI devices (very large disks or SMR zoned disks in particular)
> do not support the READ CAPACITY(10) command and only reply
> successfully to the READ CAPACITY(16) command. This patch forces the
> execution READ CAPACITY(16) if READ CAPACITY(10) fails with
> CHECK CONDITION.
> 
> Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
> ---
>  engines/sg.c | 45 ++++++++++++++++++++++++++++++---------------
>  1 file changed, 30 insertions(+), 15 deletions(-)
> 
> diff --git a/engines/sg.c b/engines/sg.c
> index 3cc068f3..9105c24c 100644
> --- a/engines/sg.c
> +++ b/engines/sg.c
> @@ -723,6 +723,8 @@ static int fio_sgio_read_capacity(struct thread_data *td, unsigned int *bs,
>  	 * io_u structures, which are not initialized until later.
>  	 */
>  	struct sg_io_hdr hdr;
> +	unsigned long long hlba;
> +	unsigned int blksz = 0;
>  	unsigned char cmd[16];
>  	unsigned char sb[64];
>  	unsigned char buf[32];  // read capacity return
> @@ -759,16 +761,21 @@ static int fio_sgio_read_capacity(struct thread_data *td, unsigned int *bs,
>  		return ret;
>  	}
>  
> -	*bs	 = ((unsigned long) buf[4] << 24) | ((unsigned long) buf[5] << 16) |
> -		   ((unsigned long) buf[6] << 8) | (unsigned long) buf[7];
> -	*max_lba = ((unsigned long) buf[0] << 24) | ((unsigned long) buf[1] << 16) |
> -		   ((unsigned long) buf[2] << 8) | (unsigned long) buf[3];
> +	if (hdr.info & SG_INFO_CHECK) {
> +		/* RCAP(10) might be unsupported by device. Force RCAP(16) */
> +		hlba = MAX_10B_LBA;
> +	} else {
> +		blksz	 = ((unsigned long) buf[4] << 24) | ((unsigned long) buf[5] << 16) |
> +			   ((unsigned long) buf[6] << 8) | (unsigned long) buf[7];
> +		hlba	 = ((unsigned long) buf[0] << 24) | ((unsigned long) buf[1] << 16) |
> +			   ((unsigned long) buf[2] << 8) | (unsigned long) buf[3];
> +	}

Please introduce get_unaligned_be32() and get_unaligned_be64() functions in fio
such that this code becomes easier to read and to maintain.

Thanks,

Bart.


  reply	other threads:[~2019-02-20 16:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-20  7:17 [PATCH 0/8] ZBD support fixes Damien Le Moal
2019-02-20  7:17 ` [PATCH 1/8] zbd: Fix partition block device handling Damien Le Moal
2019-02-20 16:00   ` Bart Van Assche
2019-02-21  1:47     ` Damien Le Moal
2019-02-20  7:17 ` [PATCH 2/8] sg: Avoid READ CAPACITY failures Damien Le Moal
2019-02-20 16:03   ` Bart Van Assche [this message]
2019-02-20  7:17 ` [PATCH 3/8] t/zbd: Fix handling of partition devices Damien Le Moal
2019-02-20  7:17 ` [PATCH 4/8] t/zbd: Fix test 2 and 3 result handling Damien Le Moal
2019-02-20 16:06   ` Bart Van Assche
2019-02-20  7:17 ` [PATCH 5/8] t/zbd: Default to using blkzone tool Damien Le Moal
2019-02-20  7:17 ` [PATCH 6/8] zbd: Fix zone locking for async I/O engines Damien Le Moal
2019-02-20  7:17 ` [PATCH 7/8] zbd: Avoid async I/O multi-job workload deadlock Damien Le Moal
2019-02-20  7:17 ` [PATCH 8/8] t/zbd: Add multi-job libaio test Damien Le Moal

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=1550678583.93548.21.camel@acm.org \
    --to=bvanassche@acm.org \
    --cc=axboe@kernel.dk \
    --cc=damien.lemoal@wdc.com \
    --cc=dmitry.fomichev@wdc.com \
    --cc=fio@vger.kernel.org \
    --cc=matias.bjorling@wdc.com \
    --cc=shinichiro.kawasaki@wdc.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox