All of lore.kernel.org
 help / color / mirror / Atom feed
* CIFS-related deadlock in 3.10-rc7
@ 2013-07-07 16:39 ` Alexander E. Patrakov
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander E. Patrakov @ 2013-07-07 16:39 UTC (permalink / raw)
  To: linux-cifs-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA

While playing a file from a CIFS-mounted samba share (over wireless,
if that matters), I got this deadlock:

[ 2164.132440] =============================================
[ 2164.132443] [ INFO: possible recursive locking detected ]
[ 2164.132446] 3.10.0-rc7-rafael+ #26 Tainted: G         C
[ 2164.132448] ---------------------------------------------
[ 2164.132452] vlc/2370 is trying to acquire lock:
[ 2164.132454]  (&cifsi->lock_sem){++++.+}, at: [<ffffffffa0913110>]
cifs_reopen_file+0x270/0x5b0 [cifs]
[ 2164.132472]
but task is already holding lock:
[ 2164.132475]  (&cifsi->lock_sem){++++.+}, at: [<ffffffffa0918ca8>]
cifs_strict_readv+0x88/0x160 [cifs]
[ 2164.132488]
other info that might help us debug this:
[ 2164.132491]  Possible unsafe locking scenario:

[ 2164.132494]        CPU0
[ 2164.132496]        ----
[ 2164.132498]   lock(&cifsi->lock_sem);
[ 2164.132502]   lock(&cifsi->lock_sem);
[ 2164.132505]
 *** DEADLOCK ***

[ 2164.132508]  May be due to missing lock nesting notation

[ 2164.132511] 1 lock held by vlc/2370:
[ 2164.132513]  #0:  (&cifsi->lock_sem){++++.+}, at:
[<ffffffffa0918ca8>] cifs_strict_readv+0x88/0x160 [cifs]
[ 2164.132526]
stack backtrace:
[ 2164.132531] CPU: 3 PID: 2370 Comm: vlc Tainted: G         C
3.10.0-rc7-rafael+ #26
[ 2164.132534] Hardware name: Sony Corporation VPCZ23A4R/VAIO, BIOS
R1013H5 05/21/2012
[ 2164.132537]  ffff880235033f80 ffff8802281fb958 ffffffff8165b7ae
ffff8802281fba48
[ 2164.132544]  ffffffff810a0042 ffff8802281fb978 ffffffff826360d0
ffff8802281fb9c8
[ 2164.132550]  0000000000000000 0000000000000000 00000000000389b0
ffff880200000542
[ 2164.132556] Call Trace:
[ 2164.132564]  [<ffffffff8165b7ae>] dump_stack+0x19/0x1b
[ 2164.132569]  [<ffffffff810a0042>] __lock_acquire+0x1522/0x1ee0
[ 2164.132579]  [<ffffffffa091aa41>] ? cifs_get_inode_info+0x181/0x690 [cifs]
[ 2164.132587]  [<ffffffffa0913110>] ? cifs_reopen_file+0x270/0x5b0 [cifs]
[ 2164.132591]  [<ffffffff810a1027>] lock_acquire+0x87/0x150
[ 2164.132598]  [<ffffffffa0913110>] ? cifs_reopen_file+0x270/0x5b0 [cifs]
[ 2164.132604]  [<ffffffff8165ed3f>] down_write+0x3f/0x70
[ 2164.132612]  [<ffffffffa0913110>] ? cifs_reopen_file+0x270/0x5b0 [cifs]
[ 2164.132622]  [<ffffffffa0927a76>] ? cifs_set_fid+0x26/0x40 [cifs]
[ 2164.132632]  [<ffffffffa0913110>] cifs_reopen_file+0x270/0x5b0 [cifs]
[ 2164.132642]  [<ffffffffa0913d0b>] cifs_readpage_worker+0x1ab/0x4e0 [cifs]
[ 2164.132652]  [<ffffffffa091427e>] cifs_readpage+0x5e/0x160 [cifs]
[ 2164.132660]  [<ffffffff81109b87>] generic_file_aio_read+0x217/0x760
[ 2164.132670]  [<ffffffffa0918d51>] cifs_strict_readv+0x131/0x160 [cifs]
[ 2164.132675]  [<ffffffff8116fff5>] do_sync_read+0x75/0xb0
[ 2164.132681]  [<ffffffff81170ef7>] vfs_read+0xa7/0x180
[ 2164.132686]  [<ffffffff81171170>] SyS_read+0x50/0xa0
[ 2164.132691]  [<ffffffff81668e16>] system_call_fastpath+0x1a/0x1f

-- 
Alexander E. Patrakov

^ permalink raw reply	[flat|nested] 8+ messages in thread

* CIFS-related deadlock in 3.10-rc7
@ 2013-07-07 16:39 ` Alexander E. Patrakov
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander E. Patrakov @ 2013-07-07 16:39 UTC (permalink / raw)
  To: linux-cifs, linux-kernel

