[parted-devel] Possible Race Condition using test code, libparted, and Fedora 12
Curtis Gedak
gedakc at gmail.com
Tue Feb 2 19:37:25 UTC 2010
After checking my previous mailing list post, it appears that the
attachment was stripped off.
Thus I am posting it 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