Commit f9c6e234c3ca64b8d49336908df99948518d6261
Committed by
Steve French
1 parent
3331914125
Exists in
master
and in
20 other branches
CIFS: Move readpage code to ops struct
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steve French <smfrench@gmail.com>
Showing 3 changed files with 32 additions and 11 deletions Side-by-side Diff
fs/cifs/cifsglob.h
... | ... | @@ -174,6 +174,7 @@ |
174 | 174 | struct cifs_fid; |
175 | 175 | struct cifs_readdata; |
176 | 176 | struct cifs_writedata; |
177 | +struct cifs_io_parms; | |
177 | 178 | |
178 | 179 | struct smb_version_operations { |
179 | 180 | int (*send_cancel)(struct TCP_Server_Info *, void *, |
... | ... | @@ -286,6 +287,10 @@ |
286 | 287 | int (*async_readv)(struct cifs_readdata *); |
287 | 288 | /* async write to the server */ |
288 | 289 | int (*async_writev)(struct cifs_writedata *); |
290 | + /* sync read from the server */ | |
291 | + int (*sync_read)(const unsigned int, struct cifsFileInfo *, | |
292 | + struct cifs_io_parms *, unsigned int *, char **, | |
293 | + int *); | |
289 | 294 | }; |
290 | 295 | |
291 | 296 | struct smb_version_values { |
fs/cifs/file.c
... | ... | @@ -2782,8 +2782,8 @@ |
2782 | 2782 | return cifs_user_readv(iocb, iov, nr_segs, pos); |
2783 | 2783 | } |
2784 | 2784 | |
2785 | -static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, | |
2786 | - loff_t *poffset) | |
2785 | +static ssize_t | |
2786 | +cifs_read(struct file *file, char *read_data, size_t read_size, loff_t *offset) | |
2787 | 2787 | { |
2788 | 2788 | int rc = -EACCES; |
2789 | 2789 | unsigned int bytes_read = 0; |
2790 | 2790 | |
... | ... | @@ -2792,8 +2792,9 @@ |
2792 | 2792 | unsigned int rsize; |
2793 | 2793 | struct cifs_sb_info *cifs_sb; |
2794 | 2794 | struct cifs_tcon *tcon; |
2795 | + struct TCP_Server_Info *server; | |
2795 | 2796 | unsigned int xid; |
2796 | - char *current_offset; | |
2797 | + char *cur_offset; | |
2797 | 2798 | struct cifsFileInfo *open_file; |
2798 | 2799 | struct cifs_io_parms io_parms; |
2799 | 2800 | int buf_type = CIFS_NO_BUFFER; |
2800 | 2801 | |
... | ... | @@ -2812,7 +2813,13 @@ |
2812 | 2813 | } |
2813 | 2814 | open_file = file->private_data; |
2814 | 2815 | tcon = tlink_tcon(open_file->tlink); |
2816 | + server = tcon->ses->server; | |
2815 | 2817 | |
2818 | + if (!server->ops->sync_read) { | |
2819 | + free_xid(xid); | |
2820 | + return -ENOSYS; | |
2821 | + } | |
2822 | + | |
2816 | 2823 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) |
2817 | 2824 | pid = open_file->pid; |
2818 | 2825 | else |
... | ... | @@ -2821,9 +2828,8 @@ |
2821 | 2828 | if ((file->f_flags & O_ACCMODE) == O_WRONLY) |
2822 | 2829 | cFYI(1, "attempting read on write only file instance"); |
2823 | 2830 | |
2824 | - for (total_read = 0, current_offset = read_data; | |
2825 | - read_size > total_read; | |
2826 | - total_read += bytes_read, current_offset += bytes_read) { | |
2831 | + for (total_read = 0, cur_offset = read_data; read_size > total_read; | |
2832 | + total_read += bytes_read, cur_offset += bytes_read) { | |
2827 | 2833 | current_read_size = min_t(uint, read_size - total_read, rsize); |
2828 | 2834 | /* |
2829 | 2835 | * For windows me and 9x we do not want to request more than it |
2830 | 2836 | |
2831 | 2837 | |
... | ... | @@ -2841,13 +2847,13 @@ |
2841 | 2847 | if (rc != 0) |
2842 | 2848 | break; |
2843 | 2849 | } |
2844 | - io_parms.netfid = open_file->fid.netfid; | |
2845 | 2850 | io_parms.pid = pid; |
2846 | 2851 | io_parms.tcon = tcon; |
2847 | - io_parms.offset = *poffset; | |
2852 | + io_parms.offset = *offset; | |
2848 | 2853 | io_parms.length = current_read_size; |
2849 | - rc = CIFSSMBRead(xid, &io_parms, &bytes_read, | |
2850 | - ¤t_offset, &buf_type); | |
2854 | + rc = server->ops->sync_read(xid, open_file, &io_parms, | |
2855 | + &bytes_read, &cur_offset, | |
2856 | + &buf_type); | |
2851 | 2857 | } |
2852 | 2858 | if (rc || (bytes_read == 0)) { |
2853 | 2859 | if (total_read) { |
... | ... | @@ -2858,7 +2864,7 @@ |
2858 | 2864 | } |
2859 | 2865 | } else { |
2860 | 2866 | cifs_stats_bytes_read(tcon, total_read); |
2861 | - *poffset += bytes_read; | |
2867 | + *offset += bytes_read; | |
2862 | 2868 | } |
2863 | 2869 | } |
2864 | 2870 | free_xid(xid); |
fs/cifs/smb1ops.c
... | ... | @@ -739,6 +739,15 @@ |
739 | 739 | return CIFSSMBFlush(xid, tcon, fid->netfid); |
740 | 740 | } |
741 | 741 | |
742 | +static int | |
743 | +cifs_sync_read(const unsigned int xid, struct cifsFileInfo *cfile, | |
744 | + struct cifs_io_parms *parms, unsigned int *bytes_read, | |
745 | + char **buf, int *buf_type) | |
746 | +{ | |
747 | + parms->netfid = cfile->fid.netfid; | |
748 | + return CIFSSMBRead(xid, parms, bytes_read, buf, buf_type); | |
749 | +} | |
750 | + | |
742 | 751 | struct smb_version_operations smb1_operations = { |
743 | 752 | .send_cancel = send_nt_cancel, |
744 | 753 | .compare_fids = cifs_compare_fids, |
... | ... | @@ -787,6 +796,7 @@ |
787 | 796 | .flush = cifs_flush_file, |
788 | 797 | .async_readv = cifs_async_readv, |
789 | 798 | .async_writev = cifs_async_writev, |
799 | + .sync_read = cifs_sync_read, | |
790 | 800 | }; |
791 | 801 | |
792 | 802 | struct smb_version_values smb1_values = { |