mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
bcache: Don't call sysconf for every io
This commit is contained in:
parent
7ee0a6e44d
commit
5052970da3
@ -133,6 +133,7 @@ struct async_engine {
|
|||||||
struct io_engine e;
|
struct io_engine e;
|
||||||
io_context_t aio_context;
|
io_context_t aio_context;
|
||||||
struct cb_set *cbs;
|
struct cb_set *cbs;
|
||||||
|
unsigned page_mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct async_engine *_to_async(struct io_engine *e)
|
static struct async_engine *_to_async(struct io_engine *e)
|
||||||
@ -162,9 +163,8 @@ static bool _async_issue(struct io_engine *ioe, enum dir d, int fd,
|
|||||||
struct iocb *cb_array[1];
|
struct iocb *cb_array[1];
|
||||||
struct control_block *cb;
|
struct control_block *cb;
|
||||||
struct async_engine *e = _to_async(ioe);
|
struct async_engine *e = _to_async(ioe);
|
||||||
long pgsize = sysconf(_SC_PAGESIZE);
|
|
||||||
|
|
||||||
if (((uintptr_t) data) & (pgsize - 1)) {
|
if (((uintptr_t) data) & e->page_mask) {
|
||||||
log_warn("misaligned data buffer");
|
log_warn("misaligned data buffer");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -276,6 +276,8 @@ struct io_engine *create_async_io_engine(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e->page_mask = sysconf(_SC_PAGESIZE) - 1;
|
||||||
|
|
||||||
return &e->e;
|
return &e->e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,11 +546,10 @@ static void _hash_table_exit(struct bcache *cache)
|
|||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
static bool _init_free_list(struct bcache *cache, unsigned count)
|
static bool _init_free_list(struct bcache *cache, unsigned count, unsigned pgsize)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
size_t block_size = cache->block_sectors << SECTOR_SHIFT;
|
size_t block_size = cache->block_sectors << SECTOR_SHIFT;
|
||||||
long pgsize = sysconf(_SC_PAGESIZE);
|
|
||||||
unsigned char *data =
|
unsigned char *data =
|
||||||
(unsigned char *) _alloc_aligned(count * block_size, pgsize);
|
(unsigned char *) _alloc_aligned(count * block_size, pgsize);
|
||||||
|
|
||||||
@ -949,7 +950,7 @@ struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks,
|
|||||||
cache->write_misses = 0;
|
cache->write_misses = 0;
|
||||||
cache->prefetches = 0;
|
cache->prefetches = 0;
|
||||||
|
|
||||||
if (!_init_free_list(cache, nr_cache_blocks)) {
|
if (!_init_free_list(cache, nr_cache_blocks, pgsize)) {
|
||||||
cache->engine->destroy(cache->engine);
|
cache->engine->destroy(cache->engine);
|
||||||
_hash_table_exit(cache);
|
_hash_table_exit(cache);
|
||||||
dm_free(cache);
|
dm_free(cache);
|
||||||
|
Loading…
Reference in New Issue
Block a user