diff options
author | Pavel Shilovsky <pshilovsky@samba.org> | 2013-07-11 11:17:45 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-21 04:16:06 +0400 |
commit | 900b565e72018dfa7f4c95dacdb3a3b5a0e4174e (patch) | |
tree | 377e88b20a5da1c8a6f85ff8b5e7f51b2dc21a05 | |
parent | 44d244a13a27f0eb7b33bb152aa173c0e875df76 (diff) | |
download | linux-900b565e72018dfa7f4c95dacdb3a3b5a0e4174e.tar.xz |
CIFS: Fix a deadlock when a file is reopened
commit 689c3db4d57a73bee6c5ad7797fce7b54d32a87c 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>
-rw-r--r-- | fs/cifs/file.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 7a0dd99e4507..eb330917ed4a 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -557,11 +557,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; } @@ -572,7 +571,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; } |