[PATCH] linux: add wait time and retries to kernel partition reread

Curtis Gedak gedakc at gmail.com
Fri Jan 29 23:17:21 UTC 2010


Occasionally when using parted with newer GNU/Linux kernels (2.6.31)
and udev (145), the kernel would fail to reread the partition table.
This could lead to problems with subsequent actions such as formatting
the partition.

Basically this patch increases the retry_count, and adds one sleep(1)
function call prior to the the last few ioctl() calls.

This patch might not be a perfect solution to this problem of "failure
to inform kernel of partition changes", but it does significantly
reduce the likelihood of encountering the problem.

Details on the testing results and procedures used can be found at
the following link:
https://bugzilla.gnome.org/show_bug.cgi?id=604298#c9

* libparted/arch/linux.c (_kernel_reread_part_table): add time and retries
---
 libparted/arch/linux.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index f3b54f0..2b0cee0 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2516,12 +2516,14 @@ static int
 _kernel_reread_part_table (PedDevice* dev)
 {
         LinuxSpecific*  arch_specific = LINUX_SPECIFIC (dev);
-        int             retry_count = 5;
+        int             retry_count = 9;
 
         sync();
         while (ioctl (arch_specific->fd, BLKRRPART)) {
                 retry_count--;
                 sync();
+                if (retry_count == 3)
+                        sleep(1); /* Pause to allow system to settle */
                 if (!retry_count) {
                         ped_exception_throw (
                                 PED_EXCEPTION_WARNING,
-- 
1.6.6


--------------060108010202040704030703--



More information about the parted-devel mailing list