aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fuse/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/fuse/file.c')
-rw-r--r--fs/fuse/file.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 65586a567d0d..d228c3962ffd 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -324,10 +324,7 @@ static int fuse_release(struct inode *inode, struct file *file)
324 324
325 /* see fuse_vma_close() for !writeback_cache case */ 325 /* see fuse_vma_close() for !writeback_cache case */
326 if (fc->writeback_cache) 326 if (fc->writeback_cache)
327 filemap_write_and_wait(file->f_mapping); 327 write_inode_now(inode, 1);
328
329 if (test_bit(FUSE_I_MTIME_DIRTY, &get_fuse_inode(inode)->state))
330 fuse_flush_mtime(file, true);
331 328
332 fuse_release_common(file, FUSE_RELEASE); 329 fuse_release_common(file, FUSE_RELEASE);
333 330
@@ -449,7 +446,7 @@ static int fuse_flush(struct file *file, fl_owner_t id)
449 if (fc->no_flush) 446 if (fc->no_flush)
450 return 0; 447 return 0;
451 448
452 err = filemap_write_and_wait(file->f_mapping); 449 err = write_inode_now(inode, 1);
453 if (err) 450 if (err)
454 return err; 451 return err;
455 452
@@ -502,12 +499,10 @@ int fuse_fsync_common(struct file *file, loff_t start, loff_t end,
502 goto out; 499 goto out;
503 500
504 fuse_sync_writes(inode); 501 fuse_sync_writes(inode);
502 err = sync_inode_metadata(inode, 1);
503 if (err)
504 goto out;
505 505
506 if (test_bit(FUSE_I_MTIME_DIRTY, &get_fuse_inode(inode)->state)) {
507 err = fuse_flush_mtime(file, false);
508 if (err)
509 goto out;
510 }
511 if ((!isdir && fc->no_fsync) || (isdir && fc->no_fsyncdir)) 506 if ((!isdir && fc->no_fsync) || (isdir && fc->no_fsyncdir))
512 goto out; 507 goto out;
513 508
@@ -1664,13 +1659,13 @@ static void fuse_writepage_end(struct fuse_conn *fc, struct fuse_req *req)
1664 fuse_writepage_free(fc, req); 1659 fuse_writepage_free(fc, req);
1665} 1660}
1666 1661
1667static struct fuse_file *fuse_write_file_get(struct fuse_conn *fc, 1662static struct fuse_file *__fuse_write_file_get(struct fuse_conn *fc,
1668 struct fuse_inode *fi) 1663 struct fuse_inode *fi)
1669{ 1664{
1670 struct fuse_file *ff = NULL; 1665 struct fuse_file *ff = NULL;
1671 1666
1672 spin_lock(&fc->lock); 1667 spin_lock(&fc->lock);
1673 if (!WARN_ON(list_empty(&fi->write_files))) { 1668 if (!list_empty(&fi->write_files)) {
1674 ff = list_entry(fi->write_files.next, struct fuse_file, 1669 ff = list_entry(fi->write_files.next, struct fuse_file,
1675 write_entry); 1670 write_entry);
1676 fuse_file_get(ff); 1671 fuse_file_get(ff);
@@ -1680,6 +1675,29 @@ static struct fuse_file *fuse_write_file_get(struct fuse_conn *fc,
1680 return ff; 1675 return ff;
1681} 1676}
1682 1677
1678static struct fuse_file *fuse_write_file_get(struct fuse_conn *fc,
1679 struct fuse_inode *fi)
1680{
1681 struct fuse_file *ff = __fuse_write_file_get(fc, fi);
1682 WARN_ON(!ff);
1683 return ff;
1684}
1685
1686int fuse_write_inode(struct inode *inode, struct writeback_control *wbc)
1687{
1688 struct fuse_conn *fc = get_fuse_conn(inode);
1689 struct fuse_inode *fi = get_fuse_inode(inode);
1690 struct fuse_file *ff;
1691 int err;
1692
1693 ff = __fuse_write_file_get(fc, fi);
1694 err = fuse_flush_mtime(inode, ff);
1695 if (ff)
1696 fuse_file_put(ff, 0);
1697
1698 return err;
1699}
1700
1683static int fuse_writepage_locked(struct page *page) 1701static int fuse_writepage_locked(struct page *page)
1684{ 1702{
1685 struct address_space *mapping = page->mapping; 1703 struct address_space *mapping = page->mapping;