After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 712533 - Partitions not detected as busy inside Software RAID on some distros
Partitions not detected as busy inside Software RAID on some distros
Status: RESOLVED FIXED
Product: gparted
Classification: Other
Component: application
GIT HEAD
Other Linux
: Normal normal
: ---
Assigned To: gparted maintainers alias
gparted maintainers alias
Depends on:
Blocks:
 
 
Reported: 2013-11-17 09:38 UTC by Mike Fleetwood
Modified: 2013-12-09 18:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Detect busy file systems inside swraid (draft 1) (2.82 KB, patch)
2013-11-17 13:02 UTC, Mike Fleetwood
none Details | Review
Detect busy file systems inside swraid (v1) (10.28 KB, patch)
2013-11-23 15:26 UTC, Mike Fleetwood
none Details | Review
Detect busy file systems inside swraid (v2) (10.21 KB, patch)
2013-11-26 13:47 UTC, Mike Fleetwood
none Details | Review
Detect busy file systems inside swraid (v3) (12.11 KB, patch)
2013-11-27 19:11 UTC, Curtis Gedak
none Details | Review

Description Mike Fleetwood 2013-11-17 09:38:17 UTC
On some distros ped_partition_busy() from libparted doesn't report a
mounted partition inside a Linux Software RAID array as busy, therefore
GParted doesn't either.

Test case:
1) Create empty partition /dev/sdb1 in GParted
2) Create software RAID array
   mdadm --create --verbose /dev/md1 --level=linear --raid-devices=1 --force /dev/sdb1
3) Write partition table to /dev/md1 in GParted
4) Create partition with any filesystem /dev/md1p1 in GParted
5) Mount filesystem
   mkdir /mnt/1
   mount /dev/md1p1 /mnt/1
6) Refresh GParted and check busy status of /dev/md1p1

From my testing it fails on these distros:
* Fedora 14 with parted-2.3 & distro patches
* CentOS 6.4 with parted-2.1 & distro patches
* Debian 6 with parted-2.3 & distro patches

And it works on these distros:
* Kubuntu 12.04 LTS with parted-2.3 & distro patches
* Ubuntu 13.10 with parted-2.3 & distro patches
* Fedora 19 with parted-3.1 & distro patches
* CentOS 6.4 with my build of parted-2.4 & distro patches

I suspect that this upstream patch included in parted >= 2.4 fixed it:
http://git.savannah.gnu.org/cgit/parted.git/commit/?id=db52898c214310dab4ed84e6cb2f9ffc8c3aa502
linux: also detect "in-use" dmraid and scsi-Nth (N>=16) partition

but Ubuntu with parted-2.3 works and I couldn't identify a distro patch
which looks similar so I don't know how it works in Ubuntu.

Anyway I'll work on a patch.

Thanks,
Mike
Comment 1 Mike Fleetwood 2013-11-17 09:54:15 UTC
Hi Phillip,

I wonder if you could confirm my suspicion that this bug is fixed by
this change in parted >= 2.4:
http://git.savannah.gnu.org/cgit/parted.git/commit/?id=db52898c214310dab4ed84e6cb2f9ffc8c3aa502
linux: also detect "in-use" dmraid and scsi-Nth (N>=16) partition

and explain how it was fixed in parted 2.3 in Ubuntu?

Thanks,
Mike
Comment 2 Mike Fleetwood 2013-11-17 13:02:45 UTC
Created attachment 260036 [details] [review]
Detect busy file systems inside swraid (draft 1)

Hi Curtis,

Here's a draft patch for this.  The only reason it's draft is because
I am not sure the identified change in parted is the one which fixed
parted, and I have no idea how Ubuntu works with what should be a broken
version of parted.

Thanks,
Mike
Comment 3 Curtis Gedak 2013-11-17 19:46:34 UTC
Hi Mike,

Ubuntu often uses a base parted package from Debian and then might apply additional patches specific to Ubuntu.  An example of the naming scheme is as follows:

   parted-2.3-10ubuntu2
   \___________/\_____/
       |           +----- Ubuntu patch version modifier
       +----------------- Debian version plus patch identifier

As far as I can tell, the patch to detect in-use dmraid and scsi-Nth (N>=16) partitions was included in Debian Parted 2.3-14.

The 2.3-14+ version is only included in Debian Jessie 8 (unstable) and Sid (experimental).

