All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <Damien.LeMoal@wdc.com>
To: Milan Broz <gmazyland@gmail.com>,
	"dm-devel@redhat.com" <dm-devel@redhat.com>,
	Mike Snitzer <snitzer@redhat.com>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	Jens Axboe <axboe@kernel.dk>
Subject: Re: [dm-devel] [PATCH 11/11] dm crypt: Fix zoned block device support
Date: Thu, 20 May 2021 00:00:34 +0000	[thread overview]
Message-ID: <DM6PR04MB7081B7965B612300F87C77F9E72A9@DM6PR04MB7081.namprd04.prod.outlook.com> (raw)
In-Reply-To: cbbf8310-cc46-7925-c8e9-1edb23d245ca@gmail.com

On 2021/05/20 0:46, Milan Broz wrote:
> On 19/05/2021 04:55, Damien Le Moal wrote:
>> Zone append BIOs (REQ_OP_ZONE_APPEND) always specify the start sector
>> of the zone to be written instead of the actual sector location to
>> write. The write location is determined by the device and returned to
>> the host upon completion of the operation. This interface, while simple
>> and efficient for writing into sequential zones of a zoned block
>> device, is incompatible with the use of sector values to calculate a
>> cypher block IV. All data written in a zone end up using the same IV
>> values corresponding to the first sectors of the zone, but read
>> operation will specify any sector within the zone resulting in an IV
>> mismatch between encryption and decryption.
>>
>> To solve this problem, report to DM core that zone append operations are
>> not supported. This result in the zone append operations being emulated
>> using regular write operations.
> 
> Yes, I think this is definitive better approach and it does not need
> to fiddle with dm-crypt crypto, thanks.
> 
> Just one comment below:
> 
>>
>> Reported-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
>> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
>> ---
>>  drivers/md/dm-crypt.c | 24 +++++++++++++++++++-----
>>  1 file changed, 19 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
>> index f410ceee51d7..44339823371c 100644
>> --- a/drivers/md/dm-crypt.c
>> +++ b/drivers/md/dm-crypt.c
>> @@ -3280,14 +3280,28 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
>>  	}
>>  	cc->start = tmpll;
>>  
>> -	/*
>> -	 * For zoned block devices, we need to preserve the issuer write
>> -	 * ordering. To do so, disable write workqueues and force inline
>> -	 * encryption completion.
>> -	 */
>>  	if (bdev_is_zoned(cc->dev->bdev)) {
>> +		/*
>> +		 * For zoned block devices, we need to preserve the issuer write
>> +		 * ordering. To do so, disable write workqueues and force inline
>> +		 * encryption completion.
>> +		 */
>>  		set_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags);
>>  		set_bit(DM_CRYPT_WRITE_INLINE, &cc->flags);
>> +
>> +		/*
>> +		 * All zone append writes to a zone of a zoned block device will
>> +		 * have the same BIO sector, the start of the zone. When the
>> +		 * cypher IV mode uses sector values, all data targeting a
>> +		 * zone will be encrypted using the first sector numbers of the
>> +		 * zone. This will not result in write errors but will
>> +		 * cause most reads to fail as reads will use the sector values
>> +		 * for the actual data locations, resulting in IV mismatch.
>> +		 * To avoid this problem, ask DM core to emulate zone append
>> +		 * operations with regular writes.
>> +		 */
>> +		DMWARN("Zone append operations will be emulated");
> 
> Do we really want to fill log with these?

I added this to signal to the user, indirectly, that performance may be impacted
as the zone write locking mechanism used for the emulation essentially limits
write operations to at most 1 per zone. Overall, the drive QD can still be high,
but per zone, it will be at most one write per zone at any time.

> (I know it is not a good example in this context - but during online reencryption,
> dm-crypt table segments are continuously reloaded and because the message is in in table constructor,
> it will flood the syslog with repeated message.)
> 
> Maybe move it to debug or remove it completely?

OK. I will change this to debug.

> What would be nice to have some zoned info extension to lsblk so we can investigate
> storage stack over zoned device (if there is some sysfs knob to detect it, it should be trivial)... 

Yes, it is simple to add a sysfs attribute like
/sys/block/xxx/queue/zone_append_emulated.

That can be done later though. I will see if that can really help applications
or FSes. Right now, I do not see the need for this attribute. After all, all
scsi SMR drives already have zone append emulation (in the SD driver).

Thanks for the review. Will send V2 later today.

