From patchwork Tue Mar 10 15:31:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 10893 Received: from lists.samba.org (mail.samba.org [66.70.73.150]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2AFVoLe027171 for ; Tue, 10 Mar 2009 15:31:50 GMT Received: from dp.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 0C1A0163C88 for ; Tue, 10 Mar 2009 15:31:36 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on dp.samba.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.8 tests=AWL, BAYES_00 autolearn=ham version=3.1.7 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from mail.etersoft.ru (mail.etersoft.ru [87.249.47.46]) by lists.samba.org (Postfix) with ESMTP id 662F9163BE7 for ; Tue, 10 Mar 2009 15:31:07 +0000 (GMT) Received: from localhost (as.office.etersoft.ru [192.168.0.10]) by mail.etersoft.ru (Postfix) with ESMTP id 4EF532EEA5B for ; Tue, 10 Mar 2009 18:31:20 +0300 (MSK) X-Virus-Scanned: amavisd-new at office.etersoft.ru Received: from mail.etersoft.ru ([192.168.0.1]) by localhost (as.office.etersoft.ru [192.168.0.10]) (amavisd-new, port 10024) with LMTP id DJSzDvypzcYO for ; Tue, 10 Mar 2009 18:31:19 +0300 (MSK) Message-ID: <49B687D8.2060600@etersoft.ru> Date: Tue, 10 Mar 2009 18:31:36 +0300 From: Pavel Shilovsky User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: linux-cifs-client@lists.samba.org Subject: [linux-cifs-client] [PATCH] Cannot allocate memory X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org Errors-To: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org Hello! This patch resolves problem "Cannot allocate memory" during loading module when we do unload/load quickly. During unloading the cifs_demultiplex_thread doesn't have enough time for clearing cache and kmem_cache_destroy fails. Then during loading module it fails with kmem_cache_create: duplicate cache cifs_request. This script can show this bug: rmmod cifs for i in `seq 1 20`; do { echo "trying to mount " $i insmod ./cifs.ko cifsmount [имя шары] [путь] -onoperm umount [путь] rmmod cifs }; done And it fails on 2nd iteration. My patch fixes it. --- Best regards, Pavel Shilovsky. diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 1ae6314..18ba45a 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -176,6 +176,7 @@ struct TCP_Server_Info { struct mac_key mac_signing_key; char ntlmv2_hash[16]; unsigned long lstrp; /* when we got last response from this server */ + int running; }; /* diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index f254235..39daaf2 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -347,6 +347,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) bool isMultiRsp; int reconnect; + server->running = 1; current->flags |= PF_MEMALLOC; cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current))); @@ -758,6 +759,8 @@ multi_t2_fnd: kfree(server->hostname); task_to_wake = xchg(&server->tsk, NULL); + server->running = 0; + msleep(20); kfree(server); length = atomic_dec_return(&tcpSesAllocCount); @@ -1408,6 +1411,9 @@ cifs_put_tcp_session(struct TCP_Server_Info *server) task = xchg(&server->tsk, NULL); if (task) force_sig(SIGKILL, task); + + while(server->running == 1) + msleep(10); } static struct cifsSesInfo *