Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs: assert on ->i_count in iput_final()

Notably make sure the count is 0 after the return from ->drop_inode(),
provided we are going to drop.

Inspired by suspicious games played by f2fs.

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Mateusz Guzik and committed by
Christian Brauner
be97a4b6 dc816f8d

+7
+7
fs/inode.c
··· 1879 1879 int drop; 1880 1880 1881 1881 WARN_ON(inode->i_state & I_NEW); 1882 + VFS_BUG_ON_INODE(atomic_read(&inode->i_count) != 0, inode); 1882 1883 1883 1884 if (op->drop_inode) 1884 1885 drop = op->drop_inode(inode); ··· 1893 1892 spin_unlock(&inode->i_lock); 1894 1893 return; 1895 1894 } 1895 + 1896 + /* 1897 + * Re-check ->i_count in case the ->drop_inode() hooks played games. 1898 + * Note we only execute this if the verdict was to drop the inode. 1899 + */ 1900 + VFS_BUG_ON_INODE(atomic_read(&inode->i_count) != 0, inode); 1896 1901 1897 1902 state = inode->i_state; 1898 1903 if (!drop) {