summaryrefslogtreecommitdiff
path: root/lib/label/label.c
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2018-11-16 12:21:20 -0600
committerDavid Teigland <teigland@redhat.com>2018-11-20 09:13:20 -0600
commitca66d520326493311a3c7132b1bcee0807862301 (patch)
treed3ccde7c58b9fe8d4efbc9fd4128d98b7ad7a756 /lib/label/label.c
parentb1e9fe9505293e8c9b4a4bfffafe62c5a83b4d11 (diff)
downloadlvm2-ca66d520326493311a3c7132b1bcee0807862301.tar.gz
io: use sync io if aio fails
io_setup() for aio may fail if a system has reached the aio request limit. In this case, fall back to using sync io. Also, lvm use of aio can be disabled entirely with config setting global/use_aio=0. The system limit for aio requests can be seen from /proc/sys/fs/aio-max-nr The current usage of aio requests can be seen from /proc/sys/fs/aio-nr The system limit for aio requests can be increased by setting fs.aio-max-nr using sysctl. Also add last-byte limit to the sync io code.
Diffstat (limited to 'lib/label/label.c')
-rw-r--r--lib/label/label.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/label/label.c b/lib/label/label.c
index 538716130..82ebd71e0 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -799,7 +799,7 @@ out:
static int _setup_bcache(int cache_blocks)
{
- struct io_engine *ioe;
+ struct io_engine *ioe = NULL;
if (cache_blocks < MIN_BCACHE_BLOCKS)
cache_blocks = MIN_BCACHE_BLOCKS;
@@ -807,9 +807,18 @@ static int _setup_bcache(int cache_blocks)
if (cache_blocks > MAX_BCACHE_BLOCKS)
cache_blocks = MAX_BCACHE_BLOCKS;
- if (!(ioe = create_async_io_engine())) {
- log_error("Failed to create bcache io engine.");
- return 0;
+ if (use_aio()) {
+ if (!(ioe = create_async_io_engine())) {
+ log_warn("Failed to set up async io, using sync io.");
+ init_use_aio(0);
+ }
+ }
+
+ if (!ioe) {
+ if (!(ioe = create_sync_io_engine())) {
+ log_error("Failed to set up sync io.");
+ return 0;
+ }
}
if (!(scan_bcache = bcache_create(BCACHE_BLOCK_SIZE_IN_SECTORS, cache_blocks, ioe))) {