Patchwork [6/8] cifs: add aio_read wrapper for cifs

login
register
mail settings
Submitter Jeff Layton
Date Feb. 11, 2010, 7:58 p.m.
Message ID <1265918330-2810-7-git-send-email-jlayton@redhat.com>
Download mbox | patch
Permalink /patch/45150/
State New
Headers show

Comments

Jeff Layton - Feb. 11, 2010, 7:58 p.m.
Ensure that the inode's validity is revalidated prior to a cache read.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 fs/cifs/cifsfs.c |    4 ++--
 fs/cifs/cifsfs.h |    2 ++
 fs/cifs/file.c   |   19 +++++++++++++++++++
 3 files changed, 23 insertions(+), 2 deletions(-)

Patch

diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 5183bc2..9f1d94e 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -739,7 +739,7 @@  const struct inode_operations cifs_symlink_inode_ops = {
 const struct file_operations cifs_file_ops = {
 	.read = do_sync_read,
 	.write = do_sync_write,
-	.aio_read = generic_file_aio_read,
+	.aio_read = cifs_file_aio_read,
 	.aio_write = cifs_file_aio_write,
 	.open = cifs_open,
 	.release = cifs_close,
@@ -781,7 +781,7 @@  const struct file_operations cifs_file_direct_ops = {
 const struct file_operations cifs_file_nobrl_ops = {
 	.read = do_sync_read,
 	.write = do_sync_write,
-	.aio_read = generic_file_aio_read,
+	.aio_read = cifs_file_aio_read,
 	.aio_write = cifs_file_aio_write,
 	.open = cifs_open,
 	.release = cifs_close,
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 7aa57ec..c7eac06 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -86,6 +86,8 @@  extern ssize_t cifs_user_write(struct file *file, const char __user *write_data,
 extern int cifs_lock(struct file *, int, struct file_lock *);
 extern int cifs_fsync(struct file *, struct dentry *, int);
 extern int cifs_flush(struct file *, fl_owner_t id);
+extern ssize_t cifs_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
+				unsigned long nr_segs, loff_t pos);
 extern int cifs_file_mmap(struct file * , struct vm_area_struct *);
 extern const struct file_operations cifs_dir_ops;
 extern int cifs_dir_open(struct inode *inode, struct file *file);
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 55ff0ad..1f720b2 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1888,6 +1888,25 @@  static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
 	return total_read;
 }
 
+ssize_t
+cifs_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
+		unsigned long nr_segs, loff_t pos)
+{
+	int rc;
+	struct dentry *dentry = iocb->ki_filp->f_path.dentry;
+
+	cFYI(1, ("%s: read(%s/%s), %lu@%lu)", __func__,
+		dentry->d_parent->d_name.name, dentry->d_name.name,
+		(unsigned long) iov_length(iov, nr_segs),
+		(unsigned long) pos));
+
+	rc = cifs_revalidate_file(iocb->ki_filp);
+	if (rc)
+		return rc;
+
+	return generic_file_aio_read(iocb, iov, nr_segs, pos);
+}
+
 int cifs_file_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	int rc, xid;