Skip to content

Commit

Permalink
fscrypt: shrink the size of struct fscrypt_inode_info slightly
Browse files Browse the repository at this point in the history
Shrink the size of struct fscrypt_inode_info by 8 bytes by packing the
small fields into the 64 bits after ci_enc_key.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Eric Biggers <[email protected]>
  • Loading branch information
ebiggers committed Feb 24, 2024
1 parent 2f944c6 commit 8c62f31
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions fs/crypto/fscrypt_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,19 @@ struct fscrypt_inode_info {
struct fscrypt_prepared_key ci_enc_key;

/* True if ci_enc_key should be freed when this struct is freed */
bool ci_owns_key;
u8 ci_owns_key : 1;

#ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT
/*
* True if this inode will use inline encryption (blk-crypto) instead of
* the traditional filesystem-layer encryption.
*/
bool ci_inlinecrypt;
u8 ci_inlinecrypt : 1;
#endif

/* True if ci_dirhash_key is initialized */
u8 ci_dirhash_key_initialized : 1;

/*
* log2 of the data unit size (granularity of contents encryption) of
* this file. This is computable from ci_policy and ci_inode but is
Expand All @@ -242,6 +245,9 @@ struct fscrypt_inode_info {
/* Cached value: log2 of number of data units per FS block */
u8 ci_data_units_per_block_bits;

/* Hashed inode number. Only set for IV_INO_LBLK_32 */
u32 ci_hashed_ino;

/*
* Encryption mode used for this inode. It corresponds to either the
* contents or filenames encryption mode, depending on the inode type.
Expand Down Expand Up @@ -276,16 +282,12 @@ struct fscrypt_inode_info {
* the plaintext filenames -- currently just casefolded directories.
*/
siphash_key_t ci_dirhash_key;
bool ci_dirhash_key_initialized;

/* The encryption policy used by this inode */
union fscrypt_policy ci_policy;

/* This inode's nonce, copied from the fscrypt_context */
u8 ci_nonce[FSCRYPT_FILE_NONCE_SIZE];

/* Hashed inode number. Only set for IV_INO_LBLK_32 */
u32 ci_hashed_ino;
};

typedef enum {
Expand Down

0 comments on commit 8c62f31

Please sign in to comment.