1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 03:27:58 +03:00

scan: always setup bcache for commands using lvmetad

Do this at the start of the command so that it doesn't
need to be checked and set up in every function that
could need it.
This commit is contained in:
David Teigland 2018-02-14 16:21:27 -06:00
parent f328532f05
commit 28255e3eee
3 changed files with 22 additions and 13 deletions

View File

@ -1241,8 +1241,11 @@ int lvmcache_label_scan(struct cmd_context *cmd)
int r = 0;
if (lvmetad_used())
if (lvmetad_used()) {
if (!label_scan_setup_bcache())
return 0;
return 1;
}
/* Avoid recursion when a PVID can't be found! */
if (_scanning_in_progress)

View File

@ -678,18 +678,6 @@ int label_scan_devs(struct cmd_context *cmd, struct dm_list *devs)
{
struct device_list *devl;
if (!scan_bcache) {
/*
* This is only needed when commands are using lvmetad, in
* which case they don't do an initial label_scan, but may
* later need to rescan certain devs from disk and call this
* function.
* FIXME: is there some better number to choose here?
*/
if (!_setup_bcache(32))
return 0;
}
dm_list_iterate_items(devl, devs) {
if (_in_bcache(devl->dev)) {
bcache_invalidate_fd(scan_bcache, devl->dev->bcache_fd);
@ -841,3 +829,20 @@ void label_scan_confirm(struct device *dev)
label_read(dev, NULL, 0);
}
/*
* This is only needed when commands are using lvmetad, in which case they
* don't do an initial label_scan, but may later need to rescan certain devs
* from disk and call this function. FIXME: is there some better number to
* choose here?
*/
int label_scan_setup_bcache(void)
{
if (!scan_bcache) {
if (!_setup_bcache(32))
return 0;
}
return 1;
}

View File

@ -110,5 +110,6 @@ void label_scan_destroy(struct cmd_context *cmd);
int label_read(struct device *dev, struct label **labelp, uint64_t unused_sector);
int label_read_sector(struct device *dev, struct label **labelp, uint64_t scan_sector);
void label_scan_confirm(struct device *dev);
int label_scan_setup_bcache(void);
#endif