public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>, Mike Snitzer <snitzer@redhat.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	linux-block@vger.kernel.org, dm-devel@redhat.com,
	Dmitry Monakhov <dmonakhov@openvz.org>,
	Kent Overstreet <kent.overstreet@gmail.com>
Subject: Re: [dm-devel] [PATCH 5.20 1/4] block: add bio_rewind() API
Date: Sun, 26 Jun 2022 14:37:22 -0700	[thread overview]
Message-ID: <YrjRkp9y99KZdwMo@sol.localdomain> (raw)
In-Reply-To: <20220624141255.2461148-2-ming.lei@redhat.com>

On Fri, Jun 24, 2022 at 10:12:52PM +0800, Ming Lei wrote:
> diff --git a/block/blk-crypto.c b/block/blk-crypto.c
> index a496aaef85ba..caae2f429fc7 100644
> --- a/block/blk-crypto.c
> +++ b/block/blk-crypto.c
> @@ -134,6 +134,21 @@ void bio_crypt_dun_increment(u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE],
>  	}
>  }
>  
> +/* Decrements @dun by @dec, treating @dun as a multi-limb integer. */
> +void bio_crypt_dun_decrement(u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE],
> +			     unsigned int dec)
> +{
> +	int i;
> +
> +	for (i = 0; dec && i < BLK_CRYPTO_DUN_ARRAY_SIZE; i++) {
> +		dun[i] -= dec;
> +		if (dun[i] > inc)
> +			dec = 1;
> +		else
> +			dec = 0;
> +	}
> +}

This doesn't compile.  Also this doesn't handle underflow into the next limb
correctly.  A correct version would be:

		u64 prev = dun[i];

		dun[i] -= dec;
		if (dun[i] > prev)
			dec = 1;
		else
			dec = 0;

- Eric

  parent reply	other threads:[~2022-06-26 21:37 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-24 14:12 [PATCH 5.20 0/4] block/dm: add bio_rewind for improving dm requeue Ming Lei
2022-06-24 14:12 ` [PATCH 5.20 1/4] block: add bio_rewind() API Ming Lei
2022-06-26 20:14   ` Kent Overstreet
2022-06-27  7:36     ` Ming Lei
2022-06-28  4:20       ` Kent Overstreet
2022-06-28  7:42         ` Ming Lei
2022-06-28 16:16           ` Kent Overstreet
2022-06-28 18:13         ` Jens Axboe
2022-06-28 18:32           ` Kent Overstreet
2022-06-29 17:16             ` Jens Axboe
2022-06-29 18:40               ` Kent Overstreet
2022-06-29 18:51                 ` Bart Van Assche
2022-06-29 19:05                   ` Kent Overstreet
2022-06-29 19:37                     ` Bart Van Assche
2022-06-29 19:50                       ` Kent Overstreet
2022-06-29 19:59                       ` Kent Overstreet
2022-06-29 19:00                 ` Jens Axboe
2022-06-29 19:26                   ` Kent Overstreet
2022-06-29 20:51                     ` Jens Axboe
2022-06-29  0:49           ` Ming Lei
2022-06-28  4:26       ` Kent Overstreet
2022-06-28  7:49         ` Ming Lei
2022-06-28 16:36           ` Kent Overstreet
2022-06-28 17:41             ` Mike Snitzer
2022-06-28 17:52               ` Kent Overstreet
2022-06-29  6:07                 ` Mike Snitzer
2022-06-29 18:11                   ` Kent Overstreet
2022-06-30  0:47                     ` Ming Lei
2022-06-30  0:58                       ` Kent Overstreet
2022-06-30  1:14                       ` Kent Overstreet
2022-07-01  3:58                         ` Ming Lei
2022-07-01 21:09                           ` Kent Overstreet
2022-06-29  1:02             ` Ming Lei
2022-06-26 21:37   ` Eric Biggers [this message]
2022-06-27  7:37     ` [dm-devel] " Ming Lei
2022-06-24 14:12 ` [PATCH 5.20 2/4] dm: add new helper for handling dm_io requeue Ming Lei
2022-06-24 14:12 ` [PATCH 5.20 3/4] dm: improve handling for DM_REQUEUE and AGAIN Ming Lei
2022-06-24 14:12 ` [PATCH 5.20 4/4] dm: add two stage requeue Ming Lei

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=YrjRkp9y99KZdwMo@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=dmonakhov@openvz.org \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-block@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox