#define MIN_BCACHE_BLOCKS 32 /* 4MB (32 * 128KB) */
#define MAX_BCACHE_BLOCKS 4096 /* 512MB (4096 * 128KB) */
-static int _setup_bcache(void)
+int label_scan_setup_bcache(void)
{
struct io_engine *ioe = NULL;
int iomem_kb = io_memory_size();
int block_size_kb = (BCACHE_BLOCK_SIZE_IN_SECTORS * 512) / 1024;
int cache_blocks;
+ if (scan_bcache)
+ return 1;
+
cache_blocks = iomem_kb / block_size_kb;
if (cache_blocks < MIN_BCACHE_BLOCKS)
};
dev_iter_destroy(iter);
- if (!scan_bcache) {
- if (!_setup_bcache())
- goto_out;
- }
+ if (!label_scan_setup_bcache())
+ goto_out;
log_debug_devs("Reading labels for pvid");
dm_list_init(&scan_devs);
dm_list_init(&hints_list);
- if (!scan_bcache) {
- if (!_setup_bcache())
- return_0;
- }
+ if (!label_scan_setup_bcache())
+ return_0;
/*
* Creates a list of available devices, does not open or read any,
*/
int label_read_pvid(struct device *dev, int *has_pvid)
{
- char buf[4096] __attribute__((aligned(8)));
+ char buf[4096] __attribute__((aligned(8))) = { 0 };
struct label_header *lh;
struct pv_header *pvh;
- memset(buf, 0, sizeof(buf));
-
if (!label_scan_open(dev))
return_0;
{
struct device_list *devl;
- if (!scan_bcache) {
- if (!_setup_bcache())
- return 0;
- }
+ if (!label_scan_setup_bcache())
+ return_0;
dm_list_iterate_items(devl, devs) {
if (_in_bcache(devl->dev))
{
struct device_list *devl;
- if (!scan_bcache) {
- if (!_setup_bcache())
- return 0;
- }
+ if (!label_scan_setup_bcache())
+ return_0;
dm_list_iterate_items(devl, devs) {
if (_in_bcache(devl->dev))
return 1;
}
-int label_scan_setup_bcache(void)
-{
- if (!scan_bcache) {
- if (!_setup_bcache())
- return 0;
- }
-
- return 1;
-}
-
/*
* This is needed to write to a new non-lvm device.
* Scanning that dev would not keep it open or in