Commit 93d0ec85 authored by Jeff Layton's avatar Jeff Layton Committed by Steve French

remove locking around tcpSesAllocCount atomic variable

The global tcpSesAllocCount variable is an atomic already and doesn't
really need the extra locking around it. Remove the locking and just use
the atomic_inc_return and atomic_dec_return functions to make sure we
access it correctly.
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 66b8bd3c
...@@ -351,10 +351,8 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -351,10 +351,8 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
current->flags |= PF_MEMALLOC; current->flags |= PF_MEMALLOC;
cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current))); cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current)));
write_lock(&GlobalSMBSeslock);
atomic_inc(&tcpSesAllocCount); length = atomic_inc_return(&tcpSesAllocCount);
length = tcpSesAllocCount.counter;
write_unlock(&GlobalSMBSeslock);
if (length > 1) if (length > 1)
mempool_resize(cifs_req_poolp, length + cifs_min_rcv, mempool_resize(cifs_req_poolp, length + cifs_min_rcv,
GFP_KERNEL); GFP_KERNEL);
...@@ -745,14 +743,11 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -745,14 +743,11 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
coming home not much else we can do but free the memory */ coming home not much else we can do but free the memory */
} }
write_lock(&GlobalSMBSeslock);
atomic_dec(&tcpSesAllocCount);
length = tcpSesAllocCount.counter;
/* last chance to mark ses pointers invalid /* last chance to mark ses pointers invalid
if there are any pointing to this (e.g if there are any pointing to this (e.g
if a crazy root user tried to kill cifsd if a crazy root user tried to kill cifsd
kernel thread explicitly this might happen) */ kernel thread explicitly this might happen) */
write_lock(&GlobalSMBSeslock);
list_for_each(tmp, &GlobalSMBSessionList) { list_for_each(tmp, &GlobalSMBSessionList) {
ses = list_entry(tmp, struct cifsSesInfo, ses = list_entry(tmp, struct cifsSesInfo,
cifsSessionList); cifsSessionList);
...@@ -763,6 +758,8 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -763,6 +758,8 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
kfree(server->hostname); kfree(server->hostname);
kfree(server); kfree(server);
length = atomic_dec_return(&tcpSesAllocCount);
if (length > 0) if (length > 0)
mempool_resize(cifs_req_poolp, length + cifs_min_rcv, mempool_resize(cifs_req_poolp, length + cifs_min_rcv,
GFP_KERNEL); GFP_KERNEL);
......
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