While playing a file from a CIFS-mounted samba share (over wireless,
if that matters), I got this deadlock:

[ 2164.132440] =============================================
[ 2164.132443] [ INFO: possible recursive locking detected ]
[ 2164.132446] 3.10.0-rc7-rafael+ #26 Tainted: G         C
[ 2164.132448] ---------------------------------------------
[ 2164.132452] vlc/2370 is trying to acquire lock:
[ 2164.132454]  (&cifsi->lock_sem){++++.+}, at: [<ffffffffa0913110>]
cifs_reopen_file+0x270/0x5b0 [cifs]
[ 2164.132472]
but task is already holding lock:
[ 2164.132475]  (&cifsi->lock_sem){++++.+}, at: [<ffffffffa0918ca8>]
cifs_strict_readv+0x88/0x160 [cifs]
[ 2164.132488]
other info that might help us debug this:
[ 2164.132491]  Possible unsafe locking scenario:

[ 2164.132494]        CPU0
[ 2164.132496]        ----
[ 2164.132498]   lock(&cifsi->lock_sem);
[ 2164.132502]   lock(&cifsi->lock_sem);
[ 2164.132505]
 *** DEADLOCK ***

[ 2164.132508]  May be due to missing lock nesting notation

[ 2164.132511] 1 lock held by vlc/2370:
[ 2164.132513]  #0:  (&cifsi->lock_sem){++++.+}, at:
[<ffffffffa0918ca8>] cifs_strict_readv+0x88/0x160 [cifs]
[ 2164.132526]
stack backtrace:
[ 2164.132531] CPU: 3 PID: 2370 Comm: vlc Tainted: G         C
3.10.0-rc7-rafael+ #26
[ 2164.132534] Hardware name: Sony Corporation VPCZ23A4R/VAIO, BIOS
R1013H5 05/21/2012
[ 2164.132537]  ffff880235033f80 ffff8802281fb958 ffffffff8165b7ae
ffff8802281fba48
[ 2164.132544]  ffffffff810a0042 ffff8802281fb978 ffffffff826360d0
ffff8802281fb9c8
[ 2164.132550]  0000000000000000 0000000000000000 00000000000389b0
ffff880200000542
[ 2164.132556] Call Trace:
[ 2164.132564]  [<ffffffff8165b7ae>] dump_stack+0x19/0x1b
[ 2164.132569]  [<ffffffff810a0042>] __lock_acquire+0x1522/0x1ee0
[ 2164.132579]  [<ffffffffa091aa41>] ? cifs_get_inode_info+0x181/0x690 [cifs]
[ 2164.132587]  [<ffffffffa0913110>] ? cifs_reopen_file+0x270/0x5b0 [cifs]
[ 2164.132591]  [<ffffffff810a1027>] lock_acquire+0x87/0x150
[ 2164.132598]  [<ffffffffa0913110>] ? cifs_reopen_file+0x270/0x5b0 [cifs]
[ 2164.132604]  [<ffffffff8165ed3f>] down_write+0x3f/0x70
[ 2164.132612]  [<ffffffffa0913110>] ? cifs_reopen_file+0x270/0x5b0 [cifs]
[ 2164.132622]  [<ffffffffa0927a76>] ? cifs_set_fid+0x26/0x40 [cifs]
[ 2164.132632]  [<ffffffffa0913110>] cifs_reopen_file+0x270/0x5b0 [cifs]
[ 2164.132642]  [<ffffffffa0913d0b>] cifs_readpage_worker+0x1ab/0x4e0 [cifs]
[ 2164.132652]  [<ffffffffa091427e>] cifs_readpage+0x5e/0x160 [cifs]
[ 2164.132660]  [<ffffffff81109b87>] generic_file_aio_read+0x217/0x760
[ 2164.132670]  [<ffffffffa0918d51>] cifs_strict_readv+0x131/0x160 [cifs]
[ 2164.132675]  [<ffffffff8116fff5>] do_sync_read+0x75/0xb0
[ 2164.132681]  [<ffffffff81170ef7>] vfs_read+0xa7/0x180
[ 2164.132686]  [<ffffffff81171170>] SyS_read+0x50/0xa0
[ 2164.132691]  [<ffffffff81668e16>] system_call_fastpath+0x1a/0x1f

