* [PATCH] btrfs: Fix bio leak
@ 2017-12-13 11:50 Nikolay Borisov
2017-12-13 17:00 ` Liu Bo
2017-12-14 15:16 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: Nikolay Borisov @ 2017-12-13 11:50 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
Commit e0ae99941423 ("btrfs: preallocate device flush bio") reworked
the way the flush bio is allocated and used. Concretely it allocates
the bio in __alloc_device and then re-uses it multiple times with a
very simple endio routine that just calls complete() without consuming
a reference. Allocated bios by default come with a ref count of 1,
which is then consumed by the endio routine (or not, in which case they
should be bio_put by the caller). The way the impleementation works now
is that the flush bio has a refcount of 2 and we only ever bio_put it
once, leaving it to hang indefinitely. Fix this by removing the extra
bio_get in __alloc_device.
Fixes: e0ae99941423 ("btrfs: preallocate device flush bio")
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/volumes.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 132966950f5f..3690822d469a 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -312,7 +312,6 @@ static struct btrfs_device *__alloc_device(void)
kfree(dev);
return ERR_PTR(-ENOMEM);
}
- bio_get(dev->flush_bio);
INIT_LIST_HEAD(&dev->dev_list);
INIT_LIST_HEAD(&dev->dev_alloc_list);
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: Fix bio leak
2017-12-13 11:50 [PATCH] btrfs: Fix bio leak Nikolay Borisov
@ 2017-12-13 17:00 ` Liu Bo
2017-12-14 15:16 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Liu Bo @ 2017-12-13 17:00 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-btrfs
On Wed, Dec 13, 2017 at 01:50:07PM +0200, Nikolay Borisov wrote:
> Commit e0ae99941423 ("btrfs: preallocate device flush bio") reworked
> the way the flush bio is allocated and used. Concretely it allocates
> the bio in __alloc_device and then re-uses it multiple times with a
> very simple endio routine that just calls complete() without consuming
> a reference. Allocated bios by default come with a ref count of 1,
> which is then consumed by the endio routine (or not, in which case they
> should be bio_put by the caller). The way the impleementation works now
> is that the flush bio has a refcount of 2 and we only ever bio_put it
> once, leaving it to hang indefinitely. Fix this by removing the extra
> bio_get in __alloc_device.
>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Thanks,
-liubo
> Fixes: e0ae99941423 ("btrfs: preallocate device flush bio")
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
> fs/btrfs/volumes.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 132966950f5f..3690822d469a 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -312,7 +312,6 @@ static struct btrfs_device *__alloc_device(void)
> kfree(dev);
> return ERR_PTR(-ENOMEM);
> }
> - bio_get(dev->flush_bio);
>
> INIT_LIST_HEAD(&dev->dev_list);
> INIT_LIST_HEAD(&dev->dev_alloc_list);
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: Fix bio leak
2017-12-13 11:50 [PATCH] btrfs: Fix bio leak Nikolay Borisov
2017-12-13 17:00 ` Liu Bo
@ 2017-12-14 15:16 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2017-12-14 15:16 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-btrfs
On Wed, Dec 13, 2017 at 01:50:07PM +0200, Nikolay Borisov wrote:
> Commit e0ae99941423 ("btrfs: preallocate device flush bio") reworked
> the way the flush bio is allocated and used. Concretely it allocates
> the bio in __alloc_device and then re-uses it multiple times with a
> very simple endio routine that just calls complete() without consuming
> a reference. Allocated bios by default come with a ref count of 1,
> which is then consumed by the endio routine (or not, in which case they
> should be bio_put by the caller). The way the impleementation works now
> is that the flush bio has a refcount of 2 and we only ever bio_put it
> once, leaving it to hang indefinitely. Fix this by removing the extra
> bio_get in __alloc_device.
>
> Fixes: e0ae99941423 ("btrfs: preallocate device flush bio")
Sigh, so many bugs. Hopefully that was the last one.
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-14 15:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-13 11:50 [PATCH] btrfs: Fix bio leak Nikolay Borisov
2017-12-13 17:00 ` Liu Bo
2017-12-14 15:16 ` David Sterba
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.