Commit c68f5990 authored by Steve French's avatar Steve French Committed by Steve French

[CIFS] Fix CIFS_MAX_MSGSIZE so it can be configured at module_install time,

allowing buffer size to be changed

Signed-off-by: Steve French (sfrench@us.ibm.com)
parent 90f9bb1f
Version 1.28
------------
Add module init parm for large SMB buffer size (to allow it to be changed
from its default of 16K) which is especially useful for large file copy
when mounting with the directio mount option.
Version 1.27
------------
Turn off DNOTIFY (directory change notification support) by default
......
......@@ -634,13 +634,14 @@ cifs_init_request_bufs(void)
{
if(CIFSMaxBufSize < 4096) {
CIFSMaxBufSize = 4096;
cFYI(1,("Buffer size set to minimum of 1 page (4096)"));
} else if (CIFSMaxBufSize > 1024*127) {
CIFSMaxBufSize = 1024 * 127;
cFYI(1,("Buffer size set to maximum"));
} else {
CIFSMaxBufSize &= 0x1FE00; /* Round size to even 512 byte mult*/
}
/* cERROR(1,("CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize)); */
cifs_req_cachep = kmem_cache_create("cifs_request",
CIFS_MAX_MSGSIZE +
CIFSMaxBufSize +
MAX_CIFS_HDR_SIZE, 0,
SLAB_HWCACHE_ALIGN, NULL, NULL);
if (cifs_req_cachep == NULL)
......
......@@ -90,5 +90,5 @@ extern int cifs_setxattr(struct dentry *, const char *, const void *,
size_t, int);
extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t);
extern ssize_t cifs_listxattr(struct dentry *, char *, size_t);
#define CIFS_VERSION "1.27"
#define CIFS_VERSION "1.28"
#endif /* _CIFSFS_H */
......@@ -288,7 +288,7 @@ static int validate_t2(struct smb_t2_rsp * pSMB)
(char *)pSMB;
if((total_size <= (*(u16 *)pBCC)) &&
(total_size <
CIFS_MAX_MSGSIZE+MAX_CIFS_HDR_SIZE)) {
CIFSMaxBufSize+MAX_CIFS_HDR_SIZE)) {
return 0;
}
......@@ -341,7 +341,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
/* probably no need to store and check maxvcs */
server->maxBuf =
min(le32_to_cpu(pSMBr->MaxBufferSize),
(__u32) CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE);
(__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);
server->maxRw = le32_to_cpu(pSMBr->MaxRawSize);
cFYI(0, ("Max buf = %d ", ses->server->maxBuf));
GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey);
......@@ -823,7 +823,7 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
__u16 data_length = le16_to_cpu(pSMBr->DataLength);
*nbytes = data_length;
/*check that DataLength would not go beyond end of SMB */
if ((data_length > CIFS_MAX_MSGSIZE)
if ((data_length > CIFSMaxBufSize)
|| (data_length > count)) {
cFYI(1,("bad length %d for count %d",data_length,count));
rc = -EIO;
......@@ -2359,7 +2359,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
pSMB->SearchAttributes =
cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM |
ATTR_DIRECTORY);
pSMB->SearchCount = cpu_to_le16(CIFS_MAX_MSGSIZE / sizeof (FILE_DIRECTORY_INFO)); /* should this be shrunk even more ? */
pSMB->SearchCount = cpu_to_le16(CIFSMaxBufSize / sizeof (FILE_DIRECTORY_INFO)); /* should this be shrunk even more ? */
pSMB->SearchFlags = cpu_to_le16(CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME);
/* test for Unix extensions */
......@@ -2475,7 +2475,7 @@ CIFSFindFirst2(const int xid, struct cifsTconInfo *tcon,
pSMB->SearchAttributes =
cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM |
ATTR_DIRECTORY);
pSMB->SearchCount= cpu_to_le16(CIFS_MAX_MSGSIZE/sizeof(FILE_UNIX_INFO));
pSMB->SearchCount= cpu_to_le16(CIFSMaxBufSize/sizeof(FILE_UNIX_INFO));
pSMB->SearchFlags = cpu_to_le16(CIFS_SEARCH_CLOSE_AT_END |
CIFS_SEARCH_RETURN_RESUME);
pSMB->InformationLevel = cpu_to_le16(psrch_inf->info_level);
......@@ -2576,7 +2576,7 @@ int CIFSFindNext2(const int xid, struct cifsTconInfo *tcon,
pSMB->SubCommand = cpu_to_le16(TRANS2_FIND_NEXT);
pSMB->SearchHandle = searchHandle; /* always kept as le */
pSMB->SearchCount =
cpu_to_le16(CIFS_MAX_MSGSIZE / sizeof (FILE_UNIX_INFO));
cpu_to_le16(CIFSMaxBufSize / sizeof (FILE_UNIX_INFO));
/* test for Unix extensions */
/* if (tcon->ses->capabilities & CAP_UNIX) {
pSMB->InformationLevel = cpu_to_le16(SMB_FIND_FILE_UNIX);
......@@ -2704,7 +2704,7 @@ CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
pSMB->SearchHandle = searchHandle; /* always kept as le */
findParms->SearchCount = 0; /* set to zero in case of error */
pSMB->SearchCount =
cpu_to_le16(CIFS_MAX_MSGSIZE / sizeof (FILE_UNIX_INFO));
cpu_to_le16(CIFSMaxBufSize / sizeof (FILE_UNIX_INFO));
/* test for Unix extensions */
if (tcon->ses->capabilities & CAP_UNIX) {
pSMB->InformationLevel = cpu_to_le16(SMB_FIND_FILE_UNIX);
......
......@@ -332,7 +332,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
} else {
if (/*(length != sizeof (struct smb_hdr) - 1)
||*/ (pdu_length >
CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE)
CIFSMaxBufSize + MAX_CIFS_HDR_SIZE)
|| (pdu_length <
sizeof (struct smb_hdr) - 1)
||
......
......@@ -1434,8 +1434,6 @@ cifs_readpages(struct file *file, struct address_space *mapping,
spin_unlock(&pTcon->stat_lock);
#endif
if((int)(bytes_read & PAGE_CACHE_MASK) != bytes_read) {
cFYI(1,("Partial page %d of %d read to cache",i++,num_pages));
i++; /* account for partial page */
/* server copy of file can have smaller size than client */
......@@ -1946,7 +1944,7 @@ cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
cifs_sb = CIFS_SB(file->f_dentry->d_sb);
pTcon = cifs_sb->tcon;
bufsize = pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE;
if(bufsize > CIFS_MAX_MSGSIZE) {
if(bufsize > CIFSMaxBufSize) {
rc = -EIO;
FreeXid(xid);
return rc;
......
......@@ -351,7 +351,7 @@ checkSMB(struct smb_hdr *smb, __u16 mid, int length)
("Entering checkSMB with Length: %x, smb_buf_length: %x ",
length, len));
if (((unsigned int)length < 2 + sizeof (struct smb_hdr)) ||
(len > CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4)) {
(len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4)) {
if ((unsigned int)length < 2 + sizeof (struct smb_hdr)) {
cERROR(1, ("Length less than 2 + sizeof smb_hdr "));
if (((unsigned int)length >= sizeof (struct smb_hdr) - 1)
......@@ -359,9 +359,9 @@ checkSMB(struct smb_hdr *smb, __u16 mid, int length)
return 0; /* some error cases do not return wct and bcc */
}
if (len > CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4)
if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4)
cERROR(1,
("smb_buf_length greater than CIFS_MAX_MSGSIZE ... "));
("smb_buf_length greater than MaxBufSize"));
cERROR(1,
("bad smb detected. Illegal length. The mid=%d",
smb->Mid));
......
......@@ -267,7 +267,7 @@ CIFSSendRcv(const unsigned int xid, struct cifsSesInfo *ses,
return -ENOMEM;
}
if (in_buf->smb_buf_length > CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4) {
if (in_buf->smb_buf_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
up(&ses->server->tcpSem);
cERROR(1,
("Illegal length, greater than maximum frame, %d ",
......@@ -397,7 +397,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
return -ENOMEM;
}
if (in_buf->smb_buf_length > CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4) {
if (in_buf->smb_buf_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
up(&ses->server->tcpSem);
cERROR(1,
("Illegal length, greater than maximum frame, %d ",
......@@ -494,7 +494,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
return rc;
}
if (receive_len > CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE) {
if (receive_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) {
cERROR(1,
("Frame too large received. Length: %d Xid: %d",
receive_len, xid));
......
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