All of lore.kernel.org
 help / color / mirror / Atom feed
* master - scan: drop bcache and close fd for LV with stacked PV
@ 2018-04-23 13:51 David Teigland
  0 siblings, 0 replies; 2+ messages in thread
From: David Teigland @ 2018-04-23 13:51 UTC (permalink / raw)
  To: lvm-devel

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=34fd818caf89f39dab58ef2ce7c60c193db02cf0
Commit:        34fd818caf89f39dab58ef2ce7c60c193db02cf0
Parent:        c2b10daf694bea490044b752209a416f886373ea
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Fri Feb 16 10:37:09 2018 -0600
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Fri Apr 20 11:22:47 2018 -0500

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.
---
 tools/toollib.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/tools/toollib.c b/tools/toollib.c
index 807e34c..0b8823b 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -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)))



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* master - scan: drop bcache and close fd for LV with stacked PV
@ 2018-04-23 13:54 David Teigland
  0 siblings, 0 replies; 2+ messages in thread
From: David Teigland @ 2018-04-23 13:54 UTC (permalink / raw)
  To: lvm-devel

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=34fd818caf89f39dab58ef2ce7c60c193db02cf0
Commit:        34fd818caf89f39dab58ef2ce7c60c193db02cf0
Parent:        c2b10daf694bea490044b752209a416f886373ea
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Fri Feb 16 10:37:09 2018 -0600
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Fri Apr 20 11:22:47 2018 -0500

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.
---
 tools/toollib.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/tools/toollib.c b/tools/toollib.c
index 807e34c..0b8823b 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -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)))



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-04-23 13:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-23 13:51 master - scan: drop bcache and close fd for LV with stacked PV David Teigland
2018-04-23 13:54 David Teigland

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.