> 
> Thanks,
> Milan
> 
>> +		ti->emulate_zone_append = true;
>>  	}
>>  
>>  	if (crypt_integrity_aead(cc) || cc->integrity_iv_size) {
>>
> 
> 


-- 
Damien Le Moal
Western Digital Research

WARNING: multiple messages have this Message-ID (diff)
From: Damien Le Moal <Damien.LeMoal@wdc.com>
To: Milan Broz <gmazyland@gmail.com>,
	"dm-devel@redhat.com" <dm-devel@redhat.com>,
	Mike Snitzer <snitzer@redhat.com>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	Jens Axboe <axboe@kernel.dk>
Subject: Re: [dm-devel] [PATCH 11/11] dm crypt: Fix zoned block device support
Date: Thu, 20 May 2021 00:00:34 +0000	[thread overview]
Message-ID: <DM6PR04MB7081B7965B612300F87C77F9E72A9@DM6PR04MB7081.namprd04.prod.outlook.com> (raw)
In-Reply-To: cbbf8310-cc46-7925-c8e9-1edb23d245ca@gmail.com

On 2021/05/20 0:46, Milan Broz wrote:
> On 19/05/2021 04:55, Damien Le Moal wrote:
>> Zone append BIOs (REQ_OP_ZONE_APPEND) always specify the start sector
>> of the zone to be written instead of the actual sector location to
>> write. The write location is determined by the device and returned to
>> the host upon completion of the operation. This interface, while simple
>> and efficient for writing into sequential zones of a zoned block
>> device, is incompatible with the use of sector values to calculate a
>> cypher block IV. All data written in a zone end up using the same IV
>> values corresponding to the first sectors of the zone, but read
>> operation will specify any sector within the zone resulting in an IV
>> mismatch between encryption and decryption.
>>
>> To solve this problem, report to DM core that zone append operations are
>> not supported. This result in the zone append operations being emulated
>> using regular write operations.
> 
> Yes, I think this is definitive better approach and it does not need
> to fiddle with dm-crypt crypto, thanks.
> 
> Just one comment below:
> 
>>
>> Reported-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
>> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
>> ---
>>  drivers/md/dm-crypt.c | 24 +++++++++++++++++++-----
>>  1 file changed, 19 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
>> index f410ceee51d7..44339823371c 100644
>> --- a/drivers/md/dm-crypt.c
>> +++ b/drivers/md/dm-crypt.c
>> @@ -3280,14 +3280,28 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
>>  	}
>>  	cc->start = tmpll;
>>  
>> -	/*
>> -	 * For zoned block devices, we need to preserve the issuer write
>> -	 * ordering. To do so, disable write workqueues and force inline
>> -	 * encryption completion.
>> -	 */
>>  	if (bdev_is_zoned(cc->dev->bdev)) {
>> +		/*
>> +		 * For zoned block devices, we need to preserve the issuer write
>> +		 * ordering. To do so, disable write workqueues and force inline
>> +		 * encryption completion.
>> +		 */
>>  		set_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags);
>>  		set_bit(DM_CRYPT_WRITE_INLINE, &cc->flags);
>> +
>> +		/*
>> +		 * All zone append writes to a zone of a zoned block device will
>> +		 * have the same BIO sector, the start of the zone. When the
>> +		 * cypher IV mode uses sector values, all data targeting a
>> +		 * zone will be encrypted using the first sector numbers of the
>> +		 * zone. This will not result in write errors but will
>> +		 * cause most reads to fail as reads will use the sector values
>> +		 * for the actual data locations, resulting in IV mismatch.
>> +		 * To avoid this problem, ask DM core to emulate zone append
>> +		 * operations with regular writes.
>> +		 */
>> +		DMWARN("Zone append operations will be emulated");
> 
> Do we really want to fill log with these?

I added this to signal to the user, indirectly, that performance may be impacted
as the zone write locking mechanism used for the emulation essentially limits
write operations to at most 1 per zone. Overall, the drive QD can still be high,
but per zone, it will be at most one write per zone at any time.

> (I know it is not a good example in this context - but during online reencryption,
> dm-crypt table segments are continuously reloaded and because the message is in in table constructor,
> it will flood the syslog with repeated message.)
> 
> Maybe move it to debug or remove it completely?

OK. I will change this to debug.

> What would be nice to have some zoned info extension to lsblk so we can investigate
> storage stack over zoned device (if there is some sysfs knob to detect it, it should be trivial)... 

Yes, it is simple to add a sysfs attribute like
/sys/block/xxx/queue/zone_append_emulated.

That can be done later though. I will see if that can really help applications
or FSes. Right now, I do not see the need for this attribute. After all, all
scsi SMR drives already have zone append emulation (in the SD driver).

Thanks for the review. Will send V2 later today.

