aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2008-04-30 03:54:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-30 11:29:50 -0400
commit854512ec358f291bcadd7daea10d6bf3704933de (patch)
treeeb587b95df2200c9765e1feb8cdf16ef3fbb9983
parent3be5a52b30aa5cf9d795b7634f728f612197b1c4 (diff)
fuse: clean up setting i_size in write
Extract common code for setting i_size in write functions into a common helper. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/fuse/file.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 68051f3bdf91..f0f0f278b4ea 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -610,13 +610,24 @@ static int fuse_write_begin(struct file *file, struct address_space *mapping,
610 return 0; 610 return 0;
611} 611}
612 612
613static void fuse_write_update_size(struct inode *inode, loff_t pos)
614{
615 struct fuse_conn *fc = get_fuse_conn(inode);
616 struct fuse_inode *fi = get_fuse_inode(inode);
617
618 spin_lock(&fc->lock);
619 fi->attr_version = ++fc->attr_version;
620 if (pos > inode->i_size)
621 i_size_write(inode, pos);
622 spin_unlock(&fc->lock);
623}
624
613static int fuse_buffered_write(struct file *file, struct inode *inode, 625static int fuse_buffered_write(struct file *file, struct inode *inode,
614 loff_t pos, unsigned count, struct page *page) 626 loff_t pos, unsigned count, struct page *page)
615{ 627{
616 int err; 628 int err;
617 size_t nres; 629 size_t nres;
618 struct fuse_conn *fc = get_fuse_conn(inode); 630 struct fuse_conn *fc = get_fuse_conn(inode);
619 struct fuse_inode *fi = get_fuse_inode(inode);
620 unsigned offset = pos & (PAGE_CACHE_SIZE - 1); 631 unsigned offset = pos & (PAGE_CACHE_SIZE - 1);
621 struct fuse_req *req; 632 struct fuse_req *req;
622 633
@@ -643,12 +654,7 @@ static int fuse_buffered_write(struct file *file, struct inode *inode,
643 err = -EIO; 654 err = -EIO;
644 if (!err) { 655 if (!err) {
645 pos += nres; 656 pos += nres;
646 spin_lock(&fc->lock); 657 fuse_write_update_size(inode, pos);
647 fi->attr_version = ++fc->attr_version;
648 if (pos > inode->i_size)
649 i_size_write(inode, pos);
650 spin_unlock(&fc->lock);
651
652 if (count == PAGE_CACHE_SIZE) 658 if (count == PAGE_CACHE_SIZE)
653 SetPageUptodate(page); 659 SetPageUptodate(page);
654 } 660 }
@@ -766,12 +772,8 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf,
766 } 772 }
767 fuse_put_request(fc, req); 773 fuse_put_request(fc, req);
768 if (res > 0) { 774 if (res > 0) {
769 if (write) { 775 if (write)
770 spin_lock(&fc->lock); 776 fuse_write_update_size(inode, pos);
771 if (pos > inode->i_size)
772 i_size_write(inode, pos);
773 spin_unlock(&fc->lock);
774 }
775 *ppos = pos; 777 *ppos = pos;
776 } 778 }
777 fuse_invalidate_attr(inode); 779 fuse_invalidate_attr(inode);