From patchwork Sat Feb 6 13:22:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 102655 Received: from lists.samba.org (fn.samba.org [216.83.154.106]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4RCZlDF013176 for ; Thu, 27 May 2010 12:36:41 GMT Received: from fn.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 4019F46637; Thu, 27 May 2010 06:35:27 -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.6 required=3.8 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.2.5 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from slow3-v.mail.gandi.net (slow3-v.mail.gandi.net [217.70.178.89]) by lists.samba.org (Postfix) with ESMTP id 1BD05AD1C6; Sat, 6 Feb 2010 06:36:22 -0700 (MST) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by slow3-v.mail.gandi.net (Postfix) with ESMTP id 63AFE3975A; Sat, 6 Feb 2010 14:23:36 +0100 (CET) Received: from d4rwin.no-ip.org (unknown [193.153.49.185]) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 1C40A2552F5; Sat, 6 Feb 2010 14:23:02 +0100 (CET) Received: by d4rwin.no-ip.org (Postfix, from userid 1000) id BF4DC4C4EE; Sat, 6 Feb 2010 14:22:51 +0100 (CET) Date: Sat, 6 Feb 2010 14:22:51 +0100 From: Matthias Kaehlcke To: Steve French , Jeff Layton Message-ID: <20100206132251.GE19106@darwin> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Mailman-Approved-At: Thu, 27 May 2010 06:34:18 -0600 Cc: samba-technical@lists.samba.org, linux-cifs-client@lists.samba.org Subject: [linux-cifs-client] [PATCH] CIFS: Convert semaphore sesSem into a mutex 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: , Sender: linux-cifs-client-bounces@lists.samba.org Errors-To: linux-cifs-client-bounces@lists.samba.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 27 May 2010 12:36:41 +0000 (UTC) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 4b35f7e..f6ed65c 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -18,6 +18,7 @@ */ #include #include +#include #include #include "cifs_fs_sb.h" #include "cifsacl.h" @@ -204,7 +205,7 @@ struct cifsUidInfo { struct cifsSesInfo { struct list_head smb_ses_list; struct list_head tcon_list; - struct semaphore sesSem; + struct mutex ses_lock; #if 0 struct cifsUidInfo *uidInfo; /* pointer to user info */ #endif @@ -633,9 +634,12 @@ require use of the stronger protocol */ * f_owner.lock protects certain per file struct operations * mapping->page_lock protects certain per page operations * + * Mutexes + * ------- + * ses_lock operations on smb session + * * Semaphores * ---------- - * sesSem operations on smb session * tconSem operations on tree connection * fh_sem file handle reconnection operations * diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 941441d..827f5f8 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -170,19 +170,19 @@ cifs_reconnect_tcon(struct cifsTconInfo *tcon, int smb_command) * need to prevent multiple threads trying to simultaneously * reconnect the same SMB session */ - down(&ses->sesSem); + mutex_lock(&ses->ses_lock); if (ses->need_reconnect) rc = cifs_setup_session(0, ses, nls_codepage); /* do we need to reconnect tcon? */ if (rc || !tcon->need_reconnect) { - up(&ses->sesSem); + mutex_unlock(&ses->ses_lock); goto out; } mark_open_files_invalid(tcon); rc = CIFSTCon(0, ses, tcon->treeName, tcon, nls_codepage); - up(&ses->sesSem); + mutex_unlock(&ses->ses_lock); cFYI(1, ("reconnect tcon rc = %d", rc)); if (rc) @@ -700,13 +700,13 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses) if (!ses || !ses->server) return -EIO; - down(&ses->sesSem); + mutex_lock(&ses->ses_lock); if (ses->need_reconnect) goto session_already_dead; /* no need to send SMBlogoff if uid already closed due to reconnect */ rc = small_smb_init(SMB_COM_LOGOFF_ANDX, 2, NULL, (void **)&pSMB); if (rc) { - up(&ses->sesSem); + mutex_unlock(&ses->ses_lock); return rc; } @@ -721,7 +721,7 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses) pSMB->AndXCommand = 0xFF; rc = SendReceiveNoRsp(xid, ses, (struct smb_hdr *) pSMB, 0); session_already_dead: - up(&ses->sesSem); + mutex_unlock(&ses->ses_lock); /* if session dead then we do not need to do ulogoff, since server closed smb session, no sense reporting diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 31bfa49..6e6065e 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -2344,13 +2344,13 @@ try_mount_again: */ cifs_put_tcp_session(srvTcp); - down(&pSesInfo->sesSem); + mutex_lock(&pSesInfo->ses_lock); if (pSesInfo->need_reconnect) { cFYI(1, ("Session needs reconnect")); rc = cifs_setup_session(xid, pSesInfo, cifs_sb->local_nls); } - up(&pSesInfo->sesSem); + mutex_unlock(&pSesInfo->ses_lock); } else if (!rc) { cFYI(1, ("Existing smb sess not found")); pSesInfo = sesInfoAlloc(); @@ -2393,12 +2393,12 @@ try_mount_again: } pSesInfo->linux_uid = volume_info->linux_uid; pSesInfo->overrideSecFlg = volume_info->secFlg; - down(&pSesInfo->sesSem); + mutex_lock(&pSesInfo->ses_lock); /* BB FIXME need to pass vol->secFlgs BB */ rc = cifs_setup_session(xid, pSesInfo, cifs_sb->local_nls); - up(&pSesInfo->sesSem); + mutex_unlock(&pSesInfo->ses_lock); } /* search for existing tcon to this server share */ @@ -2436,7 +2436,7 @@ try_mount_again: rc = -ENODEV; goto mount_fail_check; } else { - /* BB Do we need to wrap sesSem around + /* BB Do we need to wrap ses_lock around * this TCon call and Unix SetFS as * we do on SessSetup and reconnect? */ rc = CIFSTCon(xid, pSesInfo, volume_info->UNC, diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index d27d4ec..679b82a 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c @@ -79,7 +79,7 @@ sesInfoAlloc(void) ++ret_buf->ses_count; INIT_LIST_HEAD(&ret_buf->smb_ses_list); INIT_LIST_HEAD(&ret_buf->tcon_list); - init_MUTEX(&ret_buf->sesSem); + mutex_init(&ret_buf->ses_lock); } return ret_buf; }