[parted-devel] Possible Race Condition using test code, libparted, and Fedora 12

Curtis Gedak gedakc at gmail.com
Thu Feb 18 19:07:26 UTC 2010


Jim Meyering wrote:
> Curtis Gedak wrote:
>   
>> This is a heads up that the work around I implemented in GParted code,
>> which is similar to the parted patch I posted earlier, does not always
>> work.
>>
>> One user of GParted has reported this "failure to inform kernel of
>> partition changes" problem in the GParted bug tracker:
>> https://bugzilla.gnome.org/show_bug.cgi?id=608712
>>     
>
> Thanks for letting us know.
> I was hoping to look at that today, but will defer it, now.
> Besides, I've just noticed that upstream parted's "make check"
> is now failing two root-run tests on rawhide.
>   

Hi Jim,

This patch is ready for your review.  Perhaps you might consider 
including this patch in the parted-2.2 release.

The bug report listed above appears to be a problem with LVM, and not 
with the similar work around code in GParted.   Also I have not received 
any more reports of problems with the work around code.

I have re-based the patch to the latest parted git repository and posted 
the patch in-line.

Regards,
Curtis Gedak


 From 87d0f3c51ee301b0a0b9534dd902cf4a1bbed0c4 Mon Sep 17 00:00:00 2001
From: Curtis Gedak <gedakc at gmail.com>
Date: Fri, 29 Jan 2010 16:17:21 -0700
Subject: [PATCH] linux: add wait time and retries to kernel partition reread

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





More information about the parted-devel mailing list