[RHEL7,COMMIT] fs/fuse: use kio file_close only on final inode close

Submitted by Konstantin Khorenko on July 18, 2019, 12:29 p.m.

Details

Message ID 201907181229.x6ICTMAn009512@finist-ce7.sw.ru
State New
Series "fs/fuse: use kio file_close only on final inode close"
Headers show

Commit Message

Konstantin Khorenko July 18, 2019, 12:29 p.m.
The commit is pushed to "branch-rh7-3.10.0-957.21.3.vz7.106.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.21.3.vz7.106.6
------>
commit 80d09bf787460f9d7e650854e26a458a1042662a
Author: Alexey Kuznetsov <kuznet@virtuozzo.com>
Date:   Thu Jul 18 15:29:21 2019 +0300

    fs/fuse: use kio file_close only on final inode close
    
    kio.op->file_open is called only on the first open,
    hence kio.op->file_close must be called only on the last close.
    
    It is important, not only we see the warning, noticed in PSBM-96165,
    maps forcibly dropped in file_close can result in data corruption.
    
    Fixes: 9175828fad3e ("fs/fuse kio: drop maps on file close")
    https://jira.sw.ru/browse/PSBM-96165
    
    Signed-off-by: Alexey Kuznetsov <kuznet@virtuozzo.com>
---
 fs/fuse/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 79e64069e06a..344f35562bbe 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -468,7 +468,7 @@  static int fuse_release(struct inode *inode, struct file *file)
 		mutex_lock(&inode->i_mutex);
 		fuse_sync_writes(inode);
 
-		if (ff->fc->kio.op->file_close)
+		if (fi->num_openers == 0 && ff->fc->kio.op->file_close)
 			ff->fc->kio.op->file_close(ff->fc, file, inode);
 		mutex_unlock(&inode->i_mutex);
 	}