The upstream Debian Parted 2.3-14 version was only included in Ubuntu 13.10+.

Hence it makes sense that online-resize would not work with Debian Squeeze 6 (oldstable) or Wheezy 7 (stable).  I believe that these Debian versions will not be updated, except in the case of a critical bug.

Phillip should be able to provide more authoritative details on how this works.

In determining this information I used the following links that can help when trying to determine version information for Debian and Ubuntu parted packages:

Debian Parted Package:
http://packages.debian.org/search?keywords=parted

Debian Parted Package Tracking System:
http://packages.qa.debian.org/p/parted.html

Debian Parted Package Changelog:
http://ftp-master.metadata.debian.org/changelogs/main/p/parted/unstable_changelog

Ubuntu 13.10 Parted Package:
http://packages.ubuntu.com/saucy/parted

Ubuntu 13.10 Parted Package Changelog:
http://changelogs.ubuntu.com/changelogs/pool/main/p/parted/parted_2.3-16ubuntu1/changelog

Please note that I haven't yet tested this patch.

Curtis
Comment 4 Phillip Susi 2013-11-17 21:59:37 UTC
Yes, that patch fixed it and is applied in Ubuntu ( and now Debian ).  Are you building with --enable-libparted-dmraid?  IIRC gparted had some code to handle this and I discovered and fixed the bug in libparted when I added --enable-libparted-dmraid, which disabled the gparted workaround and relied on libparted.
Comment 5 Phillip Susi 2013-11-17 22:23:35 UTC
Oh, and I believe sid == unstable, and jessie is what testing will be when released, and expiermental does not have a code name.  I think the patch can be back ported to wheezy if you file a bug report.  Fedora/CentOS will probably also apply the fix if you file a bug report linking to the upstream commit.
Comment 6 Mike Fleetwood 2013-11-19 17:49:25 UTC
Hi Curtis,

Don't apply this patch.  I have done some more testing and found more I
need to do.  (Testing was on Debian 6, in case it matters).

Specifically:

1) Only have busy LVM PV2 and/or SWRAID arrays in logical partitions.
   Extended partition is not shows as busy.
   This is because libparted ped_partition_is_busy() internally only
   looks for mounted file systems to determine if partitions are busy.
   We will have to also recurse logical partitions ourselves to
   determine if extended partitions in GParted too.
   (This has been an oversight since LVM PV2 was added :-(

2) Strange case.  Create 2 SWRAID arrays /dev/md1 and /dev/md2.
   Create FS filling /dev/md2 (without any partitioning) and mount it:
     mkfs.ext4 -L test2 /dev/md2
     mkdir /mnt/2
     mount /dev/md2 /mnt/2
   In GParted write partition table to /dev/md1, create partition and
   file system /dev/md1p1.
   GParted immediately reports the partition as busy.  Libparted
   ped_partition_is_busy() is incorrectly reporting the as busy.  This
   case says we should stop using this API all together.

Thanks,
Mike
Comment 7 Phillip Susi 2013-11-19 17:58:36 UTC
Or libparted should be fixed and that way people using it on the command line also get the correct behavior.
Comment 8 Curtis Gedak 2013-11-19 18:32:13 UTC
Hi Phillip,

Thanks for reminding me about the busy handling for DMRaid partitions.  From Mike's patch it looks like this is the area that Mike is fixing.

I agree that ideally the libparted should be fixed.  Based on your the question in comment #1 and your response in comment #4 I assume that upstream libparted is fixed for versions 2.4 and higher.

Because we try to ensure GParted also works in currently supported major distros, we probably need a fix in GParted as well.

Curtis
Comment 9 Mike Fleetwood 2013-11-19 18:44:11 UTC
Hi Phillip,

I've now also tested case 2 from comment #6 on Ubuntu 13.10 and found
that libparted works correctly so I assume that it was corrected by your
already identified patch.

It seems that libblkid is the primary Linux mechanism for detecting
signatures.  Therefore I don't have the inclination to try to add
recongition of LVM2 PV and SWRAID signatures and detection of their
busy status to libparted.

Sorry,
Mike
Comment 10 Phillip Susi 2013-11-19 19:52:31 UTC
It doesn't need to recognize signatures, but it should recognize when it is busy.  I'll certainly take a look at fixing that.
Comment 11 Mike Fleetwood 2013-11-23 15:26:33 UTC
Created attachment 261300 [details] [review]
Detect busy file systems inside swraid (v1)

Hi Curtis,

Here's the patches for the issues found in this bug report:
1) Fix busy detection of file systems inside Linux Software RAID (#712533)
2) Fix false busy detection of unusual case with Linux Software RAID (#712533)
3) Fix detection of busy status of extended partitions (#712533)

and a small tidy-up:
4) Remove multi-line comment compiler warning from PipeCapture.cc

