Skip to content

Commit

Permalink
fuse: Getting file for writeback helper
Browse files Browse the repository at this point in the history
There will be a .writepageS callback implementation which will need to
get a fuse_file out of a fuse_inode, thus make a helper for this.

Signed-off-by: Maxim Patlasov <MPatlasov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
  • Loading branch information
Pavel Emelyanov authored and Miklos Szeredi committed Oct 1, 2013
1 parent 698fa1d commit adcadfa
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1494,14 +1494,27 @@ static void fuse_writepage_end(struct fuse_conn *fc, struct fuse_req *req)
fuse_writepage_free(fc, req);
}

static struct fuse_file *fuse_write_file(struct fuse_conn *fc,
struct fuse_inode *fi)
{
struct fuse_file *ff;

spin_lock(&fc->lock);
BUG_ON(list_empty(&fi->write_files));
ff = list_entry(fi->write_files.next, struct fuse_file, write_entry);
fuse_file_get(ff);
spin_unlock(&fc->lock);

return ff;
}

static int fuse_writepage_locked(struct page *page)
{
struct address_space *mapping = page->mapping;
struct inode *inode = mapping->host;
struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_inode *fi = get_fuse_inode(inode);
struct fuse_req *req;
struct fuse_file *ff;
struct page *tmp_page;

set_page_writeback(page);
Expand All @@ -1515,13 +1528,8 @@ static int fuse_writepage_locked(struct page *page)
if (!tmp_page)
goto err_free;

spin_lock(&fc->lock);
BUG_ON(list_empty(&fi->write_files));
ff = list_entry(fi->write_files.next, struct fuse_file, write_entry);
req->ff = fuse_file_get(ff);
spin_unlock(&fc->lock);

fuse_write_fill(req, ff, page_offset(page), 0);
req->ff = fuse_write_file(fc, fi);
fuse_write_fill(req, req->ff, page_offset(page), 0);

copy_highpage(tmp_page, page);
req->misc.write.in.write_flags |= FUSE_WRITE_CACHE;
Expand Down

0 comments on commit adcadfa

Please sign in to comment.