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: Remove inode lock from __generic_file_fsync()

Inode lock in __generic_file_fsync() protects sync_mapping_buffers() and
sync_inode_metadata() calls. Neither sync_mapping_buffers() nor
sync_inode_metadata() themselves need the protection by inode_lock and
both metadata buffer head writeback and inode writeback can happen
without inode lock (either in case of background writeback or sync(2)
calls). The only protection inode_lock can possibly provide is that
write(2) or other inode modifying calls cannot happen in the middle of
bh+inode writeout and thus result in writeout of inconsistent metadata.
However if writes and fsyncs race, background writeback can submit
inconsistent metadata just after fsync completed even with inode_lock
protecting fsync so this seems moot as well. So let's remove the
apparently pointless inode_lock protection.

Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20260326095354.16340-50-jack@suse.cz
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Jan Kara and committed by
Christian Brauner
ba31a330 2cbfeb4c

-2
-2
fs/libfs.c
··· 1561 1561 if (err) 1562 1562 return err; 1563 1563 1564 - inode_lock(inode); 1565 1564 ret = sync_mapping_buffers(inode->i_mapping); 1566 1565 if (!(inode_state_read_once(inode) & I_DIRTY_ALL)) 1567 1566 goto out; ··· 1572 1573 ret = err; 1573 1574 1574 1575 out: 1575 - inode_unlock(inode); 1576 1576 /* check and advance again to catch errors after syncing out buffers */ 1577 1577 err = file_check_and_advance_wb_err(file); 1578 1578 if (ret == 0)