Skip to content

Commit 36ea233

Browse files
author
Miklos Szeredi
committed
fuse: write inode in fuse_vma_close() instead of fuse_release()
Fuse ->release() is otherwise asynchronous for the reason that it can happen in contexts unrelated to close/munmap. Inode is already written back from fuse_flush(). Add it to fuse_vma_close() as well to make sure inode dirtying from mmaps also get written out before the file is released. Also add error handling. Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 5c791fe commit 36ea233

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

fs/fuse/file.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,6 @@ static int fuse_open(struct inode *inode, struct file *file)
339339

340340
static int fuse_release(struct inode *inode, struct file *file)
341341
{
342-
struct fuse_conn *fc = get_fuse_conn(inode);
343-
344-
/* see fuse_vma_close() for !writeback_cache case */
345-
if (fc->writeback_cache)
346-
write_inode_now(inode, 1);
347-
348342
fuse_release_common(file, false);
349343

350344
/* return value is ignored by VFS */
@@ -2351,12 +2345,15 @@ static int fuse_launder_page(struct page *page)
23512345
}
23522346

23532347
/*
2354-
* Write back dirty pages now, because there may not be any suitable
2355-
* open files later
2348+
* Write back dirty data/metadata now (there may not be any suitable
2349+
* open files later for data)
23562350
*/
23572351
static void fuse_vma_close(struct vm_area_struct *vma)
23582352
{
2359-
filemap_write_and_wait(vma->vm_file->f_mapping);
2353+
int err;
2354+
2355+
err = write_inode_now(vma->vm_file->f_mapping->host, 1);
2356+
mapping_set_error(vma->vm_file->f_mapping, err);
23602357
}
23612358

23622359
/*

0 commit comments

Comments
 (0)