aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2011-10-19 15:30:26 -0400
committerJeff Layton <jlayton@redhat.com>2011-10-19 15:30:26 -0400
commit5eba8ab3606621f7e175ae9f521d71f3ac534f82 (patch)
tree8fe7387d9ec3b284a8c1d4a5d2fc9e49d2c393b5 /fs/cifs/file.c
parent690c5e3163502f229e5b5d455e5212e28c20cd6d (diff)
cifs: allow for larger rsize= options and change defaults
Currently we cap the rsize at a value that fits in CIFSMaxBufSize. That's not needed any longer for readpages. Allow the use of larger values for readpages. cifs_iovec_read and cifs_read however are still limited to the CIFSMaxBufSize. Make sure they don't exceed that. The patch also changes the rsize defaults. The default when unix extensions are enabled is set to 1M for parity with the wsize, and there is a hard cap of ~16M. When unix extensions are not enabled, the default is set to 60k. According to MS-CIFS, Windows servers can only send a max of 60k at a time, so this is more efficient than requesting a larger size. If the user wishes however, the max can be extended up to 128k - the length of the READ_RSP header. Really old servers however require a special hack to ensure that we don't request too large a read. Reviewed-and-Tested-by: Pavel Shilovsky <piastry@etersoft.ru> Signed-off-by: Jeff Layton <jlayton@redhat.com>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 8f6917816fec..a3b545ff5250 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1758,6 +1758,7 @@ cifs_iovec_read(struct file *file, const struct iovec *iov,
1758 struct smb_com_read_rsp *pSMBr; 1758 struct smb_com_read_rsp *pSMBr;
1759 struct cifs_io_parms io_parms; 1759 struct cifs_io_parms io_parms;
1760 char *read_data; 1760 char *read_data;
1761 unsigned int rsize;
1761 __u32 pid; 1762 __u32 pid;
1762 1763
1763 if (!nr_segs) 1764 if (!nr_segs)
@@ -1770,6 +1771,9 @@ cifs_iovec_read(struct file *file, const struct iovec *iov,
1770 xid = GetXid(); 1771 xid = GetXid();
1771 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1772 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1772 1773
1774 /* FIXME: set up handlers for larger reads and/or convert to async */
1775 rsize = min_t(unsigned int, cifs_sb->rsize, CIFSMaxBufSize);
1776
1773 open_file = file->private_data; 1777 open_file = file->private_data;
1774 pTcon = tlink_tcon(open_file->tlink); 1778 pTcon = tlink_tcon(open_file->tlink);
1775 1779
@@ -1782,7 +1786,7 @@ cifs_iovec_read(struct file *file, const struct iovec *iov,
1782 cFYI(1, "attempting read on write only file instance"); 1786 cFYI(1, "attempting read on write only file instance");
1783 1787
1784 for (total_read = 0; total_read < len; total_read += bytes_read) { 1788 for (total_read = 0; total_read < len; total_read += bytes_read) {
1785 cur_len = min_t(const size_t, len - total_read, cifs_sb->rsize); 1789 cur_len = min_t(const size_t, len - total_read, rsize);
1786 rc = -EAGAIN; 1790 rc = -EAGAIN;
1787 read_data = NULL; 1791 read_data = NULL;
1788 1792
@@ -1874,6 +1878,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
1874 unsigned int bytes_read = 0; 1878 unsigned int bytes_read = 0;
1875 unsigned int total_read; 1879 unsigned int total_read;
1876 unsigned int current_read_size; 1880 unsigned int current_read_size;
1881 unsigned int rsize;
1877 struct cifs_sb_info *cifs_sb; 1882 struct cifs_sb_info *cifs_sb;
1878 struct cifs_tcon *pTcon; 1883 struct cifs_tcon *pTcon;
1879 int xid; 1884 int xid;
@@ -1886,6 +1891,9 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
1886 xid = GetXid(); 1891 xid = GetXid();
1887 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1892 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1888 1893
1894 /* FIXME: set up handlers for larger reads and/or convert to async */
1895 rsize = min_t(unsigned int, cifs_sb->rsize, CIFSMaxBufSize);
1896
1889 if (file->private_data == NULL) { 1897 if (file->private_data == NULL) {
1890 rc = -EBADF; 1898 rc = -EBADF;
1891 FreeXid(xid); 1899 FreeXid(xid);
@@ -1905,8 +1913,8 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
1905 for (total_read = 0, current_offset = read_data; 1913 for (total_read = 0, current_offset = read_data;
1906 read_size > total_read; 1914 read_size > total_read;
1907 total_read += bytes_read, current_offset += bytes_read) { 1915 total_read += bytes_read, current_offset += bytes_read) {
1908 current_read_size = min_t(uint, read_size - total_read, 1916 current_read_size = min_t(uint, read_size - total_read, rsize);
1909 cifs_sb->rsize); 1917
1910 /* For windows me and 9x we do not want to request more 1918 /* For windows me and 9x we do not want to request more
1911 than it negotiated since it will refuse the read then */ 1919 than it negotiated since it will refuse the read then */
1912 if ((pTcon->ses) && 1920 if ((pTcon->ses) &&