Commit 4c3bd7e4 authored by Steve French's avatar Steve French Committed by Steve French

[CIFS] Resize cifs request buffer mempools as tcp sessions are added to avoid potential deadlocks.

Signed-off-by: Steve French (sfrench@us.ibm.com)
parent 75ffe424
...@@ -41,8 +41,6 @@ ...@@ -41,8 +41,6 @@
#include "cifs_fs_sb.h" #include "cifs_fs_sb.h"
#include <linux/mm.h> #include <linux/mm.h>
#define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */ #define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */
/* BB when mempool_resize is added back in, we will resize pool on new mount */
#define CIFS_MIN_RCV_POOL 11 /* enough for progress to five servers */
#ifdef CONFIG_CIFS_QUOTA #ifdef CONFIG_CIFS_QUOTA
static struct quotactl_ops cifs_quotactl_ops; static struct quotactl_ops cifs_quotactl_ops;
...@@ -742,6 +740,7 @@ init_cifs(void) ...@@ -742,6 +740,7 @@ init_cifs(void)
*/ */
atomic_set(&sesInfoAllocCount, 0); atomic_set(&sesInfoAllocCount, 0);
atomic_set(&tconInfoAllocCount, 0); atomic_set(&tconInfoAllocCount, 0);
atomic_set(&tcpSesAllocCount,0);
atomic_set(&tcpSesReconnectCount, 0); atomic_set(&tcpSesReconnectCount, 0);
atomic_set(&tconInfoReconnectCount, 0); atomic_set(&tconInfoReconnectCount, 0);
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
termination then *2 for unicode versions */ termination then *2 for unicode versions */
#define MAX_PASSWORD_SIZE 16 #define MAX_PASSWORD_SIZE 16
#define CIFS_MIN_RCV_POOL 4
/* /*
* MAX_REQ is the maximum number of requests that WE will send * MAX_REQ is the maximum number of requests that WE will send
* on one socket concurently. It also matches the most common * on one socket concurently. It also matches the most common
...@@ -391,7 +393,7 @@ GLOBAL_EXTERN char Local_System_Name[15]; ...@@ -391,7 +393,7 @@ GLOBAL_EXTERN char Local_System_Name[15];
*/ */
GLOBAL_EXTERN atomic_t sesInfoAllocCount; GLOBAL_EXTERN atomic_t sesInfoAllocCount;
GLOBAL_EXTERN atomic_t tconInfoAllocCount; GLOBAL_EXTERN atomic_t tconInfoAllocCount;
GLOBAL_EXTERN atomic_t tcpSesAllocCount;
GLOBAL_EXTERN atomic_t tcpSesReconnectCount; GLOBAL_EXTERN atomic_t tcpSesReconnectCount;
GLOBAL_EXTERN atomic_t tconInfoReconnectCount; GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/utsname.h> #include <linux/utsname.h>
#include <linux/mempool.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/processor.h> #include <asm/processor.h>
#include "cifspdu.h" #include "cifspdu.h"
...@@ -49,6 +50,8 @@ extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, ...@@ -49,6 +50,8 @@ extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8,
unsigned char *p24); unsigned char *p24);
extern int cifs_inet_pton(int, const char *, void *dst); extern int cifs_inet_pton(int, const char *, void *dst);
extern mempool_t *cifs_req_poolp;
struct smb_vol { struct smb_vol {
char *username; char *username;
char *password; char *password;
...@@ -204,6 +207,15 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -204,6 +207,15 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
current->flags |= PF_MEMALLOC; current->flags |= PF_MEMALLOC;
server->tsk = current; /* save process info to wake at shutdown */ server->tsk = current; /* save process info to wake at shutdown */
cFYI(1, ("Demultiplex PID: %d", current->pid)); cFYI(1, ("Demultiplex PID: %d", current->pid));
write_lock(&GlobalSMBSeslock);
atomic_inc(&tcpSesAllocCount);
length = tcpSesAllocCount.counter;
write_unlock(&GlobalSMBSeslock);
if(length > 1) {
mempool_resize(cifs_req_poolp,
length + CIFS_MIN_RCV_POOL,
GFP_KERNEL);
}
while (server->tcpStatus != CifsExiting) { while (server->tcpStatus != CifsExiting) {
if (smb_buffer == NULL) if (smb_buffer == NULL)
...@@ -467,6 +479,16 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -467,6 +479,16 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
} }
kfree(server); kfree(server);
write_lock(&GlobalSMBSeslock);
atomic_dec(&tcpSesAllocCount);
length = tcpSesAllocCount.counter;
write_unlock(&GlobalSMBSeslock);
if(length > 0) {
mempool_resize(cifs_req_poolp,
length + CIFS_MIN_RCV_POOL,
GFP_KERNEL);
}
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ/4); schedule_timeout(HZ/4);
return 0; return 0;
......
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