Successfully tested on:
- CentOS 5.9, libparted 1.8
  NOTE: Can't test fix in patches (1) and (2) because the OS is so old
  it doesn't allow SWRAID arrays to be partitioned.
- Debian 6, libparted 2.3
- Fedora 19, libparted 3.1
- Ubuntu 13.10, libparted 2.3 + distro fix

Please test on fake/DMRAID setup to confirm patch num (3) is OK, in
addition to any other testing.

Thanks,
Mike
Comment 12 Curtis Gedak 2013-11-23 18:11:18 UTC
Hi Mike,

I've got an Intel fake RAID / DMRAID setup on my development computer so I should be able to test this in the next day or so.

Curtis
Comment 13 Curtis Gedak 2013-11-24 20:47:32 UTC
Hi Mike and Phillip,

Even before reviewing this patch, it would appear that reporting of
LVM2 PV space usage in GParted 0.16.2 is broken for fake RAID /
DMRAID.  The root of the problem appears to be the multiple device
partition names that are used among dmraid, libparted, and lvm2 tools
(I can provide an example of the multiple device partition names if
needed).

Rather than pollute the LVM2 PV code with more USE_LIBPARTED_DMRAID
#ifdefs, I would like to explore making USE_LIBPARTED_DMRAID the
default and get rid of the #ifdefs and unused code.

Before doing this we need to know what minimum version of
libparted is required to work with fake RAID / DMRAID.


Phillip,

Do you know what minimum version of libparted is required to work with
fake RAID / DMRAID?

If not then I will have to do some testing to determine this.


For reference, Phillip and I looked at removing the custom DMRAID
behaviour from GParted in early 2011, but back then we decided to add
the USE_LIBPARTED_DMRAID configure flag instead of increasing the
minimum required libparted version.

See [Natty] Gparted duplicates dmraid partition devices
https://bugs.launchpad.net/ubuntu/+source/gparted/+bug/719129

Curtis
Comment 14 Phillip Susi 2013-11-24 23:59:13 UTC
I think it was the switch from BLKRRPART to BLKPG that fixed this, which went into parted 2.3, and I think the last time we discussed it, there was still a distro on 2.2.

Of course, I still say that if someone can be bothered to compile the latest gparted themselves, it isn't asking much for them to have a parted that isn't over 3.5 years old and if they can compile one, they can compile the other.
Comment 15 Mike Fleetwood 2013-11-25 08:55:41 UTC
Hi Curtis,

