Commit 08bc0353 authored by Jeff Layton's avatar Jeff Layton Committed by Steve French

cifs: revalidate mapping prior to satisfying read_iter request with cache=loose

Before satisfying a read with cache=loose, we should always check
that the pagecache is valid before allowing a read to be satisfied
out of it.
Reported-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: default avatarJeff Layton <jlayton@poochiereds.net>
Signed-off-by: default avatarSteve French <smfrench@gmail.com>
parent a1d0b84c
...@@ -725,6 +725,19 @@ cifs_do_mount(struct file_system_type *fs_type, ...@@ -725,6 +725,19 @@ cifs_do_mount(struct file_system_type *fs_type,
goto out; goto out;
} }
static ssize_t
cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter)
{
ssize_t rc;
struct inode *inode = file_inode(iocb->ki_filp);
rc = cifs_revalidate_mapping(inode);
if (rc)
return rc;
return generic_file_read_iter(iocb, iter);
}
static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
{ {
struct inode *inode = file_inode(iocb->ki_filp); struct inode *inode = file_inode(iocb->ki_filp);
...@@ -881,7 +894,7 @@ const struct inode_operations cifs_symlink_inode_ops = { ...@@ -881,7 +894,7 @@ const struct inode_operations cifs_symlink_inode_ops = {
const struct file_operations cifs_file_ops = { const struct file_operations cifs_file_ops = {
.read = new_sync_read, .read = new_sync_read,
.write = new_sync_write, .write = new_sync_write,
.read_iter = generic_file_read_iter, .read_iter = cifs_loose_read_iter,
.write_iter = cifs_file_write_iter, .write_iter = cifs_file_write_iter,
.open = cifs_open, .open = cifs_open,
.release = cifs_close, .release = cifs_close,
...@@ -939,7 +952,7 @@ const struct file_operations cifs_file_direct_ops = { ...@@ -939,7 +952,7 @@ const struct file_operations cifs_file_direct_ops = {
const struct file_operations cifs_file_nobrl_ops = { const struct file_operations cifs_file_nobrl_ops = {
.read = new_sync_read, .read = new_sync_read,
.write = new_sync_write, .write = new_sync_write,
.read_iter = generic_file_read_iter, .read_iter = cifs_loose_read_iter,
.write_iter = cifs_file_write_iter, .write_iter = cifs_file_write_iter,
.open = cifs_open, .open = cifs_open,
.release = cifs_close, .release = cifs_close,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment