aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/connect.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2008-08-02 08:00:48 -0400
committerSteve French <sfrench@us.ibm.com>2008-08-03 22:02:15 -0400
commit93d0ec851820688ef5b21a84e7460d3cf405f5c5 (patch)
tree280b8e8ba981f77422e63c9223137e3a24ab98f0 /fs/cifs/connect.c
parent66b8bd3c405389213de1d6ba6c2565990f62004f (diff)
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: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r--fs/cifs/connect.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index b51d5777cde6..34a1fc9dabf5 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -351,11 +351,9 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
351 351
352 current->flags |= PF_MEMALLOC; 352 current->flags |= PF_MEMALLOC;
353 cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current))); 353 cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current)));
354 write_lock(&GlobalSMBSeslock); 354
355 atomic_inc(&tcpSesAllocCount); 355 length = atomic_inc_return(&tcpSesAllocCount);
356 length = tcpSesAllocCount.counter; 356 if (length > 1)
357 write_unlock(&GlobalSMBSeslock);
358 if (length > 1)
359 mempool_resize(cifs_req_poolp, length + cifs_min_rcv, 357 mempool_resize(cifs_req_poolp, length + cifs_min_rcv,
360 GFP_KERNEL); 358 GFP_KERNEL);
361 359
@@ -745,14 +743,11 @@ multi_t2_fnd:
745 coming home not much else we can do but free the memory */ 743 coming home not much else we can do but free the memory */
746 } 744 }
747 745
748 write_lock(&GlobalSMBSeslock);
749 atomic_dec(&tcpSesAllocCount);
750 length = tcpSesAllocCount.counter;
751
752 /* last chance to mark ses pointers invalid 746 /* last chance to mark ses pointers invalid
753 if there are any pointing to this (e.g 747 if there are any pointing to this (e.g
754 if a crazy root user tried to kill cifsd 748 if a crazy root user tried to kill cifsd
755 kernel thread explicitly this might happen) */ 749 kernel thread explicitly this might happen) */
750 write_lock(&GlobalSMBSeslock);
756 list_for_each(tmp, &GlobalSMBSessionList) { 751 list_for_each(tmp, &GlobalSMBSessionList) {
757 ses = list_entry(tmp, struct cifsSesInfo, 752 ses = list_entry(tmp, struct cifsSesInfo,
758 cifsSessionList); 753 cifsSessionList);
@@ -763,6 +758,8 @@ multi_t2_fnd:
763 758
764 kfree(server->hostname); 759 kfree(server->hostname);
765 kfree(server); 760 kfree(server);
761
762 length = atomic_dec_return(&tcpSesAllocCount);
766 if (length > 0) 763 if (length > 0)
767 mempool_resize(cifs_req_poolp, length + cifs_min_rcv, 764 mempool_resize(cifs_req_poolp, length + cifs_min_rcv,
768 GFP_KERNEL); 765 GFP_KERNEL);