Skip to content

Commit 56e7b31

Browse files
committed
Merge tag 'vfs-6.18-rc1.inode' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs inode updates from Christian Brauner: "This contains a series I originally wrote and that Eric brought over the finish line. It moves out the i_crypt_info and i_verity_info pointers out of 'struct inode' and into the fs-specific part of the inode. So now the few filesytems that actually make use of this pay the price in their own private inode storage instead of forcing it upon every user of struct inode. The pointer for the crypt and verity info is simply found by storing an offset to its address in struct fsverity_operations and struct fscrypt_operations. This shrinks struct inode by 16 bytes. I hope to move a lot more out of it in the future so that struct inode becomes really just about very core stuff that we need, much like struct dentry and struct file, instead of the dumping ground it has become over the years. On top of this are a various changes associated with the ongoing inode lifetime handling rework that multiple people are pushing forward: - Stop accessing inode->i_count directly in f2fs and gfs2. They simply should use the __iget() and iput() helpers - Make the i_state flags an enum - Rework the iput() logic Currently, if we are the last iput, and we have the I_DIRTY_TIME bit set, we will grab a reference on the inode again and then mark it dirty and then redo the put. This is to make sure we delay the time update for as long as possible We can rework this logic to simply dec i_count if it is not 1, and if it is do the time update while still holding the i_count reference Then we can replace the atomic_dec_and_lock with locking the ->i_lock and doing atomic_dec_and_test, since we did the atomic_add_unless above - Add an icount_read() helper and convert everyone that accesses inode->i_count directly for this purpose to use the helper - Expand dump_inode() to dump more information about an inode helping in debugging - Add some might_sleep() annotations to iput() and associated helpers" * tag 'vfs-6.18-rc1.inode' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: fs: add might_sleep() annotation to iput() and more fs: expand dump_inode() inode: fix whitespace issues fs: add an icount_read helper fs: rework iput logic fs: make the i_state flags an enum fs: stop accessing ->i_count directly in f2fs and gfs2 fsverity: check IS_VERITY() in fsverity_cleanup_inode() fs: remove inode::i_verity_info btrfs: move verity info pointer to fs-specific part of inode f2fs: move verity info pointer to fs-specific part of inode ext4: move verity info pointer to fs-specific part of inode fsverity: add support for info in fs-specific part of inode fs: remove inode::i_crypt_info ceph: move crypt info pointer to fs-specific part of inode ubifs: move crypt info pointer to fs-specific part of inode f2fs: move crypt info pointer to fs-specific part of inode ext4: move crypt info pointer to fs-specific part of inode fscrypt: add support for info in fs-specific part of inode fscrypt: replace raw loads of info pointer with helper function
2 parents 3a2a5b2 + c3c616c commit 56e7b31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+428
-234
lines changed

arch/powerpc/platforms/cell/spufs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ static int spufs_mfc_open(struct inode *inode, struct file *file)
14301430
if (ctx->owner != current->mm)
14311431
return -EINVAL;
14321432

1433-
if (atomic_read(&inode->i_count) != 1)
1433+
if (icount_read(inode) != 1)
14341434
return -EBUSY;
14351435

14361436
mutex_lock(&ctx->mapping_lock);

fs/btrfs/btrfs_inode.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,11 @@ struct btrfs_inode {
338338
struct list_head delayed_iput;
339339

340340
struct rw_semaphore i_mmap_lock;
341+
342+
#ifdef CONFIG_FS_VERITY
343+
struct fsverity_info *i_verity_info;
344+
#endif
345+
341346
struct inode vfs_inode;
342347
};
343348

fs/btrfs/inode.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4556,7 +4556,7 @@ static void btrfs_prune_dentries(struct btrfs_root *root)
45564556

45574557
inode = btrfs_find_first_inode(root, min_ino);
45584558
while (inode) {
4559-
if (atomic_read(&inode->vfs_inode.i_count) > 1)
4559+
if (icount_read(&inode->vfs_inode) > 1)
45604560
d_prune_aliases(&inode->vfs_inode);
45614561

45624562
min_ino = btrfs_ino(inode) + 1;
@@ -7981,6 +7981,9 @@ static void init_once(void *foo)
79817981
struct btrfs_inode *ei = foo;
79827982

79837983
inode_init_once(&ei->vfs_inode);
7984+
#ifdef CONFIG_FS_VERITY
7985+
ei->i_verity_info = NULL;
7986+
#endif
79847987
}
79857988

79867989
void __cold btrfs_destroy_cachep(void)

fs/btrfs/verity.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,8 @@ static int btrfs_write_merkle_tree_block(struct inode *inode, const void *buf,
802802
}
803803

