From: Miklos Szeredi In case a filesystem is mounted with "direct_io", sendfile should not use the generic function, but return an error instead. The generic sendfile uses the page cache, which could return stale data. Signed-off-by: Miklos Szeredi Signed-off-by: Andrew Morton --- fs/fuse/file.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletion(-) diff -puN fs/fuse/file.c~fuse-direct-i-o-disable-sendfile-with-direct_io fs/fuse/file.c --- 25/fs/fuse/file.c~fuse-direct-i-o-disable-sendfile-with-direct_io 2005-05-10 02:22:10.000000000 -0700 +++ 25-akpm/fs/fuse/file.c 2005-05-10 02:22:10.000000000 -0700 @@ -500,6 +500,17 @@ static int fuse_file_mmap(struct file *f return generic_file_mmap(file, vma); } +static ssize_t fuse_file_sendfile(struct file *file, loff_t *ppos, + size_t count, read_actor_t actor, + void *target) +{ + struct fuse_conn *fc = get_fuse_conn(file->f_dentry->d_inode); + if (fc->flags & FUSE_DIRECT_IO) + return -EINVAL; + else + return generic_file_sendfile(file, ppos, count, actor, target); +} + static int fuse_set_page_dirty(struct page *page) { printk("fuse_set_page_dirty: should not happen\n"); @@ -516,7 +527,7 @@ static struct file_operations fuse_file_ .flush = fuse_flush, .release = fuse_release, .fsync = fuse_fsync, - .sendfile = generic_file_sendfile, + .sendfile = fuse_file_sendfile, }; static struct address_space_operations fuse_file_aops = { _