]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: preallocate device flush bio
authorDavid Sterba <dsterba@suse.com>
Tue, 6 Jun 2017 15:06:06 +0000 (17:06 +0200)
committerDavid Sterba <dsterba@suse.com>
Wed, 21 Jun 2017 17:03:38 +0000 (19:03 +0200)
commitb8bb3e22a4be7524bd6b15af17acfebd7090083e
treeb127434d66d6eea75a6132b3e5b8176c2608e9d9
parent0aa8e42033ed0fb5218967dd5f78222ac402611b
btrfs: preallocate device flush bio

For devices that support flushing, we allocate a bio, submit, wait for
it and then free it. The bio allocation does not fail so ENOMEM is not a
problem but we still may unnecessarily stress the allocation subsystem.

Instead, we can allocate the bio at the same time we allocate the device
and reuse it each time we need to flush the barriers. The bio is reset
before each use. Reference counting is simplified to just device
allocation (get) and freeing (put).

The bio used to be submitted through the integrity checker which will
find out that bio has no data attached and call submit_bio.

Status of the bio in flight needs to be tracked separately in case the
device caches get switched off between write and wait.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c
fs/btrfs/volumes.c
fs/btrfs/volumes.h