From: Christoph Hellwig <hch@infradead.org>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-ext4@vger.kernel.org, linux-scsi@vger.kernel.org,
Kim Boojin <boojin.kim@samsung.com>,
Kuohong Wang <kuohong.wang@mediatek.com>,
Barani Muthukumaran <bmuthuku@qti.qualcomm.com>,
linux-f2fs-devel@lists.sourceforge.net,
linux-block@vger.kernel.org, linux-fscrypt@vger.kernel.org,
linux-fsdevel@vger.kernel.org,
Satya Tangirala <satyat@google.com>
Subject: Re: [f2fs-dev] [PATCH v9 02/11] block: Inline encryption support for blk-mq
Date: Fri, 27 Mar 2020 10:05:34 -0700 [thread overview]
Message-ID: <20200327170534.GB24682@infradead.org> (raw)
In-Reply-To: <20200326200511.GA186343@gmail.com>
On Thu, Mar 26, 2020 at 01:05:11PM -0700, Eric Biggers wrote:
> > +{
> > + int i = 0;
> > + unsigned int inc = bytes >> bc->bc_key->data_unit_size_bits;
> > +
> > + while (i < BLK_CRYPTO_DUN_ARRAY_SIZE) {
> > + if (bc->bc_dun[i] + inc != next_dun[i])
> > + return false;
> > + /*
> > + * If addition of inc to the current entry caused an overflow,
> > + * then we have to carry "1" for the next entry - so inc
> > + * needs to be "1" for the next loop iteration). Otherwise,
> > + * we need inc to be 0 for the next loop iteration. Since
> > + * overflow can be determined by (bc->bc_dun[i] + inc) < inc
> > + * we can do the following.
> > + */
> > + inc = ((bc->bc_dun[i] + inc) < inc);
> > + i++;
> > + }
>
> This comment is verbose but doesn't really explain what's going on.
> I think it would be much more useful to add comments like:
Also the code is still weird. Odd double whitespaces, expression that
evaluate to bool.
>
> /*
> * If the addition in this limb overflowed, then the carry bit
> * into the next limb is 1. Else the carry bit is 0.
> */
> inc = ((bc->bc_dun[i] + inc) < inc);
if (bc->bc_dun[i] + carry < carry)
carry = 1;
else
carry = 0;
>
> > +blk_status_t __blk_crypto_init_request(struct request *rq,
> > + const struct blk_crypto_key *key)
> > +{
> > + return blk_ksm_get_slot_for_key(rq->q->ksm, key, &rq->crypt_keyslot);
> > +}
>
> The comment of this function seems outdated. All it does it get a keyslot, but
> the comment talks about initializing "crypto fields" (plural).
This is a classic case where I think the top of the function comment
is entirely useless. If there is a single caller in core code and the
function is completely trivial, there really is no point in a multi-line
comment. Comment should explain something unexpected or non-trivial,
while much of the comments in this series are just boilerplate making
the code harder to read.
> > blk_queue_bounce(q, &bio);
> > __blk_queue_split(q, &bio, &nr_segs);
> > @@ -2002,6 +2006,14 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
> >
> > cookie = request_to_qc_t(data.hctx, rq);
> >
> > + ret = blk_crypto_init_request(rq, bio_crypt_key(bio));
> > + if (ret != BLK_STS_OK) {
> > + bio->bi_status = ret;
> > + bio_endio(bio);
> > + blk_mq_free_request(rq);
> > + return BLK_QC_T_NONE;
> > + }
> > +
> > blk_mq_bio_to_request(rq, bio, nr_segs);
>
> Wouldn't it make a lot more sense to do blk_crypto_init_request() after
> blk_mq_bio_to_request() rather than before?
>
> I.e., initialize request::crypt_ctx first, *then* get the keyslot. Not the
> other way around.
>
> That would allow removing the second argument to blk_crypto_init_request() and
> removing bio_crypt_key(). blk_crypto_init_request() would only need to take in
> the struct request.
And we can fail just the request on an error, so yes this doesn't
seem too bad.
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2020-03-27 17:05 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-26 3:06 [f2fs-dev] [PATCH v9 00/11] Inline Encryption Support Satya Tangirala via Linux-f2fs-devel
2020-03-26 3:06 ` [f2fs-dev] [PATCH v9 01/11] block: Keyslot Manager for Inline Encryption Satya Tangirala via Linux-f2fs-devel
2020-03-26 6:22 ` Eric Biggers
2020-03-27 17:00 ` Christoph Hellwig
2020-03-26 3:06 ` [f2fs-dev] [PATCH v9 02/11] block: Inline encryption support for blk-mq Satya Tangirala via Linux-f2fs-devel
2020-03-26 20:05 ` Eric Biggers
2020-03-27 17:05 ` Christoph Hellwig [this message]
2020-03-26 3:06 ` [f2fs-dev] [PATCH v9 03/11] block: Make blk-integrity preclude hardware inline encryption Satya Tangirala via Linux-f2fs-devel
2020-03-26 3:06 ` [f2fs-dev] [PATCH v9 04/11] block: blk-crypto-fallback for Inline Encryption Satya Tangirala via Linux-f2fs-devel
2020-03-26 20:28 ` Eric Biggers
2020-03-26 3:06 ` [f2fs-dev] [PATCH v9 05/11] scsi: ufs: UFS driver v2.1 spec crypto additions Satya Tangirala via Linux-f2fs-devel
2020-03-26 3:06 ` [f2fs-dev] [PATCH v9 06/11] scsi: ufs: UFS crypto API Satya Tangirala via Linux-f2fs-devel
2020-03-26 5:07 ` Eric Biggers
2020-03-26 3:06 ` [f2fs-dev] [PATCH v9 07/11] scsi: ufs: Add inline encryption support to UFS Satya Tangirala via Linux-f2fs-devel
2020-03-26 5:09 ` Eric Biggers
2020-03-26 3:06 ` [f2fs-dev] [PATCH v9 08/11] fs: introduce SB_INLINECRYPT Satya Tangirala via Linux-f2fs-devel
2020-03-26 5:56 ` Eric Biggers
2020-03-26 3:07 ` [f2fs-dev] [PATCH v9 09/11] fscrypt: add inline encryption support Satya Tangirala via Linux-f2fs-devel
2020-03-26 5:45 ` Eric Biggers
2020-03-26 3:07 ` [f2fs-dev] [PATCH v9 10/11] f2fs: " Satya Tangirala via Linux-f2fs-devel
2020-03-26 3:07 ` [f2fs-dev] [PATCH v9 11/11] ext4: " Satya Tangirala via Linux-f2fs-devel
2020-03-26 3:32 ` [f2fs-dev] [PATCH v9 00/11] Inline Encryption Support Eric Biggers
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=20200327170534.GB24682@infradead.org \
--to=hch@infradead.org \
--cc=bmuthuku@qti.qualcomm.com \
--cc=boojin.kim@samsung.com \
--cc=ebiggers@kernel.org \
--cc=kuohong.wang@mediatek.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=satyat@google.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).