Can you raise a separate bug to investigate the issue with DMRAID
please.  This one is about recognition of busy status of partitions
in Linux Software RAID.  They should be kept independent of each other.
Even patch number 3 "Fix detection of busy status of extended partitions
(#712533)" shouldn't make any difference.

Thanks,
Mike
Comment 16 Curtis Gedak 2013-11-25 19:39:18 UTC
Hi Mike and Phillip,

Thank you for your responses.

As suggested I have created the following report:

Bug #715191 - LVM2 PV recognition and space usage not working on fake
              BIOS RAID

I will focus on reviewing/testing the patch set in comment #11, without testing on motherboard BIOS RAID / fake RAID.

Curtis
Comment 17 Mike Fleetwood 2013-11-26 12:44:37 UTC
Hi Curtis,

Please still test on a motherboard with BIOS RAID / fake RAID, just
don't use an LVM2 PV to do it.

Patch number 3 "Fix detection of busy status of extended partitions
(#712533)" changes how busy status of extended partitions is determined.

Previously:
  DMRAID specific code looked for logical partitions (device name ending
  in 5 upwards) being used as a mount point in the GParted internal
  mounted map.  But this only detects if mountable file systems or swap
  space was in a logical partition.

  Libparted's ped_partition_is_busy() used for non-DMRAID devices also
  suffers from the same limitation.

  Therefore they both ignore any busy logical partitions containing
  LVM2 PV or Linux Software RAID members.

Now:
  At the end, loops through all the logical partitions looking to see if
  any are busy to determine the busy status of the extended partition.

  This relies of correct determination of the logical partitions in the
  first place, which hasn't changed in patch number 3, but GParted
  already requires this anyway.

Thanks,
Mike
Comment 18 Mike Fleetwood 2013-11-26 13:47:58 UTC
Created attachment 262851 [details] [review]
Detect busy file systems inside swraid (v2)

Sorry Curtis,

Here's patchset v2.  Same as v1 from comment #11 except for removing the
use of an unnecessary variable in patch number 3 when determining if an
extended partition is busy.  When writing the above comment I realised
I needed to update the code and simplify the code a little bit.

Thanks,
Mike
Comment 19 Phillip Susi 2013-11-26 14:56:11 UTC
I think we are going to get rid of the busy detection on extended partitions since there's no need for it.
Comment 20 Phillip Susi 2013-11-26 15:01:46 UTC
I think when I fix this in parted it will be by looking at the holders directory in the sysfs node for the partition since that doesn't depend on enumerating all of the lvm and md devices and cross referencing them.  I would say that gparted should do that too, except that it already has to build a map of the md/dm devices anyhow, so I'm not sure.  Something to think about.
Comment 21 Curtis Gedak 2013-11-26 17:13:41 UTC
Hi Mike and Phillip,

Thanks for the reminding me that I still need to test on fake BIOS RAID to ensure that busy detection is working.  I plan to test this and a few other permutations to ensure all is working well.

Because we try to maintain backward compatibility with major currently supported distros, I believe we will need to keep extended partition busy detection in GParted for the foreseeable future.

Curtis
Comment 22 Phillip Susi 2013-11-26 18:16:54 UTC
No Curtis, I meant in the other bug we were discussing getting rid of the restrictions on busy extended partitions and allowing them to be resized.  If we do that then it doesn't matter that libparted can't detect a busy extended partition and a patch to work around it is moot.
Comment 23 Curtis Gedak 2013-11-27 19:11:35 UTC
Created attachment 262972 [details] [review]
Detect busy file systems inside swraid (v3)

Hi Mike,

Good work on this patch set.

My testing of patch set v2 in comment #18 has gone very well.  I made the following small changes to the patch set:

1)  Grammar change from "effected" to "affected" in two commit messages.

2)  Added patch show SWRAID active/not active status in info dialog.

A minor problem still exists in that the busy status of LVM2 PV and Linux Software RAID does not work on fake BIOS RAID.  This is likely due to problems with multiple device path entries on fake BIOS RAID and should be handled in the already created:
Bug #715191 - LVM2 PV space usage details not working on fake BIOS RAID.

Your patches meet with my approval.  If my added patch looks okay to you then please feel free to commit the patch set to the git master branch.

Curtis
Comment 24 Mike Fleetwood 2013-11-27 20:30:19 UTC
Hi Curtis,

Thanks for the review.  Good catch on reporting busy status of SWRAID
partition in the Info Dialog.  I made some very small white space
changes to it and moved it to before my final cleanup patch.

I've committed the following changes to the GParted git repository:

Fix busy detection of file systems inside Linux Software RAID (#712533)
https://git.gnome.org/browse/gparted/commit/?id=4d7ebe0314b8c713d7b0b1a1453e95f067d52fae

Fix false busy detection of unusual case with Linux Software RAID (#712533)
https://git.gnome.org/browse/gparted/commit/?id=420299206323fb49da5ba099b9f51cba95e58603

Fix detection of busy status of extended partitions (#712533)
https://git.gnome.org/browse/gparted/commit/?id=ad63ede421ab97c3cc4b4c8f74f2dcdc04e77785

Show SWRAID active/not active status in information dialog (#712533)
https://git.gnome.org/browse/gparted/commit/?id=d842b8cdfb08bad8dd844640b8472a8501d011d3

Remove multi-line comment compiler warning from PipeCapture.cc
https://git.gnome.org/browse/gparted/commit/?id=b3f0a0b1beec7c06512ff24da6ea928bdb03cb8d

Thanks,
Mike
Comment 25 Curtis Gedak 2013-12-09 18:12:14 UTC
This enhancement was included in the GParted 0.17.0 release on December 9, 2013.