[PATCH 12/16] cifs-use-mutex.diff

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linux Kernel Mailing List <linux-kernel@...>
Cc: Roland Dreier <roland@...>, Andrew Morton <akpm@...>
Date: Sunday, April 1, 2007 - 2:16 pm

Verbatim copy of original mail:

*>>>

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>
*<<<


My 2¢:
Compile tested. Runtime tested. Did not break.

From: Roland Dreier <roland@digitalvampire.org>
Signed-off-by: Jan Engelhardt <jengelh@gmx.de>
Cc: Roland Dreier <roland@digitalvampire.org>

 cifsglob.h |    2 +-
 dir.c      |    2 +-
 file.c     |   14 +++++++-------
 3 files changed, 9 insertions(+), 9 deletions(-)

Index: linux-2.6.21-rc5/fs/cifs/cifsglob.h
===================================================================
--- linux-2.6.21-rc5.orig/fs/cifs/cifsglob.h
+++ linux-2.6.21-rc5/fs/cifs/cifsglob.h
@@ -311,7 +311,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 */
Index: linux-2.6.21-rc5/fs/cifs/dir.c
===================================================================
--- linux-2.6.21-rc5.orig/fs/cifs/dir.c
+++ linux-2.6.21-rc5/fs/cifs/dir.c
@@ -274,7 +274,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);
 
Index: linux-2.6.21-rc5/fs/cifs/file.c
===================================================================
--- linux-2.6.21-rc5.orig/fs/cifs/file.c
+++ linux-2.6.21-rc5/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;
@@ -508,12 +508,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);
@@ -598,9 +598,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;
 }
 
@@ -757,7 +757,7 @@ int cifs_lock(struct file *file, int cmd
 			struct cifsLockInfo *li, *tmp;
 
 			rc = 0;
-			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) {
@@ -771,7 +771,7 @@ int cifs_lock(struct file *file, int cmd
 					kfree(li);
 				}
 			}
-			up(&fid->lock_sem);
+			mutex_unlock(&fid->lock_mutex);
 		}
 	}
 
