From 4c3bd7e4ab6f0e5572a43f61f73cff0115d6fc41 Mon Sep 17 00:00:00 2001 From: Steve French Date: Wed, 28 Jul 2004 14:16:47 -0500 Subject: [PATCH] [CIFS] Resize cifs request buffer mempools as tcp sessions are added to avoid potential deadlocks. Signed-off-by: Steve French (sfrench@us.ibm.com) --- fs/cifs/cifsfs.c | 3 +-- fs/cifs/cifsglob.h | 4 +++- fs/cifs/connect.c | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index ad20e058abb19..2607ce38a697a 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -41,8 +41,6 @@ #include "cifs_fs_sb.h" #include #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 static struct quotactl_ops cifs_quotactl_ops; @@ -742,6 +740,7 @@ init_cifs(void) */ atomic_set(&sesInfoAllocCount, 0); atomic_set(&tconInfoAllocCount, 0); + atomic_set(&tcpSesAllocCount,0); atomic_set(&tcpSesReconnectCount, 0); atomic_set(&tconInfoReconnectCount, 0); diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index cfbfac7a74b6d..21ac75cf02d7a 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -32,6 +32,8 @@ termination then *2 for unicode versions */ #define MAX_PASSWORD_SIZE 16 +#define CIFS_MIN_RCV_POOL 4 + /* * MAX_REQ is the maximum number of requests that WE will send * on one socket concurently. It also matches the most common @@ -391,7 +393,7 @@ GLOBAL_EXTERN char Local_System_Name[15]; */ GLOBAL_EXTERN atomic_t sesInfoAllocCount; GLOBAL_EXTERN atomic_t tconInfoAllocCount; - +GLOBAL_EXTERN atomic_t tcpSesAllocCount; GLOBAL_EXTERN atomic_t tcpSesReconnectCount; GLOBAL_EXTERN atomic_t tconInfoReconnectCount; diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index e93f69075c08e..bb6b0f3b2fb20 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include "cifspdu.h" @@ -49,6 +50,8 @@ extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24); extern int cifs_inet_pton(int, const char *, void *dst); +extern mempool_t *cifs_req_poolp; + struct smb_vol { char *username; char *password; @@ -204,6 +207,15 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) current->flags |= PF_MEMALLOC; server->tsk = current; /* save process info to wake at shutdown */ 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) { if (smb_buffer == NULL) @@ -467,6 +479,16 @@ cifs_demultiplex_thread(struct TCP_Server_Info *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); schedule_timeout(HZ/4); return 0; -- 2.53.0