From patchwork Mon Aug 17 12:16:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 42020 Received: from lists.samba.org (fn.samba.org [216.83.154.106]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7HCGQV2011605 for ; Mon, 17 Aug 2009 12:16:26 GMT Received: from fn.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 0017DAD069; Mon, 17 Aug 2009 06:10:07 -0600 (MDT) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on fn.samba.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.8 tests=AWL,BAYES_00, RCVD_IN_DNSWL_MED, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.2.5 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from mx2.redhat.com (mx2.redhat.com [66.187.237.31]) by lists.samba.org (Postfix) with ESMTP id 50E99AD03F for ; Mon, 17 Aug 2009 06:09:53 -0600 (MDT) Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7HCGA1b003958; Mon, 17 Aug 2009 08:16:10 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n7HCGA5i030137; Mon, 17 Aug 2009 08:16:10 -0400 Received: from localhost.localdomain (vpn-12-141.rdu.redhat.com [10.11.12.141]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n7HCG8pg015393; Mon, 17 Aug 2009 08:16:09 -0400 From: Jeff Layton To: smfrench@gmail.com Date: Mon, 17 Aug 2009 08:16:08 -0400 Message-Id: <1250511368-9812-5-git-send-email-jlayton@redhat.com> In-Reply-To: <1250511368-9812-1-git-send-email-jlayton@redhat.com> References: <1250511368-9812-1-git-send-email-jlayton@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Cc: linux-cifs-client@lists.samba.org Subject: [linux-cifs-client] [PATCH 4/4] cifs: hold cifs_oplock_mutex while doing oplock release call X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-cifs-client-bounces@lists.samba.org Errors-To: linux-cifs-client-bounces@lists.samba.org We have to ensure that the tcon isn't freed until after this call completes. After dequeuing an oplock entry, have cifsoplockd hold the cifs_oplock_mutex until the oplock release call completes. We don't want to hold the mutex indefinitely however, so release and reacquire it on each pass through the loop. That should give other tasks access to the queue. Signed-off-by: Jeff Layton --- fs/cifs/cifsfs.c | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 4c724d5..745c3ba 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -1004,7 +1004,6 @@ static int cifs_oplock_thread(void *dummyarg) netfid = oplock_item->netfid; list_del(&oplock_item->qhead); kmem_cache_free(cifs_oplock_cachep, oplock_item); - mutex_unlock(&cifs_oplock_mutex); if (inode && S_ISREG(inode->i_mode)) { cifsi = CIFS_I(inode); @@ -1029,12 +1028,14 @@ static int cifs_oplock_thread(void *dummyarg) } iput(inode); - /* releasing stale oplock after recent reconnect - of smb session using a now incorrect file - handle is not a data integrity issue but do - not bother sending an oplock release if session - to server still is disconnected since oplock - already released by the server in that case */ + /* + * releasing stale oplock after recent reconnect + * of smb session using a now incorrect file + * handle is not a data integrity issue but do + * not bother sending an oplock release if session + * to server still is disconnected since oplock + * already released by the server in that case + */ if (!tcon->need_reconnect) { rc = CIFSSMBLock(0, tcon, netfid, 0 /* len */ , 0 /* offset */, 0, @@ -1042,6 +1043,12 @@ static int cifs_oplock_thread(void *dummyarg) false /* wait flag */); cFYI(1, ("Oplock release rc = %d", rc)); } + + /* + * release and reacquire the oplock mutex in order to + * allow tasks waiting on it to have a chance. + */ + mutex_unlock(&cifs_oplock_mutex); mutex_lock(&cifs_oplock_mutex); } mutex_unlock(&cifs_oplock_mutex);