]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
fs: rework iput logic
authorJosef Bacik <josef@toxicpanda.com>
Tue, 26 Aug 2025 15:39:03 +0000 (11:39 -0400)
committerChristian Brauner <brauner@kernel.org>
Mon, 1 Sep 2025 10:38:04 +0000 (12:38 +0200)
commit9e70e985bdc2c6fe7a160e4d59ddd7c0a39bc077
tree83a769d62d2641591aa3f6e9e89c2c845733dcc7
parent9a98f9e84cfbeaa51af42ba2b8bbbde046c709a7
fs: rework 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.

Co-developed-by: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/be208b89bdb650202e712ce2bcfc407ac7044c7a.1756222464.git.josef@toxicpanda.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/inode.c