-- 
Alexander E. Patrakov

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CIFS-related deadlock in 3.10-rc7
  2013-07-07 16:39 ` Alexander E. Patrakov
  (?)
@ 2013-07-11 12:53 ` Pavel Shilovsky
       [not found]   ` <CAKywueQXGN+W6eMyZ-eQD+pCpgRz86Dpxht+YiMVKAGXVebPFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2013-07-11 14:35   ` CIFS-related deadlock in 3.10-rc7 Steve French
  -1 siblings, 2 replies; 8+ messages in thread
From: Pavel Shilovsky @ 2013-07-11 12:53 UTC (permalink / raw)
  To: Alexander E. Patrakov; +Cc: linux-cifs, linux-kernel

2013/7/7 Alexander E. Patrakov <patrakov@gmail.com>:
> While playing a file from a CIFS-mounted samba share (over wireless,
> if that matters), I got this deadlock:
>
> [ 2164.132440] =============================================
> [ 2164.132443] [ INFO: possible recursive locking detected ]
> [ 2164.132446] 3.10.0-rc7-rafael+ #26 Tainted: G         C
> [ 2164.132448] ---------------------------------------------
> [ 2164.132452] vlc/2370 is trying to acquire lock:
> [ 2164.132454]  (&cifsi->lock_sem){++++.+}, at: [<ffffffffa0913110>]
> cifs_reopen_file+0x270/0x5b0 [cifs]
> [ 2164.132472]
> but task is already holding lock:
> [ 2164.132475]  (&cifsi->lock_sem){++++.+}, at: [<ffffffffa0918ca8>]
> cifs_strict_readv+0x88/0x160 [cifs]
> [ 2164.132488]
> other info that might help us debug this:
> [ 2164.132491]  Possible unsafe locking scenario:
>
> [ 2164.132494]        CPU0
> [ 2164.132496]        ----
> [ 2164.132498]   lock(&cifsi->lock_sem);
> [ 2164.132502]   lock(&cifsi->lock_sem);
> [ 2164.132505]
>  *** DEADLOCK ***
>
> [ 2164.132508]  May be due to missing lock nesting notation
>
> [ 2164.132511] 1 lock held by vlc/2370:
> [ 2164.132513]  #0:  (&cifsi->lock_sem){++++.+}, at:
> [<ffffffffa0918ca8>] cifs_strict_readv+0x88/0x160 [cifs]
> [ 2164.132526]
> stack backtrace:
> [ 2164.132531] CPU: 3 PID: 2370 Comm: vlc Tainted: G         C
> 3.10.0-rc7-rafael+ #26
> [ 2164.132534] Hardware name: Sony Corporation VPCZ23A4R/VAIO, BIOS
> R1013H5 05/21/2012
> [ 2164.132537]  ffff880235033f80 ffff8802281fb958 ffffffff8165b7ae
> ffff8802281fba48
> [ 2164.132544]  ffffffff810a0042 ffff8802281fb978 ffffffff826360d0
> ffff8802281fb9c8
> [ 2164.132550]  0000000000000000 0000000000000000 00000000000389b0
> ffff880200000542
> [ 2164.132556] Call Trace:
> [ 2164.132564]  [<ffffffff8165b7ae>] dump_stack+0x19/0x1b
> [ 2164.132569]  [<ffffffff810a0042>] __lock_acquire+0x1522/0x1ee0
> [ 2164.132579]  [<ffffffffa091aa41>] ? cifs_get_inode_info+0x181/0x690 [cifs]
> [ 2164.132587]  [<ffffffffa0913110>] ? cifs_reopen_file+0x270/0x5b0 [cifs]
> [ 2164.132591]  [<ffffffff810a1027>] lock_acquire+0x87/0x150
> [ 2164.132598]  [<ffffffffa0913110>] ? cifs_reopen_file+0x270/0x5b0 [cifs]
> [ 2164.132604]  [<ffffffff8165ed3f>] down_write+0x3f/0x70
> [ 2164.132612]  [<ffffffffa0913110>] ? cifs_reopen_file+0x270/0x5b0 [cifs]
> [ 2164.132622]  [<ffffffffa0927a76>] ? cifs_set_fid+0x26/0x40 [cifs]
> [ 2164.132632]  [<ffffffffa0913110>] cifs_reopen_file+0x270/0x5b0 [cifs]
> [ 2164.132642]  [<ffffffffa0913d0b>] cifs_readpage_worker+0x1ab/0x4e0 [cifs]
> [ 2164.132652]  [<ffffffffa091427e>] cifs_readpage+0x5e/0x160 [cifs]
> [ 2164.132660]  [<ffffffff81109b87>] generic_file_aio_read+0x217/0x760
> [ 2164.132670]  [<ffffffffa0918d51>] cifs_strict_readv+0x131/0x160 [cifs]
> [ 2164.132675]  [<ffffffff8116fff5>] do_sync_read+0x75/0xb0
> [ 2164.132681]  [<ffffffff81170ef7>] vfs_read+0xa7/0x180
> [ 2164.132686]  [<ffffffff81171170>] SyS_read+0x50/0xa0
> [ 2164.132691]  [<ffffffff81668e16>] system_call_fastpath+0x1a/0x1f
>
> --
> Alexander E. Patrakov
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Thank you for pointing it out. I created a patch that should fix the
problem - will sent separately.