> 
> Thanks,
> Milan
> 
>> +		ti->emulate_zone_append = true;
>>  	}
>>  
>>  	if (crypt_integrity_aead(cc) || cc->integrity_iv_size) {
>>
> 
> 


-- 
Damien Le Moal
Western Digital Research



--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  reply	other threads:[~2021-05-20  0:00 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19  2:55 [PATCH 00/11] dm: Improve zoned block device support Damien Le Moal
2021-05-19  2:55 ` [dm-devel] " Damien Le Moal
2021-05-19  2:55 ` [PATCH 01/11] block: improve handling of all zones reset operation Damien Le Moal
2021-05-19  2:55   ` [dm-devel] " Damien Le Moal
2021-05-19  9:35   ` Christoph Hellwig
2021-05-19  9:35     ` [dm-devel] " Christoph Hellwig
2021-05-19  9:48     ` Damien Le Moal
2021-05-19  9:48       ` [dm-devel] " Damien Le Moal
2021-05-19  2:55 ` [PATCH 02/11] block: introduce bio zone helpers Damien Le Moal
2021-05-19  2:55   ` [dm-devel] " Damien Le Moal
2021-05-19  7:17   ` Johannes Thumshirn
2021-05-19  7:17     ` [dm-devel] " Johannes Thumshirn
2021-05-19  7:42     ` Chaitanya Kulkarni
2021-05-19  7:42       ` [dm-devel] " Chaitanya Kulkarni
2021-05-19  8:27       ` Damien Le Moal
2021-05-19  8:27         ` [dm-devel] " Damien Le Moal
2021-05-19  9:38     ` Christoph Hellwig
2021-05-19  9:38       ` [dm-devel] " Christoph Hellwig
2021-05-19  2:55 ` [PATCH 03/11] block: introduce BIO_ZONE_WRITE_LOCKED bio flag Damien Le Moal
2021-05-19  2:55   ` [dm-devel] " Damien Le Moal
2021-05-19  9:41   ` Christoph Hellwig
2021-05-19  9:41     ` [dm-devel] " Christoph Hellwig
2021-05-19  9:50     ` Damien Le Moal
2021-05-19  9:50       ` [dm-devel] " Damien Le Moal
2021-05-19  2:55 ` [PATCH 04/11] dm: Fix dm_accept_partial_bio() Damien Le Moal
2021-05-19  2:55   ` [dm-devel] " Damien Le Moal
2021-05-19  7:37   ` Johannes Thumshirn
2021-05-19  7:37     ` [dm-devel] " Johannes Thumshirn
2021-05-19  2:55 ` [PATCH 05/11] dm: cleanup device_area_is_invalid() Damien Le Moal
2021-05-19  2:55   ` [dm-devel] " Damien Le Moal
2021-05-19  7:36   ` Johannes Thumshirn
2021-05-19  7:36     ` [dm-devel] " Johannes Thumshirn
2021-05-19  2:55 ` [PATCH 06/11] dm: move zone related code to dm-zone.c Damien Le Moal
2021-05-19  2:55   ` [dm-devel] " Damien Le Moal
2021-05-19  7:38   ` Johannes Thumshirn
2021-05-19  7:38     ` [dm-devel] " Johannes Thumshirn
2021-05-19  2:55 ` [PATCH 07/11] dm: Introduce dm_report_zones() Damien Le Moal
2021-05-19  2:55   ` [dm-devel] " Damien Le Moal
2021-05-19  7:49   ` Johannes Thumshirn
2021-05-19  7:49     ` [dm-devel] " Johannes Thumshirn
2021-05-19  2:55 ` [PATCH 08/11] dm: Forbid requeue of writes to zones Damien Le Moal
2021-05-19  2:55   ` [dm-devel] " Damien Le Moal
2021-05-19  2:55 ` [PATCH 09/11] dm: rearrange core declarations Damien Le Moal
2021-05-19  2:55   ` [dm-devel] " Damien Le Moal
2021-05-19  2:55 ` [PATCH 10/11] dm: introduce zone append emulation Damien Le Moal
2021-05-19  2:55   ` [dm-devel] " Damien Le Moal
2021-05-19  2:55 ` [PATCH 11/11] dm crypt: Fix zoned block device support Damien Le Moal
2021-05-19  2:55   ` [dm-devel] " Damien Le Moal
2021-05-19 15:45   ` Milan Broz
2021-05-19 15:45     ` Milan Broz
2021-05-20  0:00     ` Damien Le Moal [this message]
2021-05-20  0:00       ` 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=DM6PR04MB7081B7965B612300F87C77F9E72A9@DM6PR04MB7081.namprd04.prod.outlook.com \
    --to=damien.lemoal@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=gmazyland@gmail.com \
    --cc=linux-block@vger.kernel.org \
    --cc=snitzer@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.