804804
const struct fsverity_operations btrfs_verityops = {
805+
.inode_info_offs = (int)offsetof(struct btrfs_inode, i_verity_info) -
806+
(int)offsetof(struct btrfs_inode, vfs_inode),
805807
.begin_enable_verity = btrfs_begin_enable_verity,
806808
.end_enable_verity = btrfs_end_enable_verity,
807809
.get_verity_descriptor = btrfs_get_verity_descriptor,

fs/ceph/crypto.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ static const union fscrypt_policy *ceph_get_dummy_policy(struct super_block *sb)
133133
}
134134

135135
static struct fscrypt_operations ceph_fscrypt_ops = {
136+
.inode_info_offs= (int)offsetof(struct ceph_inode_info, i_crypt_info) -
137+
(int)offsetof(struct ceph_inode_info, netfs.inode),
136138
.needs_bounce_pages= 1,
137139
.get_context= ceph_crypt_get_context,
138140
.set_context= ceph_crypt_set_context,

fs/ceph/inode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb)
711711
ci->i_work_mask = 0;
712712
memset(&ci->i_btime, '\0', sizeof(ci->i_btime));
713713
#ifdef CONFIG_FS_ENCRYPTION
714+
ci->i_crypt_info = NULL;
714715
ci->fscrypt_auth = NULL;
715716
ci->fscrypt_auth_len = 0;
716717
#endif

fs/ceph/mds_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2221,7 +2221,7 @@ static int trim_caps_cb(struct inode *inode, int mds, void *arg)
22212221
int count;
22222222
dput(dentry);
22232223
d_prune_aliases(inode);
2224-
count = atomic_read(&inode->i_count);
2224+
count = icount_read(inode);
22252225
if (count == 1)
22262226
(*remaining)--;
22272227
doutc(cl, "%p %llx.%llx cap %p pruned, count now %d\n",

fs/ceph/super.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ struct ceph_inode_info {
463463
unsigned long i_work_mask;
464464

465465
#ifdef CONFIG_FS_ENCRYPTION
466+
struct fscrypt_inode_info *i_crypt_info;
466467
u32 fscrypt_auth_len;
467468
u32 fscrypt_file_len;
468469
u8 *fscrypt_auth;

fs/crypto/bio.c

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

fs/crypto/crypto.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ struct page *fscrypt_encrypt_pagecache_blocks(struct folio *folio,
173173
size_t len, size_t offs, gfp_t gfp_flags)
174174
{
175175
const struct inode *inode = folio->mapping->host;
176-
const struct fscrypt_inode_info *ci = inode->i_crypt_info;
176+
const struct fscrypt_inode_info *ci = fscrypt_get_inode_info_raw(inode);
177177
const unsigned int du_bits = ci->ci_data_unit_bits;
178178
const unsigned int du_size = 1U << du_bits;
179179
struct page *ciphertext_page;
@@ -232,8 +232,9 @@ int fscrypt_encrypt_block_inplace(const struct inode *inode, struct page *page,
232232
{
233233
if (WARN_ON_ONCE(inode->i_sb->s_cop->supports_subblock_data_units))
234234
return -EOPNOTSUPP;
235-
return fscrypt_crypt_data_unit(inode->i_crypt_info, FS_ENCRYPT,
236-
lblk_num, page, page, len, offs);
235+
return fscrypt_crypt_data_unit(fscrypt_get_inode_info_raw(inode),
236+
FS_ENCRYPT, lblk_num, page, page, len,
237+
offs);
237238
}
238239
EXPORT_SYMBOL(fscrypt_encrypt_block_inplace);
239240

@@ -255,7 +256,7 @@ int fscrypt_decrypt_pagecache_blocks(struct folio *folio, size_t len,
255256
size_t offs)
256257
{
257258
const struct inode *inode = folio->mapping->host;
258-
const struct fscrypt_inode_info *ci = inode->i_crypt_info;
259+
const struct fscrypt_inode_info *ci = fscrypt_get_inode_info_raw(inode);
259260
const unsigned int du_bits = ci->ci_data_unit_bits;
260261
const unsigned int du_size = 1U << du_bits;
261262
u64 index = ((u64)folio->index << (PAGE_SHIFT - du_bits)) +
@@ -305,8 +306,9 @@ int fscrypt_decrypt_block_inplace(const struct inode *inode, struct page *page,
305306
{
306307
if (WARN_ON_ONCE(inode->i_sb->s_cop->supports_subblock_data_units))
307308
return -EOPNOTSUPP;
308-
return fscrypt_crypt_data_unit(inode->i_crypt_info, FS_DECRYPT,
309-
lblk_num, page, page, len, offs);
309+
return fscrypt_crypt_data_unit(fscrypt_get_inode_info_raw(inode),
310+
FS_DECRYPT, lblk_num, page, page, len,
311+
offs);
310312
}
311313
EXPORT_SYMBOL(fscrypt_decrypt_block_inplace);
312314

0 commit comments

Comments
 (0)