Subject: partprobe does not wait for refresh of partition info

From: Bjoern Eberth <[email-masked]>
Date: Sun, 16 Aug 2015 01:22:15 +0200

Hi all,

As the web bugtracker seems to be broken I write this mail.

I'm using parted 3.2. All this was tested running a Debian jessie release
within a virtual machine on Windows 8.1 using VMware Workstation 11.
/dev/sdb is an USB cardreader physically connected to the Windows 8.1
machine and looped to the virtual machine.

I was executing a script that does 'partprobe /dev/sdb' and immediatly
after that 'dd of=/dev/sdb1 if=<something>'. The result is, that I get a
regular file /dev/sdb1.

After some more investigation I found, that after executing partprobe the
partition files got removed and readded to the system.
So running the script:
root@debian:~# cat /tmp/test
partprobe /dev/sdb
while true; do
        ls -lad /dev/sdb1
done

results in:

root@debian:~# /tmp/test
brw------- 1 root root 8, 17 Aug 15 16:39 /dev/sdb1
ls: cannot access /dev/sdb1: No such file or directory
ls: cannot access /dev/sdb1: No such file or directory
ls: cannot access /dev/sdb1: No such file or directory
ls: cannot access /dev/sdb1: No such file or directory
ls: cannot access /dev/sdb1: No such file or directory
brw------- 1 root root 8, 17 Aug 15 16:39 /dev/sdb1
brw------- 1 root root 8, 17 Aug 15 16:39 /dev/sdb1
brw------- 1 root root 8, 17 Aug 15 16:39 /dev/sdb1
[...]
brw-rw---- 1 root disk 8, 17 Aug 15 16:39 /dev/sdb1
brw-rw---- 1 root disk 8, 17 Aug 15 16:39 /dev/sdb1
brw-rw---- 1 root disk 8, 17 Aug 15 16:39 /dev/sdb1^C

All the above is happing in way less then a second after executing
partprobe.
Thats a really odd behaviour.

Then I downgraded parted to version 2.2 and ran the test script again:
root@debian:~# /tmp/test
brw------- 1 root root 8, 17 Aug 15 14:38 /dev/sdb1
brw------- 1 root root 8, 17 Aug 15 14:38 /dev/sdb1
brw------- 1 root root 8, 17 Aug 15 14:38 /dev/sdb1
brw------- 1 root root 8, 17 Aug 15 14:38 /dev/sdb1
brw------- 1 root root 8, 17 Aug 15 14:38 /dev/sdb1
brw------- 1 root root 8, 17 Aug 15 14:38 /dev/sdb1
brw------- 1 root root 8, 17 Aug 15 14:38 /dev/sdb1
[...]
brw-rw---- 1 root disk 8, 17 Aug 15 16:39 /dev/sdb1
brw-rw---- 1 root disk 8, 17 Aug 15 16:39 /dev/sdb1
brw-rw---- 1 root disk 8, 17 Aug 15 16:39 /dev/sdb1^C

This looks rather fine to me.

Is this a bug? Or is partprobe 3.2 just running much faster than partprobe
2.2 giving the kernel no time to reread the partition table? Or something
else?

Kind regards,
Bjoern