Skip to content

Commit 3e7807d

Browse files
josefbacikebiggers
authored andcommitted
fscrypt: rename fscrypt_info => fscrypt_inode_info
We are going to track per-extent information, so it'll be necessary to distinguish between inode infos and extent infos. Rename fscrypt_info to fscrypt_inode_info, adjusting any lines that now exceed 80 characters. Signed-off-by: Josef Bacik <josef@toxicpanda.com> [ebiggers: rebased onto fscrypt tree, renamed fscrypt_get_info(), adjusted two comments, and fixed some lines over 80 characters] Link: https://lore.kernel.org/r/20231005025757.33521-1-ebiggers@kernel.org Reviewed-by: Neal Gompa <neal@gompa.dev> Signed-off-by: Eric Biggers <ebiggers@google.com>
1 parent 5b11888 commit 3e7807d

12 files changed

Lines changed: 92 additions & 81 deletions

File tree

fs/crypto/bio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int fscrypt_zeroout_range_inline_crypt(const struct inode *inode,
111111
int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
112112
sector_t pblk, unsigned int len)
113113
{
114-
const struct fscrypt_info *ci = inode->i_crypt_info;
114+
const struct fscrypt_inode_info *ci = inode->i_crypt_info;
115115
const unsigned int du_bits = ci->ci_data_unit_bits;
116116
const unsigned int du_size = 1U << du_bits;
117117
const unsigned int du_per_page_bits = PAGE_SHIFT - du_bits;

fs/crypto/crypto.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static mempool_t *fscrypt_bounce_page_pool = NULL;
3939
static struct workqueue_struct *fscrypt_read_workqueue;
4040
static DEFINE_MUTEX(fscrypt_init_mutex);
4141

42-
struct kmem_cache *fscrypt_info_cachep;
42+
struct kmem_cache *fscrypt_inode_info_cachep;
4343

4444
void fscrypt_enqueue_decrypt_work(struct work_struct *work)
4545
{
@@ -85,7 +85,7 @@ EXPORT_SYMBOL(fscrypt_free_bounce_page);
8585
* simply contain the data unit index (e.g., IV_INO_LBLK_32).
8686
*/
8787
void fscrypt_generate_iv(union fscrypt_iv *iv, u64 index,
88-
const struct fscrypt_info *ci)
88+
const struct fscrypt_inode_info *ci)
8989
{
9090
u8 flags = fscrypt_policy_flags(&ci->ci_policy);
9191

@@ -105,7 +105,7 @@ void fscrypt_generate_iv(union fscrypt_iv *iv, u64 index,
105105
}
106106

107107
/* Encrypt or decrypt a single "data unit" of file contents. */
108-
int fscrypt_crypt_data_unit(const struct fscrypt_info *ci,
108+
int fscrypt_crypt_data_unit(const struct fscrypt_inode_info *ci,
109109
fscrypt_direction_t rw, u64 index,
110110
struct page *src_page, struct page *dest_page,
111111
unsigned int len, unsigned int offs,
@@ -184,7 +184,7 @@ struct page *fscrypt_encrypt_pagecache_blocks(struct page *page,
184184

185185
{
186186
const struct inode *inode = page->mapping->host;
187-
const struct fscrypt_info *ci = inode->i_crypt_info;
187+
const struct fscrypt_inode_info *ci = inode->i_crypt_info;
188188
const unsigned int du_bits = ci->ci_data_unit_bits;
189189
const unsigned int du_size = 1U << du_bits;
190190
struct page *ciphertext_page;
@@ -267,7 +267,7 @@ int fscrypt_decrypt_pagecache_blocks(struct folio *folio, size_t len,
267267
size_t offs)
268268
{
269269
const struct inode *inode = folio->mapping->host;
270-
const struct fscrypt_info *ci = inode->i_crypt_info;
270+
const struct fscrypt_inode_info *ci = inode->i_crypt_info;
271271
const unsigned int du_bits = ci->ci_data_unit_bits;
272272
const unsigned int du_size = 1U << du_bits;
273273
u64 index = ((u64)folio->index << (PAGE_SHIFT - du_bits)) +
@@ -409,18 +409,19 @@ static int __init fscrypt_init(void)
409409
if (!fscrypt_read_workqueue)
410410
goto fail;
411411

412-
fscrypt_info_cachep = KMEM_CACHE(fscrypt_info, SLAB_RECLAIM_ACCOUNT);
413-
if (!fscrypt_info_cachep)
412+
fscrypt_inode_info_cachep = KMEM_CACHE(fscrypt_inode_info,
413+
SLAB_RECLAIM_ACCOUNT);
414+
if (!fscrypt_inode_info_cachep)
414415
goto fail_free_queue;
415416

416417
err = fscrypt_init_keyring();
417418
if (err)
418-
goto fail_free_info;
419+
goto fail_free_inode_info;
419420

420421
return 0;
421422

422-
fail_free_info:
423-
kmem_cache_destroy(fscrypt_info_cachep);
423+
fail_free_inode_info:
424+
kmem_cache_destroy(fscrypt_inode_info_cachep);
424425
fail_free_queue:
425426
destroy_workqueue(fscrypt_read_workqueue);
426427
fail:

fs/crypto/fname.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ int fscrypt_fname_encrypt(const struct inode *inode, const struct qstr *iname,
100100
{
101101
struct skcipher_request *req = NULL;
102102
DECLARE_CRYPTO_WAIT(wait);
103-
const struct fscrypt_info *ci = inode->i_crypt_info;
103+
const struct fscrypt_inode_info *ci = inode->i_crypt_info;
104104
struct crypto_skcipher *tfm = ci->ci_enc_key.tfm;
105105
union fscrypt_iv iv;
106106
struct scatterlist sg;
@@ -157,7 +157,7 @@ static int fname_decrypt(const struct inode *inode,
157157
struct skcipher_request *req = NULL;
158158
DECLARE_CRYPTO_WAIT(wait);
159159
struct scatterlist src_sg, dst_sg;
160-
const struct fscrypt_info *ci = inode->i_crypt_info;
160+
const struct fscrypt_inode_info *ci = inode->i_crypt_info;
161161
struct crypto_skcipher *tfm = ci->ci_enc_key.tfm;
162162
union fscrypt_iv iv;
163163
int res;
@@ -568,7 +568,7 @@ EXPORT_SYMBOL_GPL(fscrypt_match_name);
568568
*/
569569
u64 fscrypt_fname_siphash(const struct inode *dir, const struct qstr *name)
570570
{
571-
const struct fscrypt_info *ci = dir->i_crypt_info;
571+
const struct fscrypt_inode_info *ci = dir->i_crypt_info;
572572

573573
WARN_ON_ONCE(!ci->ci_dirhash_key_initialized);
574574

fs/crypto/fscrypt_private.h

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -210,18 +210,18 @@ struct fscrypt_prepared_key {
210210
};
211211

212212
/*
213-
* fscrypt_info - the "encryption key" for an inode
213+
* fscrypt_inode_info - the "encryption key" for an inode
214214
*
215215
* When an encrypted file's key is made available, an instance of this struct is
216216
* allocated and stored in ->i_crypt_info. Once created, it remains until the
217217
* inode is evicted.
218218
*/
219-
struct fscrypt_info {
219+
struct fscrypt_inode_info {
220220

221221
/* The key in a form prepared for actual encryption/decryption */
222222
struct fscrypt_prepared_key ci_enc_key;
223223

224-
/* True if ci_enc_key should be freed when this fscrypt_info is freed */
224+
/* True if ci_enc_key should be freed when this struct is freed */
225225
bool ci_owns_key;
226226

227227
#ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT
@@ -294,9 +294,9 @@ typedef enum {
294294
} fscrypt_direction_t;
295295

296296
/* crypto.c */
297-
extern struct kmem_cache *fscrypt_info_cachep;
297+
extern struct kmem_cache *fscrypt_inode_info_cachep;
298298
int fscrypt_initialize(struct super_block *sb);
299-
int fscrypt_crypt_data_unit(const struct fscrypt_info *ci,
299+
int fscrypt_crypt_data_unit(const struct fscrypt_inode_info *ci,
300300
fscrypt_direction_t rw, u64 index,
301301
struct page *src_page, struct page *dest_page,
302302
unsigned int len, unsigned int offs,
@@ -326,7 +326,7 @@ union fscrypt_iv {
326326
};
327327

328328
void fscrypt_generate_iv(union fscrypt_iv *iv, u64 index,
329-
const struct fscrypt_info *ci);
329+
const struct fscrypt_inode_info *ci);
330330

331331
/*
332332
* Return the number of bits used by the maximum file data unit index that is
@@ -374,17 +374,17 @@ void fscrypt_destroy_hkdf(struct fscrypt_hkdf *hkdf);
374374

375375
/* inline_crypt.c */
376376
#ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT
377-
int fscrypt_select_encryption_impl(struct fscrypt_info *ci);
377+
int fscrypt_select_encryption_impl(struct fscrypt_inode_info *ci);
378378

379379
static inline bool
380-
fscrypt_using_inline_encryption(const struct fscrypt_info *ci)
380+
fscrypt_using_inline_encryption(const struct fscrypt_inode_info *ci)
381381
{
382382
return ci->ci_inlinecrypt;
383383
}
384384

385385
int fscrypt_prepare_inline_crypt_key(struct fscrypt_prepared_key *prep_key,
386386
const u8 *raw_key,
387-
const struct fscrypt_info *ci);
387+
const struct fscrypt_inode_info *ci);
388388

389389
void fscrypt_destroy_inline_crypt_key(struct super_block *sb,
390390
struct fscrypt_prepared_key *prep_key);
@@ -395,7 +395,7 @@ void fscrypt_destroy_inline_crypt_key(struct super_block *sb,
395395
*/
396396
static inline bool
397397
fscrypt_is_key_prepared(struct fscrypt_prepared_key *prep_key,
398-
const struct fscrypt_info *ci)
398+
const struct fscrypt_inode_info *ci)
399399
{
400400
/*
401401
* The two smp_load_acquire()'s here pair with the smp_store_release()'s
@@ -412,21 +412,21 @@ fscrypt_is_key_prepared(struct fscrypt_prepared_key *prep_key,
412412

413413
#else /* CONFIG_FS_ENCRYPTION_INLINE_CRYPT */
414414

415-
static inline int fscrypt_select_encryption_impl(struct fscrypt_info *ci)
415+
static inline int fscrypt_select_encryption_impl(struct fscrypt_inode_info *ci)
416416
{
417417
return 0;
418418
}
419419

420420
static inline bool
421-
fscrypt_using_inline_encryption(const struct fscrypt_info *ci)
421+
fscrypt_using_inline_encryption(const struct fscrypt_inode_info *ci)
422422
{
423423
return false;
424424
}
425425

426426
static inline int
427427
fscrypt_prepare_inline_crypt_key(struct fscrypt_prepared_key *prep_key,
428428
const u8 *raw_key,
429-
const struct fscrypt_info *ci)
429+
const struct fscrypt_inode_info *ci)
430430
{
431431
WARN_ON_ONCE(1);
432432
return -EOPNOTSUPP;
@@ -440,7 +440,7 @@ fscrypt_destroy_inline_crypt_key(struct super_block *sb,
440440

441441
static inline bool
442442
fscrypt_is_key_prepared(struct fscrypt_prepared_key *prep_key,
443-
const struct fscrypt_info *ci)
443+
const struct fscrypt_inode_info *ci)
444444
{
445445
return smp_load_acquire(&prep_key->tfm) != NULL;
446446
}
@@ -640,17 +640,18 @@ struct fscrypt_mode {
640640
extern struct fscrypt_mode fscrypt_modes[];
641641

642642
int fscrypt_prepare_key(struct fscrypt_prepared_key *prep_key,
643-
const u8 *raw_key, const struct fscrypt_info *ci);
643+
const u8 *raw_key, const struct fscrypt_inode_info *ci);
644644

645645
void fscrypt_destroy_prepared_key(struct super_block *sb,
646646
struct fscrypt_prepared_key *prep_key);
647647

648-
int fscrypt_set_per_file_enc_key(struct fscrypt_info *ci, const u8 *raw_key);
648+
int fscrypt_set_per_file_enc_key(struct fscrypt_inode_info *ci,
649+
const u8 *raw_key);
649650

650-
int fscrypt_derive_dirhash_key(struct fscrypt_info *ci,
651+
int fscrypt_derive_dirhash_key(struct fscrypt_inode_info *ci,
651652
const struct fscrypt_master_key *mk);
652653

653-
void fscrypt_hash_inode_number(struct fscrypt_info *ci,
654+
void fscrypt_hash_inode_number(struct fscrypt_inode_info *ci,
654655
const struct fscrypt_master_key *mk);
655656

656657
int fscrypt_get_encryption_info(struct inode *inode, bool allow_unsupported);
@@ -685,10 +686,11 @@ static inline int fscrypt_require_key(struct inode *inode)
685686

686687
void fscrypt_put_direct_key(struct fscrypt_direct_key *dk);
687688

688-
int fscrypt_setup_v1_file_key(struct fscrypt_info *ci,
689+
int fscrypt_setup_v1_file_key(struct fscrypt_inode_info *ci,
689690
const u8 *raw_master_key);
690691

691-
int fscrypt_setup_v1_file_key_via_subscribed_keyrings(struct fscrypt_info *ci);
692+
int fscrypt_setup_v1_file_key_via_subscribed_keyrings(
693+
struct fscrypt_inode_info *ci);
692694

693695
/* policy.c */
694696

fs/crypto/hooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ EXPORT_SYMBOL_GPL(__fscrypt_prepare_setattr);
169169
int fscrypt_prepare_setflags(struct inode *inode,
170170
unsigned int oldflags, unsigned int flags)
171171
{
172-
struct fscrypt_info *ci;
172+
struct fscrypt_inode_info *ci;
173173
struct fscrypt_master_key *mk;
174174
int err;
175175

fs/crypto/inline_crypt.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static struct block_device **fscrypt_get_devices(struct super_block *sb,
3939
return devs;
4040
}
4141

42-
static unsigned int fscrypt_get_dun_bytes(const struct fscrypt_info *ci)
42+
static unsigned int fscrypt_get_dun_bytes(const struct fscrypt_inode_info *ci)
4343
{
4444
const struct super_block *sb = ci->ci_inode->i_sb;
4545
unsigned int flags = fscrypt_policy_flags(&ci->ci_policy);
@@ -89,7 +89,7 @@ static void fscrypt_log_blk_crypto_impl(struct fscrypt_mode *mode,
8989
}
9090

9191
/* Enable inline encryption for this file if supported. */
92-
int fscrypt_select_encryption_impl(struct fscrypt_info *ci)
92+
int fscrypt_select_encryption_impl(struct fscrypt_inode_info *ci)
9393
{
9494
const struct inode *inode = ci->ci_inode;
9595
struct super_block *sb = inode->i_sb;
@@ -151,7 +151,7 @@ int fscrypt_select_encryption_impl(struct fscrypt_info *ci)
151151

152152
int fscrypt_prepare_inline_crypt_key(struct fscrypt_prepared_key *prep_key,
153153
const u8 *raw_key,
154-
const struct fscrypt_info *ci)
154+
const struct fscrypt_inode_info *ci)
155155
{
156156
const struct inode *inode = ci->ci_inode;
157157
struct super_block *sb = inode->i_sb;
@@ -232,7 +232,8 @@ bool __fscrypt_inode_uses_inline_crypto(const struct inode *inode)
232232
}
233233
EXPORT_SYMBOL_GPL(__fscrypt_inode_uses_inline_crypto);
234234

235-
static void fscrypt_generate_dun(const struct fscrypt_info *ci, u64 lblk_num,
235+
static void fscrypt_generate_dun(const struct fscrypt_inode_info *ci,
236+
u64 lblk_num,
236237
u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE])
237238
{
238239
u64 index = lblk_num << ci->ci_data_units_per_block_bits;
@@ -266,7 +267,7 @@ static void fscrypt_generate_dun(const struct fscrypt_info *ci, u64 lblk_num,
266267
void fscrypt_set_bio_crypt_ctx(struct bio *bio, const struct inode *inode,
267268
u64 first_lblk, gfp_t gfp_mask)
268269
{
269-
const struct fscrypt_info *ci;
270+
const struct fscrypt_inode_info *ci;
270271
u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE];
271272

272273
if (!fscrypt_inode_uses_inline_crypto(inode))
@@ -457,7 +458,7 @@ EXPORT_SYMBOL_GPL(fscrypt_dio_supported);
457458
*/
458459
u64 fscrypt_limit_io_blocks(const struct inode *inode, u64 lblk, u64 nr_blocks)
459460
{
460-
const struct fscrypt_info *ci;
461+
const struct fscrypt_inode_info *ci;
461462
u32 dun;
462463

463464
if (!fscrypt_inode_uses_inline_crypto(inode))

fs/crypto/keyring.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ static void shrink_dcache_inode(struct inode *inode)
867867

868868
static void evict_dentries_for_decrypted_inodes(struct fscrypt_master_key *mk)
869869
{
870-
struct fscrypt_info *ci;
870+
struct fscrypt_inode_info *ci;
871871
struct inode *inode;
872872
struct inode *toput_inode = NULL;
873873

@@ -917,7 +917,7 @@ static int check_for_busy_inodes(struct super_block *sb,
917917
/* select an example file to show for debugging purposes */
918918
struct inode *inode =
919919
list_first_entry(&mk->mk_decrypted_inodes,
920-
struct fscrypt_info,
920+
struct fscrypt_inode_info,
921921
ci_master_key_link)->ci_inode;
922922
ino = inode->i_ino;
923923
}

0 commit comments

Comments
 (0)