OSDN Git Service

fs: change test in inode_insert5 for adding to the sb list
authorJeff Layton <jlayton@kernel.org>
Thu, 31 Mar 2022 20:29:00 +0000 (16:29 -0400)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 2 Aug 2022 22:54:11 +0000 (00:54 +0200)
commit18cc912b8a2acaf32589241fbac47192ab90db14
tree898158dda437c2d4ae1d4fdd9eedc14eda0732fc
parent3d7cb6b04c3f3115719235cc6866b10326de34cd
fs: change test in inode_insert5 for adding to the sb list

inode_insert5 currently looks at I_CREATING to decide whether to insert
the inode into the sb list. This test is a bit ambiguous, as I_CREATING
state is not directly related to that list.

This test is also problematic for some upcoming ceph changes to add
fscrypt support. We need to be able to allocate an inode using new_inode
and insert it into the hash later iff we end up using it, and doing that
now means that we double add it and corrupt the list.

What we really want to know in this test is whether the inode is already
in its superblock list, and then add it if it isn't. Have it test for
list_empty instead and ensure that we always initialize the list by
doing it in inode_init_once. It's only ever removed from the list with
list_del_init, so that should be sufficient.

Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/inode.c