#<EOF>
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/16] Assorted patches, Jan Engelhardt, (Sun Apr 1, 2:13 pm)
[PATCH 16/16] warn-on-kthread-name-truncation.diff, Jan Engelhardt, (Sun Apr 1, 2:18 pm)
Re: [PATCH 16/16] warn-on-kthread-name-truncation.diff, Andrew Morton, (Mon Apr 2, 2:00 am)
Re: [PATCH 16/16] warn-on-kthread-name-truncation.diff, Jan Engelhardt, (Mon Apr 2, 2:51 am)
[PATCH 15/16] use-regular-eth-suffix.diff, Jan Engelhardt, (Sun Apr 1, 2:18 pm)
Re: [PATCH 15/16] use-regular-eth-suffix.diff, Kyle Moffett, (Sun Apr 1, 2:42 pm)
Re: [PATCH 15/16] use-regular-eth-suffix.diff, Jouni Malinen, (Sun Apr 1, 9:40 pm)
[PATCH 14/16] kconfig-allow-override.diff, Jan Engelhardt, (Sun Apr 1, 2:17 pm)
Re: [PATCH 14/16] kconfig-allow-override.diff, Sam Ravnborg, (Sun Apr 1, 2:44 pm)
Re: [PATCH 14/16] kconfig-allow-override.diff, Randy Dunlap, (Sun Apr 1, 3:09 pm)
[PATCH 13/16] show-pipesize-in-stat.diff, Jan Engelhardt, (Sun Apr 1, 2:17 pm)
Re: [PATCH 13/16] show-pipesize-in-stat.diff, Eric Dumazet, (Mon Apr 2, 6:41 am)
Re: [PATCH 13/16] show-pipesize-in-stat.diff, Jan Engelhardt, (Tue Apr 3, 8:48 pm)
Re: [PATCH 13/16] show-pipesize-in-stat.diff, Eric Dumazet, (Wed Apr 4, 1:03 am)
Re: [PATCH 13/16] show-pipesize-in-stat.diff, Jan Engelhardt, (Tue Apr 17, 4:05 am)
Re: [PATCH 13/16] show-pipesize-in-stat.diff, Andrew Morton, (Mon Apr 2, 1:58 am)
Re: [PATCH 13/16] show-pipesize-in-stat.diff, Jan Engelhardt, (Mon Apr 2, 2:48 am)
[PATCH 12/16] cifs-use-mutex.diff, Jan Engelhardt, (Sun Apr 1, 2:16 pm)
Re: [PATCH 12/16] cifs-use-mutex.diff, Roland Dreier, (Mon Apr 2, 1:36 am)
[PATCH 11/16] samba-eintr-fix.diff, Jan Engelhardt, (Sun Apr 1, 2:16 pm)
Re: [PATCH 11/16] samba-eintr-fix.diff, Andrew Morton, (Mon Apr 2, 1:53 am)
Re: [PATCH 11/16] samba-eintr-fix.diff, Dave Jones, (Sun Apr 1, 3:09 pm)
Re: [PATCH 11/16] samba-eintr-fix.diff, Jan Engelhardt, (Sun Apr 1, 3:28 pm)
Re: [PATCH 11/16] samba-eintr-fix.diff, Dave Jones, (Sun Apr 1, 3:42 pm)
[PATCH 10/16] show-partitions-on-mount-error.diff, Jan Engelhardt, (Sun Apr 1, 2:15 pm)
Re: [PATCH 10/16] show-partitions-on-mount-error.diff, Pavel Machek, (Mon Apr 2, 2:59 pm)
Re: [PATCH 10/16] show-partitions-on-mount-error.diff, Jan Engelhardt, (Tue Apr 3, 8:42 pm)
Re: [PATCH 10/16] show-partitions-on-mount-error.diff, Andrew Morton, (Mon Apr 2, 1:48 am)
Re: [PATCH 10/16] show partitions on mount error, Jan Engelhardt, (Mon Apr 2, 3:01 am)
Re: [PATCH 10/16] show-partitions-on-mount-error.diff, Andrew Morton, (Mon Apr 2, 1:47 am)
[PATCH 09/16] zlib-decompression-status.diff, Jan Engelhardt, (Sun Apr 1, 2:15 pm)
Re: [PATCH 09/16] zlib-decompression-status.diff, Jan Engelhardt, (Mon Apr 2, 2:50 pm)
[PATCH 08/16] console-printk-level.diff, Jan Engelhardt, (Sun Apr 1, 2:15 pm)
Re: [PATCH 08/16] console-printk-level.diff, Randy Dunlap, (Sun Apr 1, 3:07 pm)
[PATCH 07/16] kconfig-dynamic-frequency.diff, Jan Engelhardt, (Sun Apr 1, 2:15 pm)
Re: [PATCH 07/16] kconfig-dynamic-frequency.diff, Kyle Moffett, (Sun Apr 1, 2:39 pm)
Re: [PATCH 07/16] kconfig-dynamic-frequency.diff, Jan Engelhardt, (Sun Apr 1, 2:42 pm)
Re: [PATCH 07/16] kconfig-dynamic-frequency.diff, Kyle Moffett, (Sun Apr 1, 2:52 pm)
Re: [PATCH 07/16] kconfig-dynamic-frequency.diff, Robert P. J. Day, (Sun Apr 1, 4:22 pm)
Re: [PATCH 07/16] kconfig-dynamic-frequency.diff, Jan Engelhardt, (Sun Apr 1, 3:01 pm)
[PATCH], Kyle Moffett, (Sun Apr 1, 3:42 pm)
Re: [PATCH], Jan Engelhardt, (Sun Apr 1, 3:47 pm)
Re: [PATCH], Kyle Moffett, (Sun Apr 1, 4:07 pm)
Re: [PATCH], Andi Kleen, (Sun Apr 1, 7:03 pm)
[PATCH 06/16] isofs-add-write-bit.diff, Jan Engelhardt, (Sun Apr 1, 2:15 pm)
[PATCH 5/16] fix-kthread-niceness.diff, Jan Engelhardt, (Sun Apr 1, 2:14 pm)
Re: [PATCH 5/16] fix-kthread-niceness.diff, Andrew Morton, (Mon Apr 2, 1:39 am)
[PATCH 4/16] vt-printk-color.diff, Jan Engelhardt, (Sun Apr 1, 2:14 pm)
[PATCH 3/16] vt-underline-color.diff, Jan Engelhardt, (Sun Apr 1, 2:14 pm)
Re: [PATCH 3/16] vt-underline-color.diff, Andrew Morton, (Mon Apr 2, 1:37 am)
Re: [PATCH 3/16] vt-underline-color.diff, Antonino A. Daplas, (Mon Apr 2, 2:57 am)
[PATCH 2/16] vt-pure-colors.diff, Jan Engelhardt, (Sun Apr 1, 2:14 pm)
Re: [PATCH 2/16] vt-pure-colors.diff, James Bruce, (Sun Apr 1, 2:39 pm)
Re: [PATCH 2/16] vt-pure-colors.diff, Antonino A. Daplas, (Mon Apr 2, 2:49 am)
Re: [PATCH 2/16] vt-pure-colors.diff, Jan Engelhardt, (Mon Apr 2, 3:04 am)
Re: [PATCH 2/16] vt-pure-colors.diff, Antonino A. Daplas, (Mon Apr 2, 3:50 am)
Re: [PATCH 2/16] vt-pure-colors.diff, Jan Engelhardt, (Mon Apr 2, 4:01 am)
[PATCH 1/16] vt-sysfs-for-colors.diff, Jan Engelhardt, (Sun Apr 1, 2:13 pm)
Re: [PATCH 1/16] vt-sysfs-for-colors.diff, Antonino A. Daplas, (Mon Apr 2, 2:49 am)
[PATCH 17/16] Do not reset UTF8 on terminal reset, Jan Engelhardt, (Mon Apr 2, 3:31 am)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Pavel Machek, (Mon Apr 2, 2:50 pm)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Paul LeoNerd Evans, (Mon Apr 2, 7:26 am)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Antonino A. Daplas, (Mon Apr 2, 7:44 am)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Paul LeoNerd Evans, (Mon Apr 2, 7:54 am)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Antonino A. Daplas, (Mon Apr 2, 8:47 am)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Jan Engelhardt, (Mon Apr 2, 9:34 am)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Paul LeoNerd Evans, (Mon Apr 2, 9:20 am)
Re: [PATCH 17/16] Do not reset UTF8 on terminal reset, Antonino A. Daplas, (Mon Apr 2, 5:30 am)