--
Best regards,
Pavel Shilovsky.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] CIFS: Fix a deadlock when a file is reopened
       [not found]   ` <CAKywueQXGN+W6eMyZ-eQD+pCpgRz86Dpxht+YiMVKAGXVebPFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-07-11 12:54     ` Pavel Shilovsky
       [not found]       ` <1373547244-5048-1-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Pavel Shilovsky @ 2013-07-11 12:54 UTC (permalink / raw)
  To: linux-cifs-u79uwXL29TY76Z2rM5mHXA

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-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
---
 fs/cifs/file.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index b149ae4..be24f09 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -561,11 +561,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;
 	}
 
@@ -576,7 +575,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;
 }
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: CIFS-related deadlock in 3.10-rc7
  2013-07-11 12:53 ` Pavel Shilovsky
       [not found]   ` <CAKywueQXGN+W6eMyZ-eQD+pCpgRz86Dpxht+YiMVKAGXVebPFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-07-11 14:35   ` Steve French
  2013-07-11 18:08       ` Pavel Shilovsky
  1 sibling, 1 reply; 8+ messages in thread
From: Steve French @ 2013-07-11 14:35 UTC (permalink / raw)
  To: Pavel Shilovsky; +Cc: Alexander E. Patrakov, linux-cifs, linux-kernel

Wouldn't this be a candidate for stable?

On Thu, Jul 11, 2013 at 7:53 AM, Pavel Shilovsky <piastryyy@gmail.com> wrote:
> 2013/7/7 Alexander E. Patrakov <patrakov@gmail.com>:
>> While playing a file from a CIFS-mounted samba share (over wireless,
>> if that matters), I got this deadlock:
>>
>> [ 2164.132440] =============================================
>> [ 2164.132443] [ INFO: possible recursive locking detected ]
>> [ 2164.132446] 3.10.0-rc7-rafael+ #26 Tainted: G         C
>> [ 2164.132448] ---------------------------------------------
>> [ 2164.132452] vlc/2370 is trying to acquire lock:
>> [ 2164.132454]  (&cifsi->lock_sem){++++.+}, at: [<ffffffffa0913110>]
>> cifs_reopen_file+0x270/0x5b0 [cifs]
>> [ 2164.132472]
>> but task is already holding lock:
>> [ 2164.132475]  (&cifsi->lock_sem){++++.+}, at: [<ffffffffa0918ca8>]
>> cifs_strict_readv+0x88/0x160 [cifs]
>> [ 2164.132488]
>> other info that might help us debug this:
>> [ 2164.132491]  Possible unsafe locking scenario:
>>
>> [ 2164.132494]        CPU0
>> [ 2164.132496]        ----
>> [ 2164.132498]   lock(&cifsi->lock_sem);
>> [ 2164.132502]   lock(&cifsi->lock_sem);
>> [ 2164.132505]
>>  *** DEADLOCK ***
>>
>> [ 2164.132508]  May be due to missing lock nesting notation
>>
>> [ 2164.132511] 1 lock held by vlc/2370:
>> [ 2164.132513]  #0:  (&cifsi->lock_sem){++++.+}, at:
>> [<ffffffffa0918ca8>] cifs_strict_readv+0x88/0x160 [cifs]
>> [ 2164.132526]
>> stack backtrace:
>> [ 2164.132531] CPU: 3 PID: 2370 Comm: vlc Tainted: G         C
>> 3.10.0-rc7-rafael+ #26
>> [ 2164.132534] Hardware name: Sony Corporation VPCZ23A4R/VAIO, BIOS
>> R1013H5 05/21/2012
>> [ 2164.132537]  ffff880235033f80 ffff8802281fb958 ffffffff8165b7ae
>> ffff8802281fba48
>> [ 2164.132544]  ffffffff810a0042 ffff8802281fb978 ffffffff826360d0
>> ffff8802281fb9c8
>> [ 2164.132550]  0000000000000000 0000000000000000 00000000000389b0
>> ffff880200000542
>> [ 2164.132556] Call Trace:
>> [ 2164.132564]  [<ffffffff8165b7ae>] dump_stack+0x19/0x1b
>> [ 2164.132569]  [<ffffffff810a0042>] __lock_acquire+0x1522/0x1ee0
>> [ 2164.132579]  [<ffffffffa091aa41>] ? cifs_get_inode_info+0x181/0x690 [cifs]
>> [ 2164.132587]  [<ffffffffa0913110>] ? cifs_reopen_file+0x270/0x5b0 [cifs]
>> [ 2164.132591]  [<ffffffff810a1027>] lock_acquire+0x87/0x150
>> [ 2164.132598]  [<ffffffffa0913110>] ? cifs_reopen_file+0x270/0x5b0 [cifs]
>> [ 2164.132604]  [<ffffffff8165ed3f>] down_write+0x3f/0x70
>> [ 2164.132612]  [<ffffffffa0913110>] ? cifs_reopen_file+0x270/0x5b0 [cifs]
>> [ 2164.132622]  [<ffffffffa0927a76>] ? cifs_set_fid+0x26/0x40 [cifs]
>> [ 2164.132632]  [<ffffffffa0913110>] cifs_reopen_file+0x270/0x5b0 [cifs]
>> [ 2164.132642]  [<ffffffffa0913d0b>] cifs_readpage_worker+0x1ab/0x4e0 [cifs]
>> [ 2164.132652]  [<ffffffffa091427e>] cifs_readpage+0x5e/0x160 [cifs]
>> [ 2164.132660]  [<ffffffff81109b87>] generic_file_aio_read+0x217/0x760
>> [ 2164.132670]  [<ffffffffa0918d51>] cifs_strict_readv+0x131/0x160 [cifs]
>> [ 2164.132675]  [<ffffffff8116fff5>] do_sync_read+0x75/0xb0
>> [ 2164.132681]  [<ffffffff81170ef7>] vfs_read+0xa7/0x180
>> [ 2164.132686]  [<ffffffff81171170>] SyS_read+0x50/0xa0
>> [ 2164.132691]  [<ffffffff81668e16>] system_call_fastpath+0x1a/0x1f
>>
>> --
>> Alexander E. Patrakov
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> Thank you for pointing it out. I created a patch that should fix the
> problem - will sent separately.
>
> --
> Best regards,
> Pavel Shilovsky.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] CIFS: Fix a deadlock when a file is reopened
       [not found]       ` <1373547244-5048-1-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
