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

Curtis Gedak gedakc at gmail.com
Sat Jan 16 17:16:12 UTC 2010


Recently I have made a significant discovery regarding this problem of 
"failure to inform kernel of partition changes" on newer GNU/Linux 
distributions.

The likelihood of the problem occurring can be greatly reduced if a 
pause is inserted before retrying a failed call to ioctl().

I have used this logic as a work around in the GParted source code.  You 
can read about the GParted change at the following link:
https://bugzilla.gnome.org/show_bug.cgi?id=604298#c20


Inspired by this discovery, I am testing a similar change to the 
_kernel_reread_part_table() function in libparted/arch/linux.c.  The 
diff for the change can be found at the end of this email.

For the test I am using fedora 12 with parted-1.9.0-14.  The source code 
for parted-1.9.0-14 is available at:
http://koji.fedoraproject.org/koji/buildinfo?buildID=129982

The source code was configured with:
$ ./configure --without-readline --disable-device-mapper

Current I am running the test as follows:
$ ./test-partition-resize.sh /dev/sdb 99999

With this number of iterations, I anticipate the test to take several 
days before successful conclusion.  I will report back here with my 
findings.

Regards,
Curtis Gedak


The following diff output was generated with the command:
$ diff -c libparted/arch/linux.c libparted/arch/linux.c.new

*** libparted/arch/linux.c    2009-12-05 12:23:21.000000000 -0700
--- libparted/arch/linux.c.new    2010-01-16 08:24:55.000000000 -0700
***************
*** 2407,2413 ****
  _kernel_reread_part_table (PedDevice* dev)
  {
          LinuxSpecific*  arch_specific = LINUX_SPECIFIC (dev);
!         int             retry_count = 5;
 
          sync();
          while (ioctl (arch_specific->fd, BLKRRPART)) {
--- 2407,2413 ----
  _kernel_reread_part_table (PedDevice* dev)
  {
          LinuxSpecific*  arch_specific = LINUX_SPECIFIC (dev);
!         int             retry_count = 10;
 
          sync();
          while (ioctl (arch_specific->fd, BLKRRPART)) {
***************
*** 2425,2430 ****
--- 2425,2433 ----
                                  dev->path, strerror (errno), dev->path);
                          return 0;
                  }
+                 /* Pause occasionally to allow system to settle */
+                 if (retry_count % 5 == 0)
+                         sleep(1);
          }
 
          return 1;




More information about the parted-devel mailing list