From patchwork Fri Mar 13 12:06:30 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 11716 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 n2DC7APq013421 for ; Fri, 13 Mar 2009 12:07:10 GMT Received: from dp.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 13453163CD0 for ; Fri, 13 Mar 2009 12:06:55 +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 4CC35163B2D for ; Fri, 13 Mar 2009 12:06:31 +0000 (GMT) Received: from localhost (as.office.etersoft.ru [192.168.0.10]) by mail.etersoft.ru (Postfix) with ESMTP id D01A52D534D; Fri, 13 Mar 2009 15:06:44 +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 4hg+qUHaLDPy; Fri, 13 Mar 2009 15:06:43 +0300 (MSK) Message-ID: <49BA4C46.4080601@etersoft.ru> Date: Fri, 13 Mar 2009 15:06:30 +0300 From: Pavel Shilovsky User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: Jeff Layton Subject: Re: [linux-cifs-client] [PATCH] Cannot allocate memory References: <49B687D8.2060600@etersoft.ru> <20090310150128.46aa7853@tleilax.poochiereds.net> <200903110043.29073.piastry@etersoft.ru> <20090310191133.4cc7624c@tleilax.poochiereds.net> <49B7C50C.5040204@etersoft.ru> <20090311101947.144473af@tleilax.poochiereds.net> In-Reply-To: <20090311101947.144473af@tleilax.poochiereds.net> Cc: linux-cifs-client@lists.samba.org 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 Jeff Layton wrote: >> >> @@ -1418,6 +1420,11 @@ 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); >> > > > >^^^ this is pretty yucky though. Polling and sleeping isn't the way to do > >this. A completion variable + wait_for_completion() might be a better fit. > Ok, thanks a lot for advices. -- Best regards, Pavel Shilovsky. Acked-by: Jeff Layton diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 9fbf4df..a5989aa 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -182,6 +182,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 */ + struct completion done; }; /* diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index cd4ccc8..480c48e 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -337,6 +337,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) bool isMultiRsp; int reconnect; + init_completion(&server->done); current->flags |= PF_MEMALLOC; cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current))); @@ -747,7 +748,6 @@ multi_t2_fnd: kfree(server->hostname); task_to_wake = xchg(&server->tsk, NULL); - kfree(server); length = atomic_dec_return(&tcpSesAllocCount); if (length > 0) @@ -764,6 +764,8 @@ multi_t2_fnd: set_current_state(TASK_RUNNING); } + complete_all(&server->done); + module_put_and_exit(0); } @@ -1418,6 +1420,10 @@ cifs_put_tcp_session(struct TCP_Server_Info *server) task = xchg(&server->tsk, NULL); if (task) force_sig(SIGKILL, task); + + wait_for_completion_interruptible(&server->done); + + kfree(server); } static struct TCP_Server_Info *