[gparted/ataraid: 14/17] Display array device as mount point of dmraid started ATARAID members (#75)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted/ataraid: 14/17] Display array device as mount point of dmraid started ATARAID members (#75)
- Date: Mon, 2 Dec 2019 16:36:25 +0000 (UTC)
commit bb865aaaa44cc1d1d23c81ab1ba265d5cde1012b
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Wed Nov 20 21:21:07 2019 +0000
Display array device as mount point of dmraid started ATARAID members (#75)
This matches how the array device is displayed as the mount point for
mdadm started ATARAID members by "Display array device as mount point of
mdadm started ATARAID members (#75)" earlier in this patchset.
Extend the DMRaid module member cache to save the array device name and
use as needed to display as the mount point.
Closes #75 - Errors with GPT on RAID 0 ATARAID array
include/DMRaid.h | 11 ++++++++++-
src/DMRaid.cc | 48 +++++++++++++++++++++++++++++++++++++++---------
src/GParted_Core.cc | 10 ++++++++--
3 files changed, 57 insertions(+), 12 deletions(-)
---
diff --git a/include/DMRaid.h b/include/DMRaid.h
index a53e1c70..2bc61b2a 100644
--- a/include/DMRaid.h
+++ b/include/DMRaid.h
@@ -39,6 +39,13 @@ namespace GParted
{
+struct DMRaid_Member
+{
+ BlockSpecial member;
+ Glib::ustring array;
+};
+
+
class DMRaid
{
public:
@@ -60,6 +67,7 @@ public:
bool purge_dev_map_entries( const Glib::ustring & dev_path ) ;
bool update_dev_map_entry( const Partition & partition, OperationDetail & operationdetail ) ;
bool is_member_active(const Glib::ustring& member_path);
+ const Glib::ustring& get_array(const Glib::ustring& member_path);
private:
void load_dmraid_cache() ;
@@ -68,13 +76,14 @@ private:
void get_affected_dev_map_entries( const Partition & partition, std::vector<Glib::ustring> &
affected_entries ) ;
void get_partition_dev_map_entries( const Partition & partition, std::vector<Glib::ustring> &
partition_entries ) ;
static std::vector<Glib::ustring> lookup_dmraid_members(const Glib::ustring& array);
+ static const DMRaid_Member& get_cache_entry_by_member(const Glib::ustring& member_path);
static bool dmraid_cache_initialized ;
static bool dmraid_found ;
static bool dmsetup_found ;
static bool udevadm_found ;
static std::vector<Glib::ustring> dmraid_devices ;
- static std::vector<BlockSpecial> dmraid_member_cache;
+ static std::vector<DMRaid_Member> dmraid_member_cache;
};
}//GParted
diff --git a/src/DMRaid.cc b/src/DMRaid.cc
index c6c6bda4..f8d71708 100644
--- a/src/DMRaid.cc
+++ b/src/DMRaid.cc
@@ -40,7 +40,10 @@ namespace GParted
// ["isw_ecccdhhiga_MyArray"]
// dmraid_member_cache - Vector of members of active DMRaid arrays.
// E.g.
-// [BlockSpecial("/dev/sdc"), BlockSpecial("/dev/sdd")]
+// //member , array
+// [{BlockSpecial("/dev/sdc"), "/dev/mapper/isw_ecccdhhiga_MyArray"},
+// {BlockSpecial("/dev/sdd"), "/dev/mapper/isw_ecccdhhiga_MyArray"}
+// ]
//Initialize static data elements
bool DMRaid::dmraid_cache_initialized = false ;
@@ -48,7 +51,7 @@ bool DMRaid::dmraid_found = false ;
bool DMRaid::dmsetup_found = false ;
bool DMRaid::udevadm_found = false ;
std::vector<Glib::ustring> DMRaid::dmraid_devices ;
-std::vector<BlockSpecial> DMRaid::dmraid_member_cache;
+std::vector<DMRaid_Member> DMRaid::dmraid_member_cache;
DMRaid::DMRaid()
@@ -102,7 +105,12 @@ void DMRaid::load_dmraid_cache()
{
std::vector<Glib::ustring> members = lookup_dmraid_members(DEV_MAPPER_PATH +
dmraid_devices[i]);
for (unsigned int j = 0; j < members.size(); j++)
- dmraid_member_cache.push_back(BlockSpecial(members[j]));
+ {
+ DMRaid_Member memb;
+ memb.member = BlockSpecial(members[j]);
+ memb.array = DEV_MAPPER_PATH + dmraid_devices[i];
+ dmraid_member_cache.push_back(memb);
+ }
}
}
@@ -523,17 +531,23 @@ bool DMRaid::update_dev_map_entry( const Partition & partition, OperationDetail
// or not.
bool DMRaid::is_member_active(const Glib::ustring& member_path)
{
- BlockSpecial bs = BlockSpecial(member_path);
- for (unsigned int i = 0; i < dmraid_member_cache.size(); i++)
- {
- if (bs == dmraid_member_cache[i])
- return true;
- }
+ const DMRaid_Member& memb = get_cache_entry_by_member(member_path);
+ if (memb.member.m_name.length() > 0)
+ return true;
return false;
}
+// Return array device containing the specified member, or "" if the array is not running
+// or there is no such member.
+const Glib::ustring& DMRaid::get_array(const Glib::ustring& member_path)
+{
+ const DMRaid_Member& memb = get_cache_entry_by_member(member_path);
+ return memb.array;
+}
+
+
// Return vector of member devices of an active DMRaid array.
// E.g. lookup_dmraid_members("/dev/mapper/isw_ecccdhhiga_MyArray") -> ["/dev/sdc", "/dev/sdd"]
std::vector<Glib::ustring> DMRaid::lookup_dmraid_members(const Glib::ustring& array)
@@ -570,4 +584,20 @@ std::vector<Glib::ustring> DMRaid::lookup_dmraid_members(const Glib::ustring& ar
}
+// Perform linear search of the cache to find the matching member.
+// Return found cache entry or not found substitute.
+const DMRaid_Member& DMRaid::get_cache_entry_by_member(const Glib::ustring& member_path)
+{
+ BlockSpecial bs = BlockSpecial(member_path);
+ for (unsigned int i = 0; i < dmraid_member_cache.size(); i++)
+ {
+ if (bs == dmraid_member_cache[i].member)
+ return dmraid_member_cache[i];
+ }
+
+ static const DMRaid_Member notfound_memb = {BlockSpecial(), ""};
+ return notfound_memb;
+}
+
+
}//GParted
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 40057d36..0d0aa4b9 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1408,9 +1408,7 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
void GParted_Core::set_mountpoints( Partition & partition )
{
-#ifndef USE_LIBPARTED_DMRAID
DMRaid dmraid ; //Use cache of dmraid device information
-#endif
if ( partition.filesystem == FS_LVM2_PV )
{
@@ -1428,7 +1426,15 @@ void GParted_Core::set_mountpoints( Partition & partition )
{
Glib::ustring array_path = SWRaid_Info::get_array(partition.get_path());
if (! array_path.empty())
+ {
partition.add_mountpoint(array_path);
+ }
+ else
+ {
+ array_path = dmraid.get_array(partition.get_path());
+ if (! array_path.empty())
+ partition.add_mountpoint(array_path);
+ }
}
else if ( partition.filesystem == FS_LUKS )
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]