Skip to content

Commit beed926

Browse files
lorddoskiaskdave
authored andcommitted
btrfs: Fix flush bio leak
Commit e0ae999 ("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: e0ae999 ("btrfs: preallocate device flush bio") Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent c8bcbfb commit beed926

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

fs/btrfs/volumes.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ static struct btrfs_device *__alloc_device(void)
237237
kfree(dev);
238238
return ERR_PTR(-ENOMEM);
239239
}
240-
bio_get(dev->flush_bio);
241240

242241
INIT_LIST_HEAD(&dev->dev_list);
243242
INIT_LIST_HEAD(&dev->dev_alloc_list);

0 commit comments

Comments
 (0)