mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +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:
parent
f328532f05
commit
28255e3eee
5
lib/cache/lvmcache.c
vendored
5
lib/cache/lvmcache.c
vendored
@ -1241,8 +1241,11 @@ int lvmcache_label_scan(struct cmd_context *cmd)
|
|||||||
|
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
if (lvmetad_used())
|
if (lvmetad_used()) {
|
||||||
|
if (!label_scan_setup_bcache())
|
||||||
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Avoid recursion when a PVID can't be found! */
|
/* Avoid recursion when a PVID can't be found! */
|
||||||
if (_scanning_in_progress)
|
if (_scanning_in_progress)
|
||||||
|
@ -678,18 +678,6 @@ int label_scan_devs(struct cmd_context *cmd, struct dm_list *devs)
|
|||||||
{
|
{
|
||||||
struct device_list *devl;
|
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) {
|
dm_list_iterate_items(devl, devs) {
|
||||||
if (_in_bcache(devl->dev)) {
|
if (_in_bcache(devl->dev)) {
|
||||||
bcache_invalidate_fd(scan_bcache, devl->dev->bcache_fd);
|
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);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -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(struct device *dev, struct label **labelp, uint64_t unused_sector);
|
||||||
int label_read_sector(struct device *dev, struct label **labelp, uint64_t scan_sector);
|
int label_read_sector(struct device *dev, struct label **labelp, uint64_t scan_sector);
|
||||||
void label_scan_confirm(struct device *dev);
|
void label_scan_confirm(struct device *dev);
|
||||||
|
int label_scan_setup_bcache(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user