diff options
-rw-r--r-- | fs/cifs/connect.c | 15 |
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); |