Skip to contentSkip to conversation

ceph: remove superfluous inode_lock in ceph_fsync

PATCH Applied Jeff Layton 2 participants 2 messages Apr 8, 2019 – Apr 9, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: remove superfluous inode_lock in ceph_fsync

Originally, filemap_write_and_wait took the i_mutex internally, but commit 02c24a82187d pushed the mutex acquisition into the individual fsync routines, leaving it up to the subsystem maintainers to remove it if it wasn't needed.

For ceph, I see no reason to take the inode_lock here. All of the operations inside that lock are protected by their own locking.

---
 fs/ceph/caps.c | 3 ---
 1 file changed, 3 deletions(-)
fs/ceph/caps.c +0 -3
index 36a8dc699448..f976939f771f 100644
@@ -2257,8 +2257,6 @@ int ceph_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 	if (datasync)
 		goto out;
 
-	inode_lock(inode);
-
 	dirty = try_flush_caps(inode, &flush_tid);
 	dout("fsync dirty caps are %s\n", ceph_cap_string(dirty));
 
@@ -2273,7 +2271,6 @@ int ceph_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 		ret = wait_event_interruptible(ci->i_cap_wq,
 					caps_are_flushed(inode, flush_tid));
 	}
-	inode_unlock(inode);
 out:
 	dout("fsync %p%s result=%d\n", inode, datasync ? " datasync" : "", ret);
 	return ret;
Signature · 1 line
2.20.1
Applied
#1 lore raw
Quoted 28 lines · Jeff Layton

Originally, filemap_write_and_wait took the i_mutex internally, but commit 02c24a82187d pushed the mutex acquisition into the individual fsync routines, leaving it up to the subsystem maintainers to remove it if it wasn't needed.

For ceph, I see no reason to take the inode_lock here. All of the operations inside that lock are protected by their own locking.

---
  fs/ceph/caps.c | 3 ---
  1 file changed, 3 deletions(-)
fs/ceph/caps.c +0 -2
index 36a8dc699448..f976939f771f 100644
@@ -2257,8 +2257,6 @@ int ceph_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  	if (datasync)
  		goto out;
 
-	inode_lock(inode);
-
  	dirty = try_flush_caps(inode, &flush_tid);
  	dout("fsync dirty caps are %s\n", ceph_cap_string(dirty));
 

fs/ceph/caps.c int ceph_fsync(struct file *file, loff_t start, loff_t end, int datasync) · line 2276

Quoted 7 lines
fs/ceph/caps.c +0 -1
@@ -2273,7 +2271,6 @@ int ceph_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  		ret = wait_event_interruptible(ci->i_cap_wq,
  					caps_are_flushed(inode, flush_tid));
  	}
-	inode_unlock(inode);
  out:
  	dout("fsync %p%s result=%d\n", inode, datasync ? " datasync" : "", ret);
  	return ret;

Applied, thanks

Yan, Zheng