Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/plugin_apis/fs.api
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ BDFSVfatInfo* bd_fs_vfat_info_copy (BDFSVfatInfo *data) {
ret->uuid = g_strdup (data->uuid);
ret->cluster_size = data->cluster_size;
ret->cluster_count = data->cluster_count;
ret->free_cluster_count = data->free_cluster_count;

return ret;
}
Expand Down
4 changes: 3 additions & 1 deletion src/lib/plugin_apis/lvm.api
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,9 @@ BDLVMCacheStats* bd_lvm_cache_stats_copy (BDLVMCacheStats *data) {
*
* Frees @data.
*/
void bd_lvm_cache_stats_free (BDLVMLVdata *data) {
void bd_lvm_cache_stats_free (BDLVMCacheStats *data) {
if (data == NULL)
return;
g_free (data);
}

Expand Down
1 change: 1 addition & 0 deletions src/lib/plugin_apis/mdraid.api
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ BDMDDetailData* bd_md_detail_data_copy (BDMDDetailData *data) {
new_data->array_size = data->array_size;
new_data->use_dev_size = data->use_dev_size;
new_data->raid_devices = data->raid_devices;
new_data->total_devices = data->total_devices;
new_data->active_devices = data->active_devices;
new_data->working_devices = data->working_devices;
new_data->failed_devices = data->failed_devices;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/plugin_apis/nvdimm.api
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ BDNVDIMMNamespaceInfo* bd_nvdimm_namespace_info_copy (BDNVDIMMNamespaceInfo *inf

BDNVDIMMNamespaceInfo *new_info = g_new0 (BDNVDIMMNamespaceInfo, 1);

new_info->dev = info->dev;
new_info->dev = g_strdup (info->dev);
new_info->mode = info->mode;
new_info->size = info->size;
new_info->uuid = g_strdup (info->uuid);
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/btrfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ gboolean bd_btrfs_is_tech_avail (BDBtrfsTech tech G_GNUC_UNUSED, guint64 mode G_
}

static BDBtrfsDeviceInfo* get_device_info_from_match (GMatchInfo *match_info) {
BDBtrfsDeviceInfo *ret = g_new(BDBtrfsDeviceInfo, 1);
BDBtrfsDeviceInfo *ret = g_new0(BDBtrfsDeviceInfo, 1);
gchar *item = NULL;
BSSize size = NULL;
BSError *error = NULL;
Expand Down Expand Up @@ -213,7 +213,7 @@ static BDBtrfsDeviceInfo* get_device_info_from_match (GMatchInfo *match_info) {
}

static BDBtrfsSubvolumeInfo* get_subvolume_info_from_match (GMatchInfo *match_info) {
BDBtrfsSubvolumeInfo *ret = g_new(BDBtrfsSubvolumeInfo, 1);
BDBtrfsSubvolumeInfo *ret = g_new0(BDBtrfsSubvolumeInfo, 1);
gchar *item = NULL;

item = g_match_info_fetch_named (match_info, "id");
Expand All @@ -230,7 +230,7 @@ static BDBtrfsSubvolumeInfo* get_subvolume_info_from_match (GMatchInfo *match_in
}

static BDBtrfsFilesystemInfo* get_filesystem_info_from_match (GMatchInfo *match_info) {
BDBtrfsFilesystemInfo *ret = g_new(BDBtrfsFilesystemInfo, 1);
BDBtrfsFilesystemInfo *ret = g_new0(BDBtrfsFilesystemInfo, 1);
gchar *item = NULL;
BSSize size = NULL;
BSError *error = NULL;
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -2561,6 +2561,8 @@ static gboolean get_subsystem_label (const gchar *device, gchar **subsystem, gch
if (status != 0) {
g_set_error (error, BD_CRYPTO_ERROR, BD_CRYPTO_ERROR_DEVICE,
"Failed to get subsystem for the device '%s'", device);
g_free (*label);
*label = NULL;
blkid_free_probe (probe);
synced_close (fd);
return FALSE;
Expand Down Expand Up @@ -3285,7 +3287,6 @@ gboolean bd_crypto_tc_open_flags (const gchar *device, const gchar *name, BDCryp
"Only 'passphrase' context type is valid for TC open.");
bd_utils_report_finished (progress_id, l_error->message);
g_propagate_error (error, l_error);
crypt_free (cd);
return FALSE;
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/lvm/lvm-dbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -3714,7 +3714,7 @@ gboolean bd_lvm_cache_pool_convert (const gchar *vg_name, const gchar *data_lv,

ret = call_lvm_obj_method_sync (vg_name, VG_INTF, "CreateCachePool", params, NULL, extra, TRUE, error);

if (!ret && name)
if (ret && name)
bd_lvm_lvrename (vg_name, data_lv, name, NULL, error);
Comment on lines +3717 to 3718
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Propagate the rename result after a successful convert.

Line 3718 still ignores bd_lvm_lvrename()'s return value. If CreateCachePool succeeds but the rename fails, bd_lvm_cache_pool_convert() can still return TRUE even though the caller asked for a different final LV name. The native path in src/plugins/lvm/lvm.c:2499-2500 already folds the rename result into the final status.

Suggested fix
-    if (ret && name)
-        bd_lvm_lvrename (vg_name, data_lv, name, NULL, error);
+    if (ret && name)
+        ret = bd_lvm_lvrename (vg_name, data_lv, name, NULL, error);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (ret && name)
bd_lvm_lvrename (vg_name, data_lv, name, NULL, error);
if (ret && name)
ret = bd_lvm_lvrename (vg_name, data_lv, name, NULL, error);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/plugins/lvm/lvm-dbus.c` around lines 3717 - 3718, The code ignores
bd_lvm_lvrename()'s return value causing bd_lvm_cache_pool_convert() to report
success even if the rename failed; update the call in bd_lvm_cache_pool_convert
so you capture and fold the rename result into the existing status (e.g., set
ret = ret && bd_lvm_lvrename(vg_name, data_lv, name, NULL, error)) so the final
return reflects both the CreateCachePool and the LV rename outcome.


return ret;
Expand Down
1 change: 1 addition & 0 deletions src/plugins/nvdimm.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ BDNVDIMMNamespaceInfo** bd_nvdimm_list_namespaces (const gchar *bus_name, const
}

if (namespaces->len == 0) {
g_ptr_array_free (namespaces, TRUE);
ndctl_unref (ctx);
return NULL;
}
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/part.c
Original file line number Diff line number Diff line change
Expand Up @@ -991,12 +991,11 @@ BDPartSpec* bd_part_create_part (const gchar *disk, BDPartTypeReq type, guint64
if (status != 0) {
g_set_error (&l_error, BD_PART_ERROR, BD_PART_ERROR_FAIL,
"Failed to get existing partitions on the device: %s", strerror_l (-status, c_locale));
fdisk_unref_partition (npa);
close_context (cxt);
bd_utils_report_finished (progress_id, l_error->message);
g_propagate_error (error, l_error);
return NULL;
}
}

npa = fdisk_new_partition ();
if (!npa) {
Expand Down
6 changes: 6 additions & 0 deletions tests/_lvm_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -1916,6 +1916,12 @@ def test_cache_pool_convert(self):
succ = BlockDev.lvm_cache_pool_convert("testVG", "dataLV", "metadataLV", "testCache", None)
self.assertTrue(succ)

# verify the cache pool exists under the requested name
info = BlockDev.lvm_lvinfo("testVG", "testCache")
self.assertIsNotNone(info)
self.assertEqual(info.lv_name, "testCache")
self.assertIn("C", info.attr)

@tag_test(TestTags.SLOW)
def test_cache_pool_attach_detach(self):
"""Verify that is it possible to attach and detach a cache pool"""
Expand Down
Loading