mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-04 02:02:28 +09:00
CIFS: Fix a deadlock when a file is reopened
commit 689c3db4d5 upstream.
If we request reading or writing on a file that needs to be
reopened, it causes the deadlock: we are already holding rw
semaphore for reading and then we try to acquire it for writing
in cifs_relock_file. Fix this by acquiring the semaphore for
reading in cifs_relock_file due to we don't make any changes in
locks and don't need a write access.
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Acked-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
cfe24e4e36
commit
059a1671f2
@@ -553,11 +553,10 @@ cifs_relock_file(struct cifsFileInfo *cfile)
|
||||
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
|
||||
int rc = 0;
|
||||
|
||||
/* we are going to update can_cache_brlcks here - need a write access */
|
||||
down_write(&cinode->lock_sem);
|
||||
down_read(&cinode->lock_sem);
|
||||
if (cinode->can_cache_brlcks) {
|
||||
/* can cache locks - no need to push them */
|
||||
up_write(&cinode->lock_sem);
|
||||
/* can cache locks - no need to relock */
|
||||
up_read(&cinode->lock_sem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -568,7 +567,7 @@ cifs_relock_file(struct cifsFileInfo *cfile)
|
||||
else
|
||||
rc = tcon->ses->server->ops->push_mand_locks(cfile);
|
||||
|
||||
up_write(&cinode->lock_sem);
|
||||
up_read(&cinode->lock_sem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user