Thread (2 messages) 2 messages, 2 authors, 2021-01-04
STALE2095d

[PATCH] ext2: discard block reservation on last writable file release

From: Chengguang Xu <hidden>
Date: 2021-01-02 10:19:33
Subsystem: ext2 file system, filesystems (vfs and infrastructure), the rest · Maintainers: Jan Kara, Alexander Viro, Christian Brauner, Linus Torvalds

Currently reserved blocks are discarded on every writable
file release, it's not efficient for multiple writer case.

Signed-off-by: Chengguang Xu <redacted>
---
 fs/ext2/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ext2/file.c b/fs/ext2/file.c
index 96044f5dbc0e..9a19d8fe7ffd 100644
--- a/fs/ext2/file.c
+++ b/fs/ext2/file.c
@@ -141,7 +141,7 @@ static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma)
  */
 static int ext2_release_file (struct inode * inode, struct file * filp)
 {
-	if (filp->f_mode & FMODE_WRITE) {
+	if (filp->f_mode & FMODE_WRITE && (atomic_read(&inode->i_writecount) == 1)) {
 		mutex_lock(&EXT2_I(inode)->truncate_mutex);
 		ext2_discard_reservation(inode);
 		mutex_unlock(&EXT2_I(inode)->truncate_mutex);
-- 
2.18.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help