diff options
author | Pavel Shilovsky <pshilovsky@samba.org> | 2013-07-11 03:17:45 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-21 21:21:21 -0400 |
commit | 059a1671f28c977fe69a0f86eeb0fa2084fdb3dd (patch) | |
tree | d3f051c00845f9d840bca3b1d6d98a637713e958 /fs | |
parent | cfe24e4e36ec19a56bac17691f8721ac44050a6f (diff) |
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>
Diffstat (limited to 'fs')
-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 48b29d24c9f4..c2934f8701da 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -553,11 +553,10 @@ cifs_relock_file(struct cifsFileInfo *cfile) | |||
553 | struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); | 553 | struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); |
554 | int rc = 0; | 554 | int rc = 0; |
555 | 555 | ||
556 | /* we are going to update can_cache_brlcks here - need a write access */ | 556 | down_read(&cinode->lock_sem); |
557 | down_write(&cinode->lock_sem); | ||
558 | if (cinode->can_cache_brlcks) { | 557 | if (cinode->can_cache_brlcks) { |
559 | /* can cache locks - no need to push them */ | 558 | /* can cache locks - no need to relock */ |
560 | up_write(&cinode->lock_sem); | 559 | up_read(&cinode->lock_sem); |
561 | return rc; | 560 | return rc; |
562 | } | 561 | } |
563 | 562 | ||
@@ -568,7 +567,7 @@ cifs_relock_file(struct cifsFileInfo *cfile) | |||
568 | else | 567 | else |
569 | rc = tcon->ses->server->ops->push_mand_locks(cfile); | 568 | rc = tcon->ses->server->ops->push_mand_locks(cfile); |
570 | 569 | ||
571 | up_write(&cinode->lock_sem); | 570 | up_read(&cinode->lock_sem); |
572 | return rc; | 571 | return rc; |
573 | } | 572 | } |
574 | 573 | ||