v9fs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t pos)
{
struct file *file = iocb->ki_filp;
- if (rw == WRITE) {
- ssize_t written;
- int err = 0;
-
- written = p9_client_write(file->private_data, pos, iter, &err);
- if (written) {
+ ssize_t n;
+ int err = 0;
+ if (rw & WRITE) {
+ n = p9_client_write(file->private_data, pos, iter, &err);
+ if (n) {
struct inode *inode = file_inode(file);
loff_t i_size = i_size_read(inode);
- if (pos + written > i_size)
- inode_add_bytes(inode, pos + written - i_size);
- return written;
+ if (pos + n > i_size)
+ inode_add_bytes(inode, pos + n - i_size);
}
- return err;
+ } else {
+ n = p9_client_read(file->private_data, pos, iter, &err);
}
- return -EINVAL;
+ return n ? n : err;
}
static int v9fs_write_begin(struct file *filp, struct address_space *mapping,
return VM_FAULT_NOPAGE;
}
-static ssize_t
-v9fs_direct_read(struct file *filp, char __user *udata, size_t count,
- loff_t *offsetp)
-{
- loff_t size, offset;
- struct inode *inode;
- struct address_space *mapping;
-
- offset = *offsetp;
- mapping = filp->f_mapping;
- inode = mapping->host;
- if (!count)
- return 0;
- size = i_size_read(inode);
- if (offset < size)
- filemap_write_and_wait_range(mapping, offset,
- offset + count - 1);
-
- return v9fs_file_read(filp, udata, count, offsetp);
-}
-
-/**
- * v9fs_cached_file_read - read from a file
- * @filp: file pointer to read
- * @data: user data buffer to read data into
- * @count: size of buffer
- * @offset: offset at which to read data
- *
- */
-static ssize_t
-v9fs_cached_file_read(struct file *filp, char __user *data, size_t count,
- loff_t *offset)
-{
- if (filp->f_flags & O_DIRECT)
- return v9fs_direct_read(filp, data, count, offset);
- return new_sync_read(filp, data, count, offset);
-}
-
/**
* v9fs_mmap_file_read - read from a file
* @filp: file pointer to read
const struct file_operations v9fs_cached_file_operations = {
.llseek = generic_file_llseek,
- .read = v9fs_cached_file_read,
+ .read = new_sync_read,
.write = new_sync_write,
.read_iter = generic_file_read_iter,
.write_iter = generic_file_write_iter,
const struct file_operations v9fs_cached_file_operations_dotl = {
.llseek = generic_file_llseek,
- .read = v9fs_cached_file_read,
+ .read = new_sync_read,
.write = new_sync_write,
.read_iter = generic_file_read_iter,
.write_iter = generic_file_write_iter,