aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilovsky@samba.org>2012-09-18 19:20:29 -0400
committerSteve French <smfrench@gmail.com>2012-09-24 22:46:28 -0400
commitf9c6e234c3ca64b8d49336908df99948518d6261 (patch)
treec49a8042f3039d8c007018a51bfa0264341a8c32 /fs/cifs/file.c
parent33319141252fd14b58cf13685156c23dcaac2527 (diff)
CIFS: Move readpage code to ops struct
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 703c1648b068..fae03c52f314 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2782,8 +2782,8 @@ ssize_t cifs_strict_readv(struct kiocb *iocb, const struct iovec *iov,
2782 return cifs_user_readv(iocb, iov, nr_segs, pos); 2782 return cifs_user_readv(iocb, iov, nr_segs, pos);
2783} 2783}
2784 2784
2785static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, 2785static ssize_t
2786 loff_t *poffset) 2786cifs_read(struct file *file, char *read_data, size_t read_size, loff_t *offset)
2787{ 2787{
2788 int rc = -EACCES; 2788 int rc = -EACCES;
2789 unsigned int bytes_read = 0; 2789 unsigned int bytes_read = 0;
@@ -2792,8 +2792,9 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
2792 unsigned int rsize; 2792 unsigned int rsize;
2793 struct cifs_sb_info *cifs_sb; 2793 struct cifs_sb_info *cifs_sb;
2794 struct cifs_tcon *tcon; 2794 struct cifs_tcon *tcon;
2795 struct TCP_Server_Info *server;
2795 unsigned int xid; 2796 unsigned int xid;
2796 char *current_offset; 2797 char *cur_offset;
2797 struct cifsFileInfo *open_file; 2798 struct cifsFileInfo *open_file;
2798 struct cifs_io_parms io_parms; 2799 struct cifs_io_parms io_parms;
2799 int buf_type = CIFS_NO_BUFFER; 2800 int buf_type = CIFS_NO_BUFFER;
@@ -2812,6 +2813,12 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
2812 } 2813 }
2813 open_file = file->private_data; 2814 open_file = file->private_data;
2814 tcon = tlink_tcon(open_file->tlink); 2815 tcon = tlink_tcon(open_file->tlink);
2816 server = tcon->ses->server;
2817
2818 if (!server->ops->sync_read) {
2819 free_xid(xid);
2820 return -ENOSYS;
2821 }
2815 2822
2816 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) 2823 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD)
2817 pid = open_file->pid; 2824 pid = open_file->pid;
@@ -2821,9 +2828,8 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
2821 if ((file->f_flags & O_ACCMODE) == O_WRONLY) 2828 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
2822 cFYI(1, "attempting read on write only file instance"); 2829 cFYI(1, "attempting read on write only file instance");
2823 2830
2824 for (total_read = 0, current_offset = read_data; 2831 for (total_read = 0, cur_offset = read_data; read_size > total_read;
2825 read_size > total_read; 2832 total_read += bytes_read, cur_offset += bytes_read) {
2826 total_read += bytes_read, current_offset += bytes_read) {
2827 current_read_size = min_t(uint, read_size - total_read, rsize); 2833 current_read_size = min_t(uint, read_size - total_read, rsize);
2828 /* 2834 /*
2829 * For windows me and 9x we do not want to request more than it 2835 * For windows me and 9x we do not want to request more than it
@@ -2841,13 +2847,13 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
2841 if (rc != 0) 2847 if (rc != 0)
2842 break; 2848 break;
2843 } 2849 }
2844 io_parms.netfid = open_file->fid.netfid;
2845 io_parms.pid = pid; 2850 io_parms.pid = pid;
2846 io_parms.tcon = tcon; 2851 io_parms.tcon = tcon;
2847 io_parms.offset = *poffset; 2852 io_parms.offset = *offset;
2848 io_parms.length = current_read_size; 2853 io_parms.length = current_read_size;
2849 rc = CIFSSMBRead(xid, &io_parms, &bytes_read, 2854 rc = server->ops->sync_read(xid, open_file, &io_parms,
2850 &current_offset, &buf_type); 2855 &bytes_read, &cur_offset,
2856 &buf_type);
2851 } 2857 }
2852 if (rc || (bytes_read == 0)) { 2858 if (rc || (bytes_read == 0)) {
2853 if (total_read) { 2859 if (total_read) {
@@ -2858,7 +2864,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
2858 } 2864 }
2859 } else { 2865 } else {
2860 cifs_stats_bytes_read(tcon, total_read); 2866 cifs_stats_bytes_read(tcon, total_read);
2861 *poffset += bytes_read; 2867 *offset += bytes_read;
2862 } 2868 }
2863 } 2869 }
2864 free_xid(xid); 2870 free_xid(xid);