Skip to content

Commit eebcafa

Browse files
ebiggersaxboe
authored andcommitted
blk-crypto-fallback: properly prefix function and struct names
For clarity, avoid using just the "blk_crypto_" prefix for functions and structs that are specific to blk-crypto-fallback. Instead, use "blk_crypto_fallback_". Some places already did this, but others didn't. This is also a prerequisite for using "struct blk_crypto_keyslot" to mean a generic blk-crypto keyslot (which is what it sounds like). Rename the fallback one to "struct blk_crypto_fallback_keyslot". No change in behavior. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Reviewed-by: Mike Snitzer <snitzer@redhat.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Link: https://lore.kernel.org/r/20211018180453.40441-2-ebiggers@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 435c2ac commit eebcafa

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

block/blk-crypto-fallback.c

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static mempool_t *bio_fallback_crypt_ctx_pool;
7373
static DEFINE_MUTEX(tfms_init_lock);
7474
static bool tfms_inited[BLK_ENCRYPTION_MODE_MAX];
7575

76-
static struct blk_crypto_keyslot {
76+
static struct blk_crypto_fallback_keyslot {
7777
enum blk_crypto_mode_num crypto_mode;
7878
struct crypto_skcipher *tfms[BLK_ENCRYPTION_MODE_MAX];
7979
} *blk_crypto_keyslots;
@@ -89,9 +89,9 @@ static struct bio_set crypto_bio_split;
8989
*/
9090
static u8 blank_key[BLK_CRYPTO_MAX_KEY_SIZE];
9191

92-
static void blk_crypto_evict_keyslot(unsigned int slot)
92+
static void blk_crypto_fallback_evict_keyslot(unsigned int slot)
9393
{
94-
struct blk_crypto_keyslot *slotp = &blk_crypto_keyslots[slot];
94+
struct blk_crypto_fallback_keyslot *slotp = &blk_crypto_keyslots[slot];
9595
enum blk_crypto_mode_num crypto_mode = slotp->crypto_mode;
9696
int err;
9797

@@ -104,34 +104,34 @@ static void blk_crypto_evict_keyslot(unsigned int slot)
104104
slotp->crypto_mode = BLK_ENCRYPTION_MODE_INVALID;
105105
}
106106

107-
static int blk_crypto_keyslot_program(struct blk_keyslot_manager *ksm,
108-
const struct blk_crypto_key *key,
109-
unsigned int slot)
107+
static int blk_crypto_fallback_keyslot_program(struct blk_keyslot_manager *ksm,
108+
const struct blk_crypto_key *key,
109+
unsigned int slot)
110110
{
111-
struct blk_crypto_keyslot *slotp = &blk_crypto_keyslots[slot];
111+
struct blk_crypto_fallback_keyslot *slotp = &blk_crypto_keyslots[slot];
112112
const enum blk_crypto_mode_num crypto_mode =
113113
key->crypto_cfg.crypto_mode;
114114
int err;
115115

116116
if (crypto_mode != slotp->crypto_mode &&
117117
slotp->crypto_mode != BLK_ENCRYPTION_MODE_INVALID)
118-
blk_crypto_evict_keyslot(slot);
118+
blk_crypto_fallback_evict_keyslot(slot);
119119

120120
slotp->crypto_mode = crypto_mode;
121121
err = crypto_skcipher_setkey(slotp->tfms[crypto_mode], key->raw,
122122
key->size);
123123
if (err) {
124-
blk_crypto_evict_keyslot(slot);
124+
blk_crypto_fallback_evict_keyslot(slot);
125125
return err;
126126
}
127127
return 0;
128128
}
129129

130-
static int blk_crypto_keyslot_evict(struct blk_keyslot_manager *ksm,
131-
const struct blk_crypto_key *key,
132-
unsigned int slot)
130+
static int blk_crypto_fallback_keyslot_evict(struct blk_keyslot_manager *ksm,
131+
const struct blk_crypto_key *key,
132+
unsigned int slot)
133133
{
134-
blk_crypto_evict_keyslot(slot);
134+
blk_crypto_fallback_evict_keyslot(slot);
135135
return 0;
136136
}
137137

@@ -141,8 +141,8 @@ static int blk_crypto_keyslot_evict(struct blk_keyslot_manager *ksm,
141141
* hardware.
142142
*/
143143
static const struct blk_ksm_ll_ops blk_crypto_ksm_ll_ops = {
144-
.keyslot_program = blk_crypto_keyslot_program,
145-
.keyslot_evict = blk_crypto_keyslot_evict,
144+
.keyslot_program = blk_crypto_fallback_keyslot_program,
145+
.keyslot_evict = blk_crypto_fallback_keyslot_evict,
146146
};
147147

148148
static void blk_crypto_fallback_encrypt_endio(struct bio *enc_bio)
@@ -160,7 +160,7 @@ static void blk_crypto_fallback_encrypt_endio(struct bio *enc_bio)
160160
bio_endio(src_bio);
161161
}
162162

163-
static struct bio *blk_crypto_clone_bio(struct bio *bio_src)
163+
static struct bio *blk_crypto_fallback_clone_bio(struct bio *bio_src)
164164
{
165165
struct bvec_iter iter;
166166
struct bio_vec bv;
@@ -187,12 +187,13 @@ static struct bio *blk_crypto_clone_bio(struct bio *bio_src)
187187
return bio;
188188
}
189189

190-
static bool blk_crypto_alloc_cipher_req(struct blk_ksm_keyslot *slot,
191-
struct skcipher_request **ciph_req_ret,
192-
struct crypto_wait *wait)
190+
static bool
191+
blk_crypto_fallback_alloc_cipher_req(struct blk_ksm_keyslot *slot,
192+
struct skcipher_request **ciph_req_ret,
193+
struct crypto_wait *wait)
193194
{
194195
struct skcipher_request *ciph_req;
195-
const struct blk_crypto_keyslot *slotp;
196+
const struct blk_crypto_fallback_keyslot *slotp;
196197
int keyslot_idx = blk_ksm_get_slot_idx(slot);
197198

198199
slotp = &blk_crypto_keyslots[keyslot_idx];
@@ -210,7 +211,7 @@ static bool blk_crypto_alloc_cipher_req(struct blk_ksm_keyslot *slot,
210211
return true;
211212
}
212213

213-
static bool blk_crypto_split_bio_if_needed(struct bio **bio_ptr)
214+
static bool blk_crypto_fallback_split_bio_if_needed(struct bio **bio_ptr)
214215
{
215216
struct bio *bio = *bio_ptr;
216217
unsigned int i = 0;
@@ -277,15 +278,15 @@ static bool blk_crypto_fallback_encrypt_bio(struct bio **bio_ptr)
277278
blk_status_t blk_st;
278279

279280
/* Split the bio if it's too big for single page bvec */
280-
if (!blk_crypto_split_bio_if_needed(bio_ptr))
281+
if (!blk_crypto_fallback_split_bio_if_needed(bio_ptr))
281282
return false;
282283

283284
src_bio = *bio_ptr;
284285
bc = src_bio->bi_crypt_context;
285286
data_unit_size = bc->bc_key->crypto_cfg.data_unit_size;
286287

287288
/* Allocate bounce bio for encryption */
288-
enc_bio = blk_crypto_clone_bio(src_bio);
289+
enc_bio = blk_crypto_fallback_clone_bio(src_bio);
289290
if (!enc_bio) {
290291
src_bio->bi_status = BLK_STS_RESOURCE;
291292
return false;
@@ -302,7 +303,7 @@ static bool blk_crypto_fallback_encrypt_bio(struct bio **bio_ptr)
302303
}
303304

304305
/* and then allocate an skcipher_request for it */
305-
if (!blk_crypto_alloc_cipher_req(slot, &ciph_req, &wait)) {
306+
if (!blk_crypto_fallback_alloc_cipher_req(slot, &ciph_req, &wait)) {
306307
src_bio->bi_status = BLK_STS_RESOURCE;
307308
goto out_release_keyslot;
308309
}
@@ -404,7 +405,7 @@ static void blk_crypto_fallback_decrypt_bio(struct work_struct *work)
404405
}
405406

406407
/* and then allocate an skcipher_request for it */
407-
if (!blk_crypto_alloc_cipher_req(slot, &ciph_req, &wait)) {
408+
if (!blk_crypto_fallback_alloc_cipher_req(slot, &ciph_req, &wait)) {
408409
bio->bi_status = BLK_STS_RESOURCE;
409410
goto out;
410411
}
@@ -474,9 +475,9 @@ static void blk_crypto_fallback_decrypt_endio(struct bio *bio)
474475
* @bio_ptr: pointer to the bio to prepare
475476
*
476477
* If bio is doing a WRITE operation, this splits the bio into two parts if it's
477-
* too big (see blk_crypto_split_bio_if_needed). It then allocates a bounce bio
478-
* for the first part, encrypts it, and update bio_ptr to point to the bounce
479-
* bio.
478+
* too big (see blk_crypto_fallback_split_bio_if_needed()). It then allocates a
479+
* bounce bio for the first part, encrypts it, and updates bio_ptr to point to
480+
* the bounce bio.
480481
*
481482
* For a READ operation, we mark the bio for decryption by using bi_private and
482483
* bi_end_io.
@@ -611,7 +612,7 @@ static int blk_crypto_fallback_init(void)
611612
int blk_crypto_fallback_start_using_mode(enum blk_crypto_mode_num mode_num)
612613
{
613614
const char *cipher_str = blk_crypto_modes[mode_num].cipher_str;
614-
struct blk_crypto_keyslot *slotp;
615+
struct blk_crypto_fallback_keyslot *slotp;
615616
unsigned int i;
616617
int err = 0;
617618

0 commit comments

Comments
 (0)