aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fuse/file.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-01-17 18:34:51 -0500
committerDavid Woodhouse <dwmw2@infradead.org>2007-01-17 18:34:51 -0500
commit9cdf083f981b8d37b3212400a359368661385099 (patch)
treeaa15a6a08ad87e650dea40fb59b3180bef0d345b /fs/fuse/file.c
parente499e01d234a31d59679b7b1e1cf628d917ba49a (diff)
parenta8b3485287731978899ced11f24628c927890e78 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'fs/fuse/file.c')
-rw-r--r--fs/fuse/file.c59
1 files changed, 47 insertions, 12 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 763a50daf1c0..f63efe1337ec 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -141,8 +141,8 @@ int fuse_release_common(struct inode *inode, struct file *file, int isdir)
141 isdir ? FUSE_RELEASEDIR : FUSE_RELEASE); 141 isdir ? FUSE_RELEASEDIR : FUSE_RELEASE);
142 142
143 /* Hold vfsmount and dentry until release is finished */ 143 /* Hold vfsmount and dentry until release is finished */
144 req->vfsmount = mntget(file->f_vfsmnt); 144 req->vfsmount = mntget(file->f_path.mnt);
145 req->dentry = dget(file->f_dentry); 145 req->dentry = dget(file->f_path.dentry);
146 request_send_background(fc, req); 146 request_send_background(fc, req);
147 } 147 }
148 148
@@ -184,7 +184,7 @@ static u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id)
184 184
185static int fuse_flush(struct file *file, fl_owner_t id) 185static int fuse_flush(struct file *file, fl_owner_t id)
186{ 186{
187 struct inode *inode = file->f_dentry->d_inode; 187 struct inode *inode = file->f_path.dentry->d_inode;
188 struct fuse_conn *fc = get_fuse_conn(inode); 188 struct fuse_conn *fc = get_fuse_conn(inode);
189 struct fuse_file *ff = file->private_data; 189 struct fuse_file *ff = file->private_data;
190 struct fuse_req *req; 190 struct fuse_req *req;
@@ -483,10 +483,8 @@ static int fuse_commit_write(struct file *file, struct page *page,
483 i_size_write(inode, pos); 483 i_size_write(inode, pos);
484 spin_unlock(&fc->lock); 484 spin_unlock(&fc->lock);
485 485
486 if (offset == 0 && to == PAGE_CACHE_SIZE) { 486 if (offset == 0 && to == PAGE_CACHE_SIZE)
487 clear_page_dirty(page);
488 SetPageUptodate(page); 487 SetPageUptodate(page);
489 }
490 } 488 }
491 fuse_invalidate_attr(inode); 489 fuse_invalidate_attr(inode);
492 return err; 490 return err;
@@ -533,7 +531,7 @@ static int fuse_get_user_pages(struct fuse_req *req, const char __user *buf,
533static ssize_t fuse_direct_io(struct file *file, const char __user *buf, 531static ssize_t fuse_direct_io(struct file *file, const char __user *buf,
534 size_t count, loff_t *ppos, int write) 532 size_t count, loff_t *ppos, int write)
535{ 533{
536 struct inode *inode = file->f_dentry->d_inode; 534 struct inode *inode = file->f_path.dentry->d_inode;
537 struct fuse_conn *fc = get_fuse_conn(inode); 535 struct fuse_conn *fc = get_fuse_conn(inode);
538 size_t nmax = write ? fc->max_write : fc->max_read; 536 size_t nmax = write ? fc->max_write : fc->max_read;
539 loff_t pos = *ppos; 537 loff_t pos = *ppos;
@@ -607,7 +605,7 @@ static ssize_t fuse_direct_read(struct file *file, char __user *buf,
607static ssize_t fuse_direct_write(struct file *file, const char __user *buf, 605static ssize_t fuse_direct_write(struct file *file, const char __user *buf,
608 size_t count, loff_t *ppos) 606 size_t count, loff_t *ppos)
609{ 607{
610 struct inode *inode = file->f_dentry->d_inode; 608 struct inode *inode = file->f_path.dentry->d_inode;
611 ssize_t res; 609 ssize_t res;
612 /* Don't allow parallel writes to the same file */ 610 /* Don't allow parallel writes to the same file */
613 mutex_lock(&inode->i_mutex); 611 mutex_lock(&inode->i_mutex);
@@ -662,7 +660,7 @@ static int convert_fuse_file_lock(const struct fuse_file_lock *ffl,
662static void fuse_lk_fill(struct fuse_req *req, struct file *file, 660static void fuse_lk_fill(struct fuse_req *req, struct file *file,
663 const struct file_lock *fl, int opcode, pid_t pid) 661 const struct file_lock *fl, int opcode, pid_t pid)
664{ 662{
665 struct inode *inode = file->f_dentry->d_inode; 663 struct inode *inode = file->f_path.dentry->d_inode;
666 struct fuse_conn *fc = get_fuse_conn(inode); 664 struct fuse_conn *fc = get_fuse_conn(inode);
667 struct fuse_file *ff = file->private_data; 665 struct fuse_file *ff = file->private_data;
668 struct fuse_lk_in *arg = &req->misc.lk_in; 666 struct fuse_lk_in *arg = &req->misc.lk_in;
@@ -682,7 +680,7 @@ static void fuse_lk_fill(struct fuse_req *req, struct file *file,
682 680
683static int fuse_getlk(struct file *file, struct file_lock *fl) 681static int fuse_getlk(struct file *file, struct file_lock *fl)
684{ 682{
685 struct inode *inode = file->f_dentry->d_inode; 683 struct inode *inode = file->f_path.dentry->d_inode;
686 struct fuse_conn *fc = get_fuse_conn(inode); 684 struct fuse_conn *fc = get_fuse_conn(inode);
687 struct fuse_req *req; 685 struct fuse_req *req;
688 struct fuse_lk_out outarg; 686 struct fuse_lk_out outarg;
@@ -707,7 +705,7 @@ static int fuse_getlk(struct file *file, struct file_lock *fl)
707 705
708static int fuse_setlk(struct file *file, struct file_lock *fl) 706static int fuse_setlk(struct file *file, struct file_lock *fl)
709{ 707{
710 struct inode *inode = file->f_dentry->d_inode; 708 struct inode *inode = file->f_path.dentry->d_inode;
711 struct fuse_conn *fc = get_fuse_conn(inode); 709 struct fuse_conn *fc = get_fuse_conn(inode);
712 struct fuse_req *req; 710 struct fuse_req *req;
713 int opcode = (fl->fl_flags & FL_SLEEP) ? FUSE_SETLKW : FUSE_SETLK; 711 int opcode = (fl->fl_flags & FL_SLEEP) ? FUSE_SETLKW : FUSE_SETLK;
@@ -734,7 +732,7 @@ static int fuse_setlk(struct file *file, struct file_lock *fl)
734 732
735static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl) 733static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl)
736{ 734{
737 struct inode *inode = file->f_dentry->d_inode; 735 struct inode *inode = file->f_path.dentry->d_inode;
738 struct fuse_conn *fc = get_fuse_conn(inode); 736 struct fuse_conn *fc = get_fuse_conn(inode);
739 int err; 737 int err;
740 738
@@ -754,6 +752,42 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl)
754 return err; 752 return err;
755} 753}
756 754
755static sector_t fuse_bmap(struct address_space *mapping, sector_t block)
756{
757 struct inode *inode = mapping->host;
758 struct fuse_conn *fc = get_fuse_conn(inode);
759 struct fuse_req *req;
760 struct fuse_bmap_in inarg;
761 struct fuse_bmap_out outarg;
762 int err;
763
764 if (!inode->i_sb->s_bdev || fc->no_bmap)
765 return 0;
766
767 req = fuse_get_req(fc);
768 if (IS_ERR(req))
769 return 0;
770
771 memset(&inarg, 0, sizeof(inarg));
772 inarg.block = block;
773 inarg.blocksize = inode->i_sb->s_blocksize;
774 req->in.h.opcode = FUSE_BMAP;
775 req->in.h.nodeid = get_node_id(inode);
776 req->in.numargs = 1;
777 req->in.args[0].size = sizeof(inarg);
778 req->in.args[0].value = &inarg;
779 req->out.numargs = 1;
780 req->out.args[0].size = sizeof(outarg);
781 req->out.args[0].value = &outarg;
782 request_send(fc, req);
783 err = req->out.h.error;
784 fuse_put_request(fc, req);
785 if (err == -ENOSYS)
786 fc->no_bmap = 1;
787
788 return err ? 0 : outarg.block;
789}
790
757static const struct file_operations fuse_file_operations = { 791static const struct file_operations fuse_file_operations = {
758 .llseek = generic_file_llseek, 792 .llseek = generic_file_llseek,
759 .read = do_sync_read, 793 .read = do_sync_read,
@@ -787,6 +821,7 @@ static const struct address_space_operations fuse_file_aops = {
787 .commit_write = fuse_commit_write, 821 .commit_write = fuse_commit_write,
788 .readpages = fuse_readpages, 822 .readpages = fuse_readpages,
789 .set_page_dirty = fuse_set_page_dirty, 823 .set_page_dirty = fuse_set_page_dirty,
824 .bmap = fuse_bmap,
790}; 825};
791 826
792void fuse_init_file_inode(struct inode *inode) 827void fuse_init_file_inode(struct inode *inode)