--- zzzz-none-000/linux-2.6.19.2/fs/fuse/file.c 2007-01-10 19:10:37.000000000 +0000 +++ davinci-8020-5505/linux-2.6.19.2/fs/fuse/file.c 2008-04-22 14:04:52.000000000 +0000 @@ -11,6 +11,7 @@ #include #include #include +#include static const struct file_operations fuse_direct_io_file_operations; @@ -69,7 +70,7 @@ if (outarg->open_flags & FOPEN_DIRECT_IO) file->f_op = &fuse_direct_io_file_operations; if (!(outarg->open_flags & FOPEN_KEEP_CACHE)) - invalidate_inode_pages(inode->i_mapping); + invalidate_mapping_pages(inode->i_mapping, 0, -1); ff->fh = outarg->fh; file->private_data = ff; } @@ -141,8 +142,13 @@ isdir ? FUSE_RELEASEDIR : FUSE_RELEASE); /* Hold vfsmount and dentry until release is finished */ - req->vfsmount = mntget(file->f_vfsmnt); +#if 1 /* AVM - old kernel */ + req->vfsmount = mntget(file->f_vfsmnt); req->dentry = dget(file->f_dentry); +#else + req->vfsmount = mntget(file->f_path.mnt); + req->dentry = dget(file->f_path.dentry); +#endif request_send_background(fc, req); } @@ -184,7 +190,12 @@ static int fuse_flush(struct file *file, fl_owner_t id) { - struct inode *inode = file->f_dentry->d_inode; + +#if 1 /* AVM - old kernel */ + struct inode *inode = file->f_dentry->d_inode; +#else + struct inode *inode = file->f_path.dentry->d_inode; +#endif struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_file *ff = file->private_data; struct fuse_req *req; @@ -483,10 +494,8 @@ i_size_write(inode, pos); spin_unlock(&fc->lock); - if (offset == 0 && to == PAGE_CACHE_SIZE) { - clear_page_dirty(page); + if (offset == 0 && to == PAGE_CACHE_SIZE) SetPageUptodate(page); - } } fuse_invalidate_attr(inode); return err; @@ -533,7 +542,11 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf, size_t count, loff_t *ppos, int write) { - struct inode *inode = file->f_dentry->d_inode; +#if 1 /* AVM - old kernel */ + struct inode *inode = file->f_dentry->d_inode; +#else + struct inode *inode = file->f_path.dentry->d_inode; +#endif struct fuse_conn *fc = get_fuse_conn(inode); size_t nmax = write ? fc->max_write : fc->max_read; loff_t pos = *ppos; @@ -607,11 +620,17 @@ static ssize_t fuse_direct_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { - struct inode *inode = file->f_dentry->d_inode; +#if 1 /* AVM - old kernel */ + struct inode *inode = file->f_dentry->d_inode; +#else + struct inode *inode = file->f_path.dentry->d_inode; +#endif ssize_t res; /* Don't allow parallel writes to the same file */ mutex_lock(&inode->i_mutex); - res = fuse_direct_io(file, buf, count, ppos, 1); + res = generic_write_checks(file, ppos, &count, 0); + if (!res) + res = fuse_direct_io(file, buf, count, ppos, 1); mutex_unlock(&inode->i_mutex); return res; } @@ -662,7 +681,11 @@ static void fuse_lk_fill(struct fuse_req *req, struct file *file, const struct file_lock *fl, int opcode, pid_t pid) { - struct inode *inode = file->f_dentry->d_inode; +#if 1 /* AVM - old kernel */ + struct inode *inode = file->f_dentry->d_inode; +#else + struct inode *inode = file->f_path.dentry->d_inode; +#endif struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_file *ff = file->private_data; struct fuse_lk_in *arg = &req->misc.lk_in; @@ -682,7 +705,11 @@ static int fuse_getlk(struct file *file, struct file_lock *fl) { - struct inode *inode = file->f_dentry->d_inode; +#if 1 /* AVM - old kernel */ + struct inode *inode = file->f_dentry->d_inode; +#else + struct inode *inode = file->f_path.dentry->d_inode; +#endif struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_req *req; struct fuse_lk_out outarg; @@ -707,7 +734,11 @@ static int fuse_setlk(struct file *file, struct file_lock *fl) { - struct inode *inode = file->f_dentry->d_inode; +#if 1 /* AVM - old kernel */ + struct inode *inode = file->f_dentry->d_inode; +#else + struct inode *inode = file->f_path.dentry->d_inode; +#endif struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_req *req; int opcode = (fl->fl_flags & FL_SLEEP) ? FUSE_SETLKW : FUSE_SETLK; @@ -734,14 +765,22 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl) { - struct inode *inode = file->f_dentry->d_inode; +#if 1 /* AVM - old kernel */ + struct inode *inode = file->f_dentry->d_inode; +#else + struct inode *inode = file->f_path.dentry->d_inode; +#endif struct fuse_conn *fc = get_fuse_conn(inode); int err; if (cmd == F_GETLK) { if (fc->no_lock) { - if (!posix_test_lock(file, fl, fl)) - fl->fl_type = F_UNLCK; +#if 1 /* AVM - old kernel */ + if (!posix_test_lock(file, fl, fl)) + fl->fl_type = F_UNLCK; +#else + posix_test_lock(file, fl); +#endif err = 0; } else err = fuse_getlk(file, fl); @@ -754,6 +793,45 @@ return err; } +// #if 1 /* AVM - old kernel */ +// #else +static sector_t fuse_bmap(struct address_space *mapping, sector_t block) +{ + struct inode *inode = mapping->host; + struct fuse_conn *fc = get_fuse_conn(inode); + struct fuse_req *req; + struct fuse_bmap_in inarg; + struct fuse_bmap_out outarg; + int err; + + if (!inode->i_sb->s_bdev || fc->no_bmap) + return 0; + + req = fuse_get_req(fc); + if (IS_ERR(req)) + return 0; + + memset(&inarg, 0, sizeof(inarg)); + inarg.block = block; + inarg.blocksize = inode->i_sb->s_blocksize; + req->in.h.opcode = FUSE_BMAP; + req->in.h.nodeid = get_node_id(inode); + req->in.numargs = 1; + req->in.args[0].size = sizeof(inarg); + req->in.args[0].value = &inarg; + req->out.numargs = 1; + req->out.args[0].size = sizeof(outarg); + req->out.args[0].value = &outarg; + request_send(fc, req); + err = req->out.h.error; + fuse_put_request(fc, req); + if (err == -ENOSYS) + fc->no_bmap = 1; + + return err ? 0 : outarg.block; +} +// #endif + static const struct file_operations fuse_file_operations = { .llseek = generic_file_llseek, .read = do_sync_read, @@ -787,6 +865,10 @@ .commit_write = fuse_commit_write, .readpages = fuse_readpages, .set_page_dirty = fuse_set_page_dirty, +// #if 1 /* AVM - old kernel */ +// #else + .bmap = fuse_bmap, +// #endif }; void fuse_init_file_inode(struct inode *inode)