@ 2013-07-11 15:02         ` Jeff Layton
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Layton @ 2013-07-11 15:02 UTC (permalink / raw)
  To: Pavel Shilovsky; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA

On Thu, 11 Jul 2013 16:54:04 +0400
Pavel Shilovsky <pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org> wrote:

> 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-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
> ---
>  fs/cifs/file.c |    9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> index b149ae4..be24f09 100644
> --- a/fs/cifs/file.c
> +++ b/fs/cifs/file.c
> @@ -561,11 +561,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;
>  	}
>  
> @@ -576,7 +575,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;
>  }
>  

Ok, I think this will work, but I'm a little leery of recursively
taking the same semaphore twice for read. This really could use a
rethink as getting this locking wrong is a great source of subtle bugs.

Maybe you could consider using RCU instead?

Acked-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CIFS-related deadlock in 3.10-rc7
  2013-07-11 14:35   ` CIFS-related deadlock in 3.10-rc7 Steve French
@ 2013-07-11 18:08       ` Pavel Shilovsky
  0 siblings, 0 replies; 8+ messages in thread
From: Pavel Shilovsky @ 2013-07-11 18:08 UTC (permalink / raw)
  To: Steve French
  Cc: Alexander E. Patrakov, linux-cifs, linux-kernel-u79uwXL29TY76Z2rM5mHXA

2013/7/11 Steve French <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> Wouldn't this be a candidate for stable?

 Yes, I think it should go to stable as well as "[PATCH 1/8] CIFS: Fix
lease context buffer parsing" patch.

--
Best regards,
Pavel Shilovsky.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CIFS-related deadlock in 3.10-rc7
@ 2013-07-11 18:08       ` Pavel Shilovsky
  0 siblings, 0 replies; 8+ messages in thread
