LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Roland Dreier <roland@love-shack.home.digitalvampire.org>
To: sfrench@us.ibm.com
Cc: linux-kernel@vger.kernel.org, jra@samba.org
Subject: [PATCH][CIFS] Convert new lock_sem to a mutex
Date: Sat, 02 Sep 2006 14:36:46 -0700	[thread overview]
Message-ID: <87zmdi54sx.fsf@love-shack.home.digitalvampire.org> (raw)

The recent change to "allow Windows blocking locks to be cancelled via
a CANCEL_LOCK call" introduced a new semaphore in struct cifsFileInfo,
lock_sem.  However, semaphores used as mutexes are deprecated these
days, and there's no reason to add a new one to the kernel.
Therefore, convert lock_sem to a struct mutex (and also fix one
indentation glitch on one of the lines changed anyway).

Compile tested only, since I don't use CIFS.

Signed-off-by: Roland Dreier <roland@digitalvampire.org>

---

diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index b24006c..5d7048a 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -306,7 +306,7 @@ struct cifsFileInfo {
 	/* lock scope id (0 if none) */
 	struct file * pfile; /* needed for writepage */
 	struct inode * pInode; /* needed for oplock break */
-	struct semaphore lock_sem;
+	struct mutex lock_mutex;
 	struct list_head llist; /* list of byte range locks we have. */
 	unsigned closePend:1;	/* file is marked to close */
 	unsigned invalidHandle:1;  /* file closed via session abend */
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 914239d..58042f5 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -267,7 +267,7 @@ cifs_create(struct inode *inode, struct 
 			pCifsFile->invalidHandle = FALSE;
 			pCifsFile->closePend     = FALSE;
 			init_MUTEX(&pCifsFile->fh_sem);
-			init_MUTEX(&pCifsFile->lock_sem);
+			mutex_init(&pCifsFile->lock_mutex);
 			INIT_LIST_HEAD(&pCifsFile->llist);
 			atomic_set(&pCifsFile->wrtPending,0);
 
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index e9c5ba9..e27f077 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -48,7 +48,7 @@ static inline struct cifsFileInfo *cifs_
 	private_data->netfid = netfid;
 	private_data->pid = current->tgid;	
 	init_MUTEX(&private_data->fh_sem);
-	init_MUTEX(&private_data->lock_sem);
+	mutex_init(&private_data->lock_mutex);
 	INIT_LIST_HEAD(&private_data->llist);
 	private_data->pfile = file; /* needed for writepage */
 	private_data->pInode = inode;
@@ -504,12 +504,12 @@ int cifs_close(struct inode *inode, stru
 
 		/* Delete any outstanding lock records.
 		   We'll lose them when the file is closed anyway. */
-		down(&pSMBFile->lock_sem);
+		mutex_lock(&pSMBFile->lock_mutex);
 		list_for_each_entry_safe(li, tmp, &pSMBFile->llist, llist) {
 			list_del(&li->llist);
 			kfree(li);
 		}
-		up(&pSMBFile->lock_sem);
+		mutex_unlock(&pSMBFile->lock_mutex);
 
 		write_lock(&GlobalSMBSeslock);
 		list_del(&pSMBFile->flist);
@@ -594,9 +594,9 @@ static int store_file_lock(struct cifsFi
 	li->offset = offset;
 	li->length = len;
 	li->type = lockType;
-	down(&fid->lock_sem);
+	mutex_lock(&fid->lock_mutex);
 	list_add(&li->llist, &fid->llist);
-	up(&fid->lock_sem);
+	mutex_unlock(&fid->lock_mutex);
 	return 0;
 }
 
@@ -752,7 +752,7 @@ int cifs_lock(struct file *file, int cmd
 			int stored_rc = 0;
 			struct cifsLockInfo *li, *tmp;
 
-			down(&fid->lock_sem);
+			mutex_lock(&fid->lock_mutex);
 			list_for_each_entry_safe(li, tmp, &fid->llist, llist) {
 				if (pfLock->fl_start <= li->offset &&
 						length >= li->length) {
@@ -766,7 +766,7 @@ int cifs_lock(struct file *file, int cmd
 					kfree(li);
 				}
 			}
-		up(&fid->lock_sem);
+			mutex_unlock(&fid->lock_mutex);
 		}
 	}
 

-- 
VGER BF report: H 2.74101e-05

             reply	other threads:[~2006-09-02 21:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-02 21:36 Roland Dreier [this message]
2007-01-15 16:43 ` Jan Engelhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zmdi54sx.fsf@love-shack.home.digitalvampire.org \
    --to=roland@love-shack.home.digitalvampire.org \
    --cc=jra@samba.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sfrench@us.ibm.com \
    --subject='Re: [PATCH][CIFS] Convert new lock_sem to a mutex' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).