linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
	linux-block@vger.kernel.org, Omar Sandoval <osandov@osandov.com>
Cc: Omar Sandoval <osandov@fb.com>,
	Damien Le Moal <Damien.LeMoal@wdc.com>,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>
Subject: Re: [PATCH blktests 1/2] zbd/rc: Support dm-crypt
Date: Tue, 13 Jul 2021 06:59:54 -0700	[thread overview]
Message-ID: <17ed9d08-ecd2-abb6-544e-33bff88b7504@acm.org> (raw)
In-Reply-To: <20210713101239.269789-2-shinichiro.kawasaki@wdc.com>

On 7/13/21 3:12 AM, Shin'ichiro Kawasaki wrote:
> -	# Parse dm table lines for dm-linear or dm-flakey target
> +	if _test_dev_has_dm_map crypt; then
> +		dev_idx=6
> +		off_idx=7
> +	fi
> +
> +	# Parse dm table lines for dm-linear, dm-flakey or dm-crypt target
>  	while read -r -a tbl_line; do
>  		local -i map_start=${tbl_line[0]}
>  		local -i map_end=$((tbl_line[0] + tbl_line[1]))
> @@ -355,10 +362,11 @@ _get_dev_container_and_sector() {
>  			continue
>  		fi
>  
> -		offset=${tbl_line[4]}
> -		if ! cont_dev=$(_get_dev_path_by_id "${tbl_line[3]}"); then
> +		offset=${tbl_line[off_idx]}
> +		if ! cont_dev=$(_get_dev_path_by_id \
> +					"${tbl_line[dev_idx]}"); then
>  			echo -n "Cannot access to container device: "
> -			echo "${tbl_line[3]}"
> +			echo "${tbl_line[dev_idx]}"
>  			return 1
>  		fi

To me the above code looks like code that is hard to maintain. Can the
above parser be replaced by reading /sys/block/*/slaves? An example from
my workstation for dm-crypt:

$ ls /sys/block/dm-0/slaves
nvme0n1p2

Thanks,

Bart.

  reply	other threads:[~2021-07-13 14:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13 10:12 [PATCH blktests 0/2] zbd: Support dm-crypt Shin'ichiro Kawasaki
2021-07-13 10:12 ` [PATCH blktests 1/2] zbd/rc: " Shin'ichiro Kawasaki
2021-07-13 13:59   ` Bart Van Assche [this message]
2021-07-14 11:13     ` Shinichiro Kawasaki
2021-07-13 10:12 ` [PATCH blktests 2/2] zbd/007: Reset test target zones at test end Shin'ichiro Kawasaki
2021-07-26 19:02 ` [PATCH blktests 0/2] zbd: Support dm-crypt Omar Sandoval
2021-07-27  2:17   ` Shinichiro Kawasaki

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=17ed9d08-ecd2-abb6-544e-33bff88b7504@acm.org \
    --to=bvanassche@acm.org \
    --cc=Chaitanya.Kulkarni@wdc.com \
    --cc=Damien.LeMoal@wdc.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=linux-block@vger.kernel.org \
    --cc=osandov@fb.com \
    --cc=osandov@osandov.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;
as well as URLs for NNTP newsgroup(s).