From: Pavel Shilovsky @ 2013-07-11 18:08 UTC (permalink / raw)
  To: Steve French; +Cc: Alexander E. Patrakov, linux-cifs, linux-kernel

2013/7/11 Steve French <smfrench@gmail.com>:
> Wouldn't this be a candidate for stable?

 Yes, I think it should go to stable as well as "[PATCH 1/8] CIFS: Fix
lease context buffer parsing" patch.

--
Best regards,
Pavel Shilovsky.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-07-11 18:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-07 16:39 CIFS-related deadlock in 3.10-rc7 Alexander E. Patrakov
2013-07-07 16:39 ` Alexander E. Patrakov
2013-07-11 12:53 ` Pavel Shilovsky
     [not found]   ` <CAKywueQXGN+W6eMyZ-eQD+pCpgRz86Dpxht+YiMVKAGXVebPFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-07-11 12:54     ` [PATCH] CIFS: Fix a deadlock when a file is reopened Pavel Shilovsky
     [not found]       ` <1373547244-5048-1-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2013-07-11 15:02         ` Jeff Layton
2013-07-11 14:35   ` CIFS-related deadlock in 3.10-rc7 Steve French
2013-07-11 18:08     ` Pavel Shilovsky
2013-07-11 18:08       ` Pavel Shilovsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.