GNU bug report logs -
#15491
[PATCH] libparted: avoid disturbing partitions
Previous Next
Reported by: Phillip Susi <psusi <at> ubuntu.com>
Date: Mon, 30 Sep 2013 02:20:05 UTC
Severity: normal
Tags: patch
Done: Phillip Susi <psusi <at> ubuntu.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 15491 in the body.
You can then email your comments to 15491 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-parted <at> gnu.org
:
bug#15491
; Package
parted
.
(Mon, 30 Sep 2013 02:20:05 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Phillip Susi <psusi <at> ubuntu.com>
:
New bug report received and forwarded. Copy sent to
bug-parted <at> gnu.org
.
(Mon, 30 Sep 2013 02:20:06 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
The partition sync logic was first removing all
partitions, then trying to re-add them. This resulted in many
udev events triggering annoying behavior like auto mounting.
Refactor the code to avoid removing and re-adding unmodified
partitions.
---
libparted/arch/linux.c | 69 +++++++++++++++++++++++---------------------------
1 file changed, 31 insertions(+), 38 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 4b1b438..d3a03d6 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2670,6 +2670,11 @@ _dm_get_partition_start_and_length(PedPartition const *part,
return 0;
char *path = _device_get_part_path (part->disk->dev, part->num);
PED_ASSERT(path);
+ /* libdevmapper likes to complain on stderr instead of quietly
+ returning ENOENT or ENXIO, so try to stat first */
+ struct stat st;
+ if (stat(path, &st))
+ goto err;
dm_task_set_name(task, path);
if (!dm_task_run(task))
goto err;
@@ -2806,50 +2811,38 @@ _disk_sync_part_table (PedDisk* disk)
if (!errnums)
goto cleanup;
- /* Attempt to remove each and every partition, retrying for
- up to max_sleep_seconds upon any failure due to EBUSY. */
- unsigned int sleep_microseconds = 10000;
- unsigned int max_sleep_seconds = 1;
- unsigned int n_sleep = (max_sleep_seconds
- * 1000000 / sleep_microseconds);
int i;
- for (i = 0; i < n_sleep; i++) {
- if (i)
- usleep (sleep_microseconds);
- bool busy = false;
- int j;
- for (j = 0; j < lpn; j++) {
- if (!ok[j]) {
- ok[j] = remove_partition (disk, j + 1);
- errnums[j] = errno;
- if (!ok[j] && errnums[j] == EBUSY)
- busy = true;
- }
- }
- if (!busy)
- break;
- }
-
for (i = 1; i <= lpn; i++) {
PedPartition *part = ped_disk_get_partition (disk, i);
if (part) {
- if (!ok[i - 1] && errnums[i - 1] == EBUSY) {
- unsigned long long length;
- unsigned long long start;
- /* get start and length of existing partition */
- if (!get_partition_start_and_length(part,
- &start, &length))
- goto cleanup;
- if (start == part->geom.start
- && length == part->geom.length)
- ok[i - 1] = 1;
- /* If the new partition is unchanged and the
- existing one was not removed because it was
- in use, then reset the error flag and do not
- try to add it since it is already there. */
+ unsigned long long length;
+ unsigned long long start;
+ /* get start and length of existing partition */
+ if (get_partition_start_and_length(part,
+ &start, &length)
+ && start == part->geom.start
+ && length == part->geom.length) {
+ ok[i - 1] = 1;
+ /* partition is unchanged, so nothing to do */
continue;
}
-
+ }
+ /* Attempt to remove the partition, retrying for
+ up to max_sleep_seconds upon any failure due to EBUSY. */
+ unsigned int sleep_microseconds = 10000;
+ unsigned int max_sleep_seconds = 1;
+ unsigned int n_sleep = (max_sleep_seconds
+ * 1000000 / sleep_microseconds);
+ do {
+ ok[i - 1] = remove_partition (disk, i);
+ errnums[i - 1] = errno;
+ if (ok[i - 1] || errnums[i - 1] != EBUSY)
+ break;
+ usleep (sleep_microseconds);
+ } while (n_sleep--);
+ if (!ok[i - 1] && errnums[i - 1] == ENXIO)
+ ok[i - 1] = 1; /* it already doesn't exist */
+ if (part && ok[i - 1]) {
/* add the (possibly modified or new) partition */
if (!add_partition (disk, part)) {
ok[i - 1] = 0;
--
1.8.1.2
Information forwarded
to
bug-parted <at> gnu.org
:
bug#15491
; Package
parted
.
(Mon, 18 Nov 2013 04:21:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 15491 <at> debbugs.gnu.org (full text, mbox):
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
I had to revise this patch because it caused failures to update the
partition table when lower numbered partitions that had been added or
removed overlapped with higher numbered partitions that had been
removed or changed ( and not yet removed/changed at the time the lower
partition is processed ). So I fixed it to try to remove all
partitions that are not unchanged first, then add/resize.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBCgAGBQJSiZV6AAoJEJrBOlT6nu756mIH/1J7un4cXEkJVIq8g65CLTZa
BpbxnZkwLMHUagz644vmHxBY+erVLtouN8f5/pki80murF6z7u27wGUfjRcgjf3B
wWPqg+2VKFc6iM6VlPIy6IP8ATXe8ym62RHak6xgpq9TGBDK0yIjB7vAi/2KCFLE
x2LWbI94pR90WlpZfgtrsJxCfCjINlrXbJuBAPIiL958KyllwOFD4DPxv6L89ZLU
a+oD0ANpF544OJJmYtpZ/NCefZrIDc9inHpgcLivlzTdQKhODKK3ROT9Q5VtWRP8
NAe8m3kXxcyCXgms32NXiWnKio38owHuOBy04dlliHVBHURTgwfLtFAz5IV9BSo=
=SBMT
-----END PGP SIGNATURE-----
Information forwarded
to
bug-parted <at> gnu.org
:
bug#15491
; Package
parted
.
(Mon, 18 Nov 2013 04:22:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 15491 <at> debbugs.gnu.org (full text, mbox):
The partition sync logic was first removing all
partitions, then trying to re-add them. This resulted in many
udev events triggering annoying behavior like auto mounting.
Refactor the code to avoid removing and re-adding unmodified
partitions.
---
libparted/arch/linux.c | 84 ++++++++++++++++++++++++++++----------------------
1 file changed, 47 insertions(+), 37 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 4b1b438..f43eae1 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2670,6 +2670,11 @@ _dm_get_partition_start_and_length(PedPartition const *part,
return 0;
char *path = _device_get_part_path (part->disk->dev, part->num);
PED_ASSERT(path);
+ /* libdevmapper likes to complain on stderr instead of quietly
+ returning ENOENT or ENXIO, so try to stat first */
+ struct stat st;
+ if (stat(path, &st))
+ goto err;
dm_task_set_name(task, path);
if (!dm_task_run(task))
goto err;
@@ -2806,50 +2811,55 @@ _disk_sync_part_table (PedDisk* disk)
if (!errnums)
goto cleanup;
- /* Attempt to remove each and every partition, retrying for
- up to max_sleep_seconds upon any failure due to EBUSY. */
- unsigned int sleep_microseconds = 10000;
- unsigned int max_sleep_seconds = 1;
- unsigned int n_sleep = (max_sleep_seconds
- * 1000000 / sleep_microseconds);
int i;
- for (i = 0; i < n_sleep; i++) {
- if (i)
- usleep (sleep_microseconds);
- bool busy = false;
- int j;
- for (j = 0; j < lpn; j++) {
- if (!ok[j]) {
- ok[j] = remove_partition (disk, j + 1);
- errnums[j] = errno;
- if (!ok[j] && errnums[j] == EBUSY)
- busy = true;
+ /* remove old partitions first */
+ for (i = 1; i <= lpn; i++) {
+ PedPartition *part = ped_disk_get_partition (disk, i);
+ if (part) {
+ unsigned long long length;
+ unsigned long long start;
+ /* get start and length of existing partition */
+ if (get_partition_start_and_length(part,
+ &start, &length)
+ && start == part->geom.start
+ && length == part->geom.length)
+ {
+ ok[i - 1] = 1;
+ continue;
+ }
}
- }
- if (!busy)
- break;
- }
-
+ }
for (i = 1; i <= lpn; i++) {
PedPartition *part = ped_disk_get_partition (disk, i);
if (part) {
- if (!ok[i - 1] && errnums[i - 1] == EBUSY) {
- unsigned long long length;
- unsigned long long start;
- /* get start and length of existing partition */
- if (!get_partition_start_and_length(part,
- &start, &length))
- goto cleanup;
- if (start == part->geom.start
- && length == part->geom.length)
- ok[i - 1] = 1;
- /* If the new partition is unchanged and the
- existing one was not removed because it was
- in use, then reset the error flag and do not
- try to add it since it is already there. */
+ unsigned long long length;
+ unsigned long long start;
+ /* get start and length of existing partition */
+ if (get_partition_start_and_length(part,
+ &start, &length)
+ && start == part->geom.start
+ && length == part->geom.length) {
+ ok[i - 1] = 1;
+ /* partition is unchanged, so nothing to do */
continue;
}
-
+ }
+ /* Attempt to remove the partition, retrying for
+ up to max_sleep_seconds upon any failure due to EBUSY. */
+ unsigned int sleep_microseconds = 10000;
+ unsigned int max_sleep_seconds = 1;
+ unsigned int n_sleep = (max_sleep_seconds
+ * 1000000 / sleep_microseconds);
+ do {
+ ok[i - 1] = remove_partition (disk, i);
+ errnums[i - 1] = errno;
+ if (ok[i - 1] || errnums[i - 1] != EBUSY)
+ break;
+ usleep (sleep_microseconds);
+ } while (n_sleep--);
+ if (!ok[i - 1] && errnums[i - 1] == ENXIO)
+ ok[i - 1] = 1; /* it already doesn't exist */
+ if (part && ok[i - 1]) {
/* add the (possibly modified or new) partition */
if (!add_partition (disk, part)) {
ok[i - 1] = 0;
--
1.8.3.2
Reply sent
to
Phillip Susi <psusi <at> ubuntu.com>
:
You have taken responsibility.
(Sun, 24 Nov 2013 03:01:03 GMT)
Full text and
rfc822 format available.
Notification sent
to
Phillip Susi <psusi <at> ubuntu.com>
:
bug acknowledged by developer.
(Sun, 24 Nov 2013 03:01:04 GMT)
Full text and
rfc822 format available.
Message #16 received at 15491-done <at> debbugs.gnu.org (full text, mbox):
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Patches pushed.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBCgAGBQJSkWu0AAoJEJrBOlT6nu75jvEH/0YAeaOBrU/ANr8yIqNyb51t
YYwS16WiiIi9MQ5dBL4pxamSWYVZWo56SwxL3VE0U3JgjuYFcQ/frc3DvLGE6Zbq
4UszohWAsBftn4N4bQJlq6sWewN3R4bbauVUfwEHv9B4KgFnyDkomELseFyNgYL9
y33ZMLEQpIKkD5JM8jL/xb48V71J8kkVU/4vLGVUT4xF5ZswCXixKDqCpjlbvhzE
e+r172v0hIkIE9VE5ZtsvyRdebjZuNRYYuQSCkh+9Vr4Xbk+erB9Uz0paApwyVV9
iNfVS0s8K0oDBpOdpYpWgRkn7+SA6SQoPR5oCSTkkE9lmUXAUfu3/f5L+J1crv0=
=gQOi
-----END PGP SIGNATURE-----
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 22 Dec 2013 12:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 11 years and 180 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.