提交 796e5661 编写于 作者: R Roland Dreier 提交者: Steve French

[CIFS] Change semaphore to mutex for cifs lock_sem

Originally at http://lkml.org/lkml/2006/9/2/86

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).
Signed-off-by: NRoland Dreier <roland@digitalvampire.org>
Signed-off-by: NJan Engelhardt <jengelh@gmx.de>
Signed-off-by: NSteve French <sfrench@us.ibm.com>
上级 0b2365f8
...@@ -311,7 +311,7 @@ struct cifsFileInfo { ...@@ -311,7 +311,7 @@ struct cifsFileInfo {
/* lock scope id (0 if none) */ /* lock scope id (0 if none) */
struct file * pfile; /* needed for writepage */ struct file * pfile; /* needed for writepage */
struct inode * pInode; /* needed for oplock break */ 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. */ struct list_head llist; /* list of byte range locks we have. */
unsigned closePend:1; /* file is marked to close */ unsigned closePend:1; /* file is marked to close */
unsigned invalidHandle:1; /* file closed via session abend */ unsigned invalidHandle:1; /* file closed via session abend */
......
...@@ -274,7 +274,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, ...@@ -274,7 +274,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
pCifsFile->invalidHandle = FALSE; pCifsFile->invalidHandle = FALSE;
pCifsFile->closePend = FALSE; pCifsFile->closePend = FALSE;
init_MUTEX(&pCifsFile->fh_sem); init_MUTEX(&pCifsFile->fh_sem);
init_MUTEX(&pCifsFile->lock_sem); mutex_init(&pCifsFile->lock_mutex);
INIT_LIST_HEAD(&pCifsFile->llist); INIT_LIST_HEAD(&pCifsFile->llist);
atomic_set(&pCifsFile->wrtPending,0); atomic_set(&pCifsFile->wrtPending,0);
......
...@@ -48,7 +48,7 @@ static inline struct cifsFileInfo *cifs_init_private( ...@@ -48,7 +48,7 @@ static inline struct cifsFileInfo *cifs_init_private(
private_data->netfid = netfid; private_data->netfid = netfid;
private_data->pid = current->tgid; private_data->pid = current->tgid;
init_MUTEX(&private_data->fh_sem); init_MUTEX(&private_data->fh_sem);
init_MUTEX(&private_data->lock_sem); mutex_init(&private_data->lock_mutex);
INIT_LIST_HEAD(&private_data->llist); INIT_LIST_HEAD(&private_data->llist);
private_data->pfile = file; /* needed for writepage */ private_data->pfile = file; /* needed for writepage */
private_data->pInode = inode; private_data->pInode = inode;
...@@ -511,12 +511,12 @@ int cifs_close(struct inode *inode, struct file *file) ...@@ -511,12 +511,12 @@ int cifs_close(struct inode *inode, struct file *file)
/* Delete any outstanding lock records. /* Delete any outstanding lock records.
We'll lose them when the file is closed anyway. */ 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_for_each_entry_safe(li, tmp, &pSMBFile->llist, llist) {
list_del(&li->llist); list_del(&li->llist);
kfree(li); kfree(li);
} }
up(&pSMBFile->lock_sem); mutex_unlock(&pSMBFile->lock_mutex);
write_lock(&GlobalSMBSeslock); write_lock(&GlobalSMBSeslock);
list_del(&pSMBFile->flist); list_del(&pSMBFile->flist);
...@@ -601,9 +601,9 @@ static int store_file_lock(struct cifsFileInfo *fid, __u64 len, ...@@ -601,9 +601,9 @@ static int store_file_lock(struct cifsFileInfo *fid, __u64 len,
li->offset = offset; li->offset = offset;
li->length = len; li->length = len;
li->type = lockType; li->type = lockType;
down(&fid->lock_sem); mutex_lock(&fid->lock_mutex);
list_add(&li->llist, &fid->llist); list_add(&li->llist, &fid->llist);
up(&fid->lock_sem); mutex_unlock(&fid->lock_mutex);
return 0; return 0;
} }
...@@ -760,7 +760,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -760,7 +760,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
struct cifsLockInfo *li, *tmp; struct cifsLockInfo *li, *tmp;
rc = 0; rc = 0;
down(&fid->lock_sem); mutex_lock(&fid->lock_mutex);
list_for_each_entry_safe(li, tmp, &fid->llist, llist) { list_for_each_entry_safe(li, tmp, &fid->llist, llist) {
if (pfLock->fl_start <= li->offset && if (pfLock->fl_start <= li->offset &&
length >= li->length) { length >= li->length) {
...@@ -774,7 +774,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -774,7 +774,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
kfree(li); kfree(li);
} }
} }
up(&fid->lock_sem); mutex_unlock(&fid->lock_mutex);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册