* [PATCH] Btrfs: use down_read_nested to make lockdep silent
@ 2016-12-01 21:44 Liu Bo
2016-12-12 13:15 ` David Sterba
2016-12-13 23:58 ` [PATCH v2] " Liu Bo
0 siblings, 2 replies; 3+ messages in thread
From: Liu Bo @ 2016-12-01 21:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
If @block_group is not @used_bg, it'll try to get @used_bg's lock without
droping @block_group 's lock and lockdep has throwed a scary deadlock warning
about it.
Fix it by using down_read_nested.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
fs/btrfs/extent-tree.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 210c94a..cdb082a 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -7394,7 +7394,8 @@ btrfs_lock_cluster(struct btrfs_block_group_cache *block_group,
spin_unlock(&cluster->refill_lock);
- down_read(&used_bg->data_rwsem);
+ /* We should only have one-level nested. */
+ down_read_nested(&used_bg->data_rwsem, 1);
spin_lock(&cluster->refill_lock);
if (used_bg == cluster->block_group)
--
2.5.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Btrfs: use down_read_nested to make lockdep silent
2016-12-01 21:44 [PATCH] Btrfs: use down_read_nested to make lockdep silent Liu Bo
@ 2016-12-12 13:15 ` David Sterba
2016-12-13 23:58 ` [PATCH v2] " Liu Bo
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2016-12-12 13:15 UTC (permalink / raw)
To: Liu Bo; +Cc: linux-btrfs, David Sterba
On Thu, Dec 01, 2016 at 01:44:19PM -0800, Liu Bo wrote:
> If @block_group is not @used_bg, it'll try to get @used_bg's lock without
> droping @block_group 's lock and lockdep has throwed a scary deadlock warning
> about it.
> Fix it by using down_read_nested.
>
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
> ---
> fs/btrfs/extent-tree.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 210c94a..cdb082a 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -7394,7 +7394,8 @@ btrfs_lock_cluster(struct btrfs_block_group_cache *block_group,
>
> spin_unlock(&cluster->refill_lock);
>
> - down_read(&used_bg->data_rwsem);
> + /* We should only have one-level nested. */
> + down_read_nested(&used_bg->data_rwsem, 1);
While looking what down_read_nested does, I've found
SINGLE_DEPTH_NESTING, defined to 1. I'd rather use it instead of '1', as
it gives more more pointers to the docs.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] Btrfs: use down_read_nested to make lockdep silent
2016-12-01 21:44 [PATCH] Btrfs: use down_read_nested to make lockdep silent Liu Bo
2016-12-12 13:15 ` David Sterba
@ 2016-12-13 23:58 ` Liu Bo
1 sibling, 0 replies; 3+ messages in thread
From: Liu Bo @ 2016-12-13 23:58 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
If @block_group is not @used_bg, it'll try to get @used_bg's lock without
droping @block_group 's lock and lockdep has throwed a scary deadlock warning
about it.
Fix it by using down_read_nested.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
v2: Use 'SINGLE_DEPTH_NESTING' to avoid magic number.
fs/btrfs/extent-tree.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 4607af3..68e9d25 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -7397,7 +7397,8 @@ btrfs_lock_cluster(struct btrfs_block_group_cache *block_group,
spin_unlock(&cluster->refill_lock);
- down_read(&used_bg->data_rwsem);
+ /* We should only have one-level nested. */
+ down_read_nested(&used_bg->data_rwsem, SINGLE_DEPTH_NESTING);
spin_lock(&cluster->refill_lock);
if (used_bg == cluster->block_group)
--
2.5.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-12-13 23:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-01 21:44 [PATCH] Btrfs: use down_read_nested to make lockdep silent Liu Bo
2016-12-12 13:15 ` David Sterba
2016-12-13 23:58 ` [PATCH v2] " Liu Bo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).