exfat: replace truncate_lock with inode_lock
PATCH 1/1 exfat: replace truncate_lock with inode_lock
From: Chi Zhiling <[email protected]>
Remove the per-inode truncate_lock and rely on inode_lock instead. exfat_setattr() truncates under inode_lock (held exclusively by the VFS callers), and exfat_aop_bmap() now takes inode_lock shared to exclude a concurrent truncate, providing the same mutual exclusion with a single lock.
Signed-off-by Chi Zhiling <[email protected]>
--- fs/exfat/exfat_fs.h | 2 -- fs/exfat/file.c | 2 -- fs/exfat/inode.c | 5 ++--- fs/exfat/super.c | 1 - 4 files changed, 2 insertions(+), 8 deletions(-)
fs/exfat/exfat_fs.h +0 -2
@@ -298,8 +298,6 @@ struct exfat_inode_info {loff_t zeroed_size;/* hash by i_location */ struct hlist_node i_hash_fat; -/* protect bmap against truncate */ -struct rw_semaphore truncate_lock;struct inode vfs_inode;/* File creation time */ struct timespec64 i_crtime;
fs/exfat/file.c +0 -2
@@ -413,7 +413,6 @@ int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,* about to be freed. */ inode_dio_wait (inode); -down_write (&EXFAT_I (inode)->truncate_lock);truncate_setsize (inode, attr->ia_size);/*
@@ -421,7 +420,6 @@ int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,* is already written by it, so mark_inode_dirty() is unneeded. */ exfat_truncate (inode); -up_write (&EXFAT_I (inode)->truncate_lock); }else mark_inode_dirty (inode);
fs/exfat/inode.c +2 -3
@@ -291,10 +291,9 @@ static sector_t exfat_aop_bmap(struct address_space *mapping, sector_t block) {sector_t blocknr; -/* exfat_get_cluster() assumes the requested blocknr isn't truncated. */ -down_read (&EXFAT_I (mapping->host)->truncate_lock); +inode_lock_shared (mapping->host); blocknr =iomap_bmap (mapping, block, &exfat_iomap_ops); -up_read (&EXFAT_I (mapping->host)->truncate_lock); +inode_unlock_shared (mapping->host);return blocknr; }
fs/exfat/super.c +0 -1
@@ -195,7 +195,6 @@ static struct inode *exfat_alloc_inode(struct super_block *sb)if (!ei)return NULL ; -init_rwsem (&ei->truncate_lock);return &ei->vfs_inode; }
Signature · 1 line
2.53.0
Quoted 10 lines · Chi Zhiling
From: Chi Zhiling <[email protected]>
Remove the per-inode
truncate_lockand rely oninode_lockinstead.exfat_setattr()truncates underinode_lock(held exclusively by the VFS callers), andexfat_aop_bmap()now takesinode_lockshared to exclude a concurrent truncate, providing the same mutual exclusion with a single lock.Signed-off-by Chi Zhiling <[email protected]>
Applied it to #dev.
Thanks!