[gparted/new-master] Fix false usage figures for busy SWRAID members (#27)
- From: Mike Fleetwood <mfleetwo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted/new-master] Fix false usage figures for busy SWRAID members (#27)
- Date: Tue, 20 Nov 2018 10:59:38 +0000 (UTC)
commit 79770640c1c2df64d9c8c4018f0c529bfc3f47c9
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sun Nov 18 12:41:56 2018 +0000
Fix false usage figures for busy SWRAID members (#27)
Create an active Linux Software RAID member which is larger than /dev
virtual file system and GParted will report the usage figure of the /dev
virtual file system for the SWRAID member.
# df -h /dev
Filesystem Size Used Avail Use% Mounted on
devtmpfs 732M 0 732M 0% /dev
# sgdisk -n 1:1M:+1G /dev/sdb
# mdadm --create --verbose /dev/md1 --level=linear --raid-devices=1 --force /dev/sdb1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.
GParted reports the usage of /dev/sdb1 as:
Partition Mount Point Size Used Unused Unallocated
/dev/sdb1 /dev/md1 1.00GiB 0.00B 731.04MiB 292.96MiB
However GParted should have reported the usage as "---" for unknown
because it isn't coded to query the size of the SWRAID member within a
partition.
The fault has been bisected to this commit:
Extend un/mounting and usage reporting to unsupported file systems (!13)
95903efb1f284f3d6819f38e894dc6c3464b2183
What happens for busy Linux Software RAID array members:
* GParted_Core::is_busy()
has custom code to identify busy members.
* GParted_Core::set_mountpoints()
has custom code to add the array device name as the "mount point" of
the member.
* GParted_Core::set_used_sectors()
falls into the else not a supported file system (because SWRAID
doesn't have a derived FileSystem implementation class).
* GParted_Core::mounted_set_used_sectors()
is called to get the file system usage of mounted, but unsupported
file systems, such as UFS and any others.
* Utils::get_mounted_filesystem_usage()
is called which queries the kernel using statvfs() and gets the file
system usage of the /dev virtual file system because the array
device name will always start /dev.
Fix by ensuring that GParted only asks the kernel for the usage of paths
which it knows are mount points of mounted file systems. (As read from
/proc/mounts and cached in the Mount_Info module). Also rename the
method, by inserting "_fs", to mounted_fs_set_used_sectors() to remind
us that it is for mounted *file systems* only.
Closes #27 - GParted may report incorrect usage for SWRAID partitions
instead of unknown
include/GParted_Core.h | 2 +-
src/GParted_Core.cc | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/include/GParted_Core.h b/include/GParted_Core.h
index 94d204b5..c0b81445 100644
--- a/include/GParted_Core.h
+++ b/include/GParted_Core.h
@@ -96,7 +96,7 @@ private:
bool set_mountpoints_helper( Partition & partition, const Glib::ustring & path );
bool is_busy( FSType fstype, const Glib::ustring & path );
void set_used_sectors( Partition & partition, PedDisk* lp_disk );
- void mounted_set_used_sectors( Partition & partition ) ;
+ void mounted_fs_set_used_sectors(Partition& partition);
#ifdef HAVE_LIBPARTED_FS_RESIZE
void LP_set_used_sectors( Partition & partition, PedDisk* lp_disk ) ;
#endif
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index a79cda9c..8528a604 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1748,7 +1748,7 @@ void GParted_Core::set_used_sectors( Partition & partition, PedDisk* lp_disk )
p_filesystem->set_used_sectors( partition );
break;
case FS::GPARTED:
- mounted_set_used_sectors( partition );
+ mounted_fs_set_used_sectors( partition );
break;
default:
break;
@@ -1830,15 +1830,15 @@ void GParted_Core::set_used_sectors( Partition & partition, PedDisk* lp_disk )
}
else
{
- // Set usage of mouted but unsupported file systems
+ // Set usage of mounted but unsupported file systems.
if ( partition.busy )
- mounted_set_used_sectors( partition );
+ mounted_fs_set_used_sectors(partition);
}
}
-void GParted_Core::mounted_set_used_sectors( Partition & partition )
+void GParted_Core::mounted_fs_set_used_sectors( Partition & partition )
{
- if ( partition .get_mountpoints() .size() > 0 )
+ if (partition.get_mountpoints().size() > 0 && Mount_Info::is_dev_mounted(partition.get_path()))
{
Byte_Value fs_size ;
Byte_Value fs_free ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]