]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
remove locking around tcpSesAllocCount atomic variable
authorJeff Layton <jlayton@redhat.com>
Sat, 2 Aug 2008 12:00:48 +0000 (08:00 -0400)
committerSteve French <sfrench@us.ibm.com>
Mon, 4 Aug 2008 02:02:15 +0000 (02:02 +0000)
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>
fs/cifs/connect.c

index b51d5777cde695f308c85a2387a56b743ef1820c..34a1fc9dabf5cd68cdeffa8e0d787c81196e9b7a 100644 (file)
@@ -351,11 +351,9 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
 
        current->flags |= PF_MEMALLOC;
        cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current)));
-       write_lock(&GlobalSMBSeslock);
-       atomic_inc(&tcpSesAllocCount);
-       length = tcpSesAllocCount.counter;
-       write_unlock(&GlobalSMBSeslock);
-       if (length  > 1)
+
+       length = atomic_inc_return(&tcpSesAllocCount);
+       if (length > 1)
                mempool_resize(cifs_req_poolp, length + cifs_min_rcv,
                                GFP_KERNEL);
 
@@ -745,14 +743,11 @@ multi_t2_fnd:
                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
        if there are any pointing to this (e.g
        if a crazy root user tried to kill cifsd
        kernel thread explicitly this might happen) */
+       write_lock(&GlobalSMBSeslock);
        list_for_each(tmp, &GlobalSMBSessionList) {
                ses = list_entry(tmp, struct cifsSesInfo,
                                cifsSessionList);
@@ -763,6 +758,8 @@ multi_t2_fnd:
 
        kfree(server->hostname);
        kfree(server);
+
+       length = atomic_dec_return(&tcpSesAllocCount);
        if (length  > 0)
                mempool_resize(cifs_req_poolp, length + cifs_min_rcv,
                                GFP_KERNEL);