[systemd-devel] udev removing and re-adding partition /dev entries after read-write open close of whole disk device

Mike Fleetwood mike.fleetwood at googlemail.com
Fri Mar 18 17:43:58 UTC 2016


Hi,

I've noticed that since approximately udev version 219, opening a whole
disk device entry read-write, then closing it triggers udev to remove
and re-create all the partition /dev entries.

Because of this GParted (graphical disk partitioning and file system
manipulation tool) is sometimes failing.  Before each change GParted is
using libparted to re-read the partition table, which ends up triggering
udev to re-create the partition /dev entries.  Then GParted may go on to
run a file system specific command such as an fsck, resize or similar on
/dev/PTN.  However this command sometimes fails reporting the /dev/PTN
does not exist because udev is still in the middle of removing and
re-adding the required /dev entry.

Below is [1] a very simple test program and [2] an example failure.

So that I can correctly make GParted handle this behaviour on existing
distributions can you tell me what version introduced this behaviour
(commit(s) would be great) and why?  Also I assume that GParted should
run "udevadm settle" to wait for the /dev partition entries to be
re-created.

Thanks,
Mike

[1] test program
/* gcc -o c-test-0005 c-test-0005.c */

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(void)
{
    int fd = open("/dev/sdc", O_RDWR);
    close(fd);

    char * const cmd[] = {"e2fsck", "-f", "-y", "-v", "-C", "0",
"/dev/sdc3", NULL};
    execvp("e2fsck", cmd);
    return EXIT_SUCCESS;
}

[2] example failure
# udevadm monitor &
...
# c-test-0005
KERNEL[8995.600483] remove
/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/sdc1
(block)
e2fsck 1.42.9 (28-Dec-2013)
KERNEL[8995.606149] remove
/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/sdc2
(block)
KERNEL[8995.606498] remove
/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/sdc3
(block)
e2fsck: No such file or directory while trying to open /dev/sdc3
Possibly non-existent device?
KERNEL[8995.609880] change
/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc
(block)
KERNEL[8995.610850] add
/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/sdc1
(block)
KERNEL[8995.611091] add
/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/sdc2
(block)
KERNEL[8995.614083] add
/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/sdc3
(block)
UDEV  [8995.631253] remove
/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/sdc2
(block)
UDEV  [8995.638997] remove
/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/sdc1
(block)
UDEV  [8995.642246] remove
/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/sdc3
(block)
UDEV  [8995.687918] change
/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc
(block)
UDEV  [8995.726753] add
/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/sdc3
(block)
UDEV  [8995.749604] add
/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/sdc2
(block)
UDEV  [8995.773355] add
/devices/pci0000:00/0000:00:0d.0/ata5/host4/target4:0:0/4:0:0:0/block/sdc/sdc1
(block)


More information about the systemd-devel mailing list