mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
scan: drop bcache and close fd for LV with stacked PV
When a PV is stacked on an LV, the LV will be kept in bcache, and the open fd on the LV may interfere with processing the LV. So, drop/close a bcache fd for an LV before processing the LV.
This commit is contained in:
parent
c2b10daf69
commit
34fd818caf
@ -3009,6 +3009,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||
log_report_t saved_log_report_state = log_get_report_state();
|
||||
char lv_uuid[64] __attribute__((aligned(8)));
|
||||
char vg_uuid[64] __attribute__((aligned(8)));
|
||||
struct lvinfo lvinfo;
|
||||
int ret_max = ECMD_PROCESSED;
|
||||
int ret = 0;
|
||||
int whole_selected = 0;
|
||||
@ -3025,6 +3026,8 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||
struct lv_list *final_lvl;
|
||||
struct dm_list found_arg_lvnames;
|
||||
struct glv_list *glvl, *tglvl;
|
||||
struct device *dev;
|
||||
dev_t devt;
|
||||
int do_report_ret_code = 1;
|
||||
|
||||
log_set_report_object_type(LOG_REPORT_OBJECT_TYPE_LV);
|
||||
@ -3162,6 +3165,18 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||
}
|
||||
log_set_report_object_name_and_id(NULL, NULL);
|
||||
|
||||
/*
|
||||
* If a PV is stacked on an LV, then the LV is kept open
|
||||
* in bcache, and needs to be closed so the open fd doesn't
|
||||
* interfere with processing the LV.
|
||||
*/
|
||||
dm_list_iterate_items(lvl, &final_lvs) {
|
||||
lv_info(cmd, lvl->lv, 0, &lvinfo, 0, 0);
|
||||
devt = MKDEV(lvinfo.major, lvinfo.minor);
|
||||
if ((dev = dev_cache_get_by_devt(devt, cmd->filter)))
|
||||
label_scan_invalidate(dev);
|
||||
}
|
||||
|
||||
dm_list_iterate_items(lvl, &final_lvs) {
|
||||
lv_uuid[0] = '\0';
|
||||
if (!id_write_format(&lvl->lv->lvid.id[1], lv_uuid, sizeof(lv_uuid)))
|
||||
|
Loading…
Reference in New Issue
Block a user