Re: [PATCH v2 15/20] btrfs: store a fscrypt extent context per normal file extent

Sweet Tea Dorminy
2022-09-07T21:39:07Z

> FSCRYPT_EXTENT_CONTEXT_MAX_SIZE is 33 and btrfs_fscrypt_extent_context
> is part of extent_map, that's quite common object. Random sample from
> my
> desktop right now is around 800k objects so this is noticeable. Needs a
> second look.
>
>> +
>> extern const struct fscrypt_operations btrfs_fscrypt_ops;
>> #endif /* BTRFS_FSCRYPT_H */
>> --- a/fs/btrfs/ordered-data.h
>> +++ b/fs/btrfs/ordered-data.h
>> @@ -99,6 +99,7 @@ struct btrfs_ordered_extent {
>> u64 disk_bytenr;
>> u64 disk_num_bytes;
>> u64 offset;
>> + struct btrfs_fscrypt_extent_context fscrypt_context;
>
> And another embedded btrfs_fscrypt_extent_context, that can also get a
> lot of slab objects.

I could certainly define fscrypt_extent_context's as a separate btree
object type, and/or have them be separately allocated and just have a
pointer in the various structures to keep track of them. I didn't have a
separate object for them since its only a 17 or 33 byte object (at
present) on a per-btrfs_file_extent basis, but maybe that would be
better?

I could also #ifdef CONFIG_FS_ENCRYPTION the member in each structure,
if that would help over and beyond either of the previous things.