Skip to content

Commit

Permalink
FIXUP - don't expose sync_percent, copy_percent is the same
Browse files Browse the repository at this point in the history
maybe
  • Loading branch information
mvollmer committed Apr 12, 2022
1 parent 0d99f56 commit 280ce76
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 18 deletions.
2 changes: 0 additions & 2 deletions src/lib/plugin_apis/lvm.api
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ typedef struct BDLVMLVdata {
guint64 copy_percent;
gchar **lv_tags;
gchar *health_status;
guint64 sync_percent;
} BDLVMLVdata;

/**
Expand Down Expand Up @@ -342,7 +341,6 @@ BDLVMLVdata* bd_lvm_lvdata_copy (BDLVMLVdata *data) {
new_data->copy_percent = data->copy_percent;
new_data->lv_tags = g_strdupv (data->lv_tags);
new_data->health_status = g_strdup (data->health_status);
new_data->sync_percent = data->sync_percent;
return new_data;
}

Expand Down
15 changes: 4 additions & 11 deletions src/plugins/lvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ BDLVMLVdata* bd_lvm_lvdata_copy (BDLVMLVdata *data) {
new_data->copy_percent = data->copy_percent;
new_data->lv_tags = g_strdupv (data->lv_tags);
new_data->health_status = g_strdup (data->health_status);
new_data->sync_percent = data->sync_percent;
return new_data;
}

Expand Down Expand Up @@ -667,12 +666,6 @@ static BDLVMLVdata* get_lv_data_from_table (GHashTable *table, gboolean free_tab

data->health_status = g_strdup (g_hash_table_lookup (table, "LVM2_LV_HEALTH_STATUS"));

value = (gchar*) g_hash_table_lookup (table, "LVM2_SYNC_PERCENT");
if (value)
data->sync_percent = g_ascii_strtoull (value, NULL, 0);
else
data->sync_percent = 0;

/* replace '[' and ']' (marking LVs as internal) with spaces and then
remove all the leading and trailing whitespace */
g_strstrip (g_strdelimit (data->pool_lv, "[]", ' '));
Expand Down Expand Up @@ -1946,7 +1939,7 @@ gboolean bd_lvm_delete_lv_tags (const gchar *vg_name, const gchar *lv_name, cons
BDLVMLVdata* bd_lvm_lvinfo (const gchar *vg_name, const gchar *lv_name, GError **error) {
const gchar *args[11] = {"lvs", "--noheadings", "--nosuffix", "--nameprefixes",
"--unquoted", "--units=b", "-a",
"-o", "vg_name,lv_name,lv_uuid,lv_size,lv_attr,segtype,origin,pool_lv,data_lv,metadata_lv,role,move_pv,data_percent,metadata_percent,copy_percent,lv_tags,health_status,sync_percent",
"-o", "vg_name,lv_name,lv_uuid,lv_size,lv_attr,segtype,origin,pool_lv,data_lv,metadata_lv,role,move_pv,data_percent,metadata_percent,copy_percent,lv_tags,health_status",
NULL, NULL};

GHashTable *table = NULL;
Expand All @@ -1970,7 +1963,7 @@ BDLVMLVdata* bd_lvm_lvinfo (const gchar *vg_name, const gchar *lv_name, GError *

for (lines_p = lines; *lines_p; lines_p++) {
table = parse_lvm_vars ((*lines_p), &num_items);
if (table && (num_items == 18)) {
if (table && (num_items == 17)) {
g_strfreev (lines);
return get_lv_data_from_table (table, TRUE);
} else
Expand Down Expand Up @@ -1998,7 +1991,7 @@ BDLVMLVdata* bd_lvm_lvinfo (const gchar *vg_name, const gchar *lv_name, GError *
BDLVMLVdata** bd_lvm_lvs (const gchar *vg_name, GError **error) {
const gchar *args[11] = {"lvs", "--noheadings", "--nosuffix", "--nameprefixes",
"--unquoted", "--units=b", "-a",
"-o", "vg_name,lv_name,lv_uuid,lv_size,lv_attr,segtype,origin,pool_lv,data_lv,metadata_lv,role,move_pv,data_percent,metadata_percent,copy_percent,lv_tags,health_status,sync_percent",
"-o", "vg_name,lv_name,lv_uuid,lv_size,lv_attr,segtype,origin,pool_lv,data_lv,metadata_lv,role,move_pv,data_percent,metadata_percent,copy_percent,lv_tags,health_status",
NULL, NULL};

GHashTable *table = NULL;
Expand Down Expand Up @@ -2038,7 +2031,7 @@ BDLVMLVdata** bd_lvm_lvs (const gchar *vg_name, GError **error) {

for (lines_p = lines; *lines_p; lines_p++) {
table = parse_lvm_vars ((*lines_p), &num_items);
if (table && (num_items == 18)) {
if (table && (num_items == 17)) {
/* valid line, try to parse and record it */
lvdata = get_lv_data_from_table (table, TRUE);
if (lvdata) {
Expand Down
1 change: 0 additions & 1 deletion src/plugins/lvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ typedef struct BDLVMLVdata {
guint64 copy_percent;
gchar **lv_tags;
gchar *health_status;
guint64 sync_percent;
} BDLVMLVdata;

void bd_lvm_lvdata_free (BDLVMLVdata *data);
Expand Down
4 changes: 0 additions & 4 deletions tests/lvm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,6 @@ def test_lvpartial(self):
info = BlockDev.lvm_lvinfo("testVG", "testLV")
self.assertTrue(info)
self.assertEqual(info.health_status, "")
self.assertEqual(info.sync_percent, 100)

# remove records of missing PVs
succ = BlockDev.lvm_vgreduce("testVG", None, None)
Expand Down Expand Up @@ -974,9 +973,6 @@ def test_lvcreate_type(self):
info = BlockDev.lvm_lvinfo("testVG", "testLV")
self.assertEqual(info.segtype, "raid1")

# it should be fully synched
self.assertEqual(info.sync_percent, 100)

succ = BlockDev.lvm_lvremove("testVG", "testLV", True, None)
self.assertTrue(succ)

Expand Down

0 comments on commit 280ce76

Please sign in to comment.