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.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 763a50daf1c0..128f79c40803 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -754,6 +754,42 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl)
754 return err; 754 return err;
755} 755}
756 756
757static sector_t fuse_bmap(struct address_space *mapping, sector_t block)
758{
759 struct inode *inode = mapping->host;
760 struct fuse_conn *fc = get_fuse_conn(inode);
761 struct fuse_req *req;
762 struct fuse_bmap_in inarg;
763 struct fuse_bmap_out outarg;
764 int err;
765
766 if (!inode->i_sb->s_bdev || fc->no_bmap)
767 return 0;
768
769 req = fuse_get_req(fc);
770 if (IS_ERR(req))
771 return 0;
772
773 memset(&inarg, 0, sizeof(inarg));
774 inarg.block = block;
775 inarg.blocksize = inode->i_sb->s_blocksize;
776 req->in.h.opcode = FUSE_BMAP;
777 req->in.h.nodeid = get_node_id(inode);
778 req->in.numargs = 1;
779 req->in.args[0].size = sizeof(inarg);
780 req->in.args[0].value = &inarg;
781 req->out.numargs = 1;
782 req->out.args[0].size = sizeof(outarg);
783 req->out.args[0].value = &outarg;
784 request_send(fc, req);
785 err = req->out.h.error;
786 fuse_put_request(fc, req);
787 if (err == -ENOSYS)
788 fc->no_bmap = 1;
789
790 return err ? 0 : outarg.block;
791}
792
757static const struct file_operations fuse_file_operations = { 793static const struct file_operations fuse_file_operations = {
758 .llseek = generic_file_llseek, 794 .llseek = generic_file_llseek,
759 .read = do_sync_read, 795 .read = do_sync_read,
@@ -787,6 +823,7 @@ static const struct address_space_operations fuse_file_aops = {
787 .commit_write = fuse_commit_write, 823 .commit_write = fuse_commit_write,
788 .readpages = fuse_readpages, 824 .readpages = fuse_readpages,
789 .set_page_dirty = fuse_set_page_dirty, 825 .set_page_dirty = fuse_set_page_dirty,
826 .bmap = fuse_bmap,
790}; 827};
791 828
792void fuse_init_file_inode(struct inode *inode) 829void fuse_init_file_inode(struct inode *inode)