From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pavel Emelyanov Subject: [PATCH 2/10] fuse: Getting file for writeback helper Date: Tue, 03 Jul 2012 19:54:17 +0400 Message-ID: <4FF315A9.7000809@parallels.com> References: <4FF3156E.8030109@parallels.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: James Bottomley , Kirill Korotaev To: fuse-devel@lists.sourceforge.net, Miklos Szeredi , Alexander Viro , linux-fsdevel Return-path: Received: from mailhub.sw.ru ([195.214.232.25]:42113 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752339Ab2GCPyb (ORCPT ); Tue, 3 Jul 2012 11:54:31 -0400 In-Reply-To: <4FF3156E.8030109@parallels.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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: Pavel Emelyanov --- fs/fuse/file.c | 23 +++++++++++++++-------- 1 files changed, 15 insertions(+), 8 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 7d10b4c..9c32bf5 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1273,6 +1273,19 @@ 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; @@ -1280,7 +1293,6 @@ static int fuse_writepage_locked(struct page *page) 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); @@ -1293,13 +1305,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; -- 1.5.5.6