Linux block layer
 help / color / mirror / Atom feed
From: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	Omar Sandoval <osandov@osandov.com>,
	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: Wed, 14 Jul 2021 11:13:06 +0000	[thread overview]
Message-ID: <20210714111306.lyty7pekcqygg3vz@shindev> (raw)
In-Reply-To: <17ed9d08-ecd2-abb6-544e-33bff88b7504@acm.org>

On Jul 13, 2021 / 06:59, Bart Van Assche wrote:
> 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

Hi, Bart. Thanks for the suggestion, but I don't think sysfs slaves attribute
will simplify the code. The helper function _get_dev_container_and_sector()
requires pairs of 'map starting sector offset' and 'map target device'. Dm
table provides both of them, but the sysfs slaves attribute provides only the
map target device. As far as I understand, the helper function must parse the
dm table anyway to get the map starting sector offsets, and paired devices.

-- 
Best Regards,
Shin'ichiro Kawasaki

  reply	other threads:[~2021-07-14 11:13 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
2021-07-14 11:13     ` Shinichiro Kawasaki [this message]
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=20210714111306.lyty7pekcqygg3vz@shindev \
    --to=shinichiro.kawasaki@wdc.com \
    --cc=Chaitanya.Kulkarni@wdc.com \
    --cc=Damien.LeMoal@wdc.com \
    --cc=Johannes.Thumshirn@wdc.com \
    --cc=bvanassche@acm.org \
    --cc=linux-block@vger.kernel.org \
    --cc=osandov@fb.com \
    --cc=osandov@osandov.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