Subject: bug#42796: partprobe doesn't reload partition information for loop devices when invoked with no options

From: "Szuberski, Damian (Nokia - HU/Budapest)" <[email-masked]>
Date: Mon, 10 Aug 2020 08:27:07 +0000

Hello parted developers!

I hope you're well. Steps to reproduce the bug I just found

# script start
(zpool destroy rootPool1 ; losetup -D ; rm -rf disk* ) &> /dev/null

set -xe

uname -a
partprobe --version
zpool --version

fallocate -l 3G disk1
sgdisk -Z -n1:1M:+1023M -t1:8300 disk1 &> /dev/null
losetup -Pf disk1

lsblk /dev/loop0
sgdisk -p /dev/loop0

zpool create -R /mnt rootPool1 /dev/loop0p1

sgdisk -d1 -n1:1M:+2G -t1:8300 /dev/loop0 &> /dev/null
echo "CORRECT REPORT HERE (2G)"
sgdisk -p /dev/loop0
partprobe

echo "INCORRECT REPORT HERE (1G)"
lsblk /dev/loop0

echo "CORRECT REPORT HERE (2G)"
partprobe /dev/loop0
lsblk /dev/loop0
# script end

# output begin
+ uname -a
Linux damian 5.7.0-2-cloud-amd64 #1 SMP Debian 5.7.10-1 (2020-07-26) x86_64 GNU/Linux
+ partprobe --version
partprobe (GNU parted) 3.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by <http://git.debian.org/?p=parted/parted.git;a=blob_plain;f=AUTHORS>.
+ zpool --version
zfs-0.8.4-2
zfs-kmod-0.8.4-2
+ fallocate -l 3G disk1
+ sgdisk -Z -n1:1M:+1023M -t1:8300 disk1
+ losetup -Pf disk1
+ lsblk /dev/loop0
NAME      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0       7:0    0    3G  0 loop
└─loop0p1 259:0    0 1023M  0 part
+ sgdisk -p /dev/loop0
Disk /dev/loop0: 6291456 sectors, 3.0 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 190FB977-371C-4C2C-A180-EB55E188B8E2
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 6291422
Partitions will be aligned on 2048-sector boundaries
Total free space is 4196285 sectors (2.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         2097151   1023.0 MiB  8300
+ zpool create -R /mnt rootPool1 /dev/loop0p1
+ sgdisk -d1 -n1:1M:+2G -t1:8300 /dev/loop0
+ echo 'CORRECT REPORT HERE (2G)'
CORRECT REPORT HERE (2G)
+ sgdisk -p /dev/loop0
Disk /dev/loop0: 6291456 sectors, 3.0 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 190FB977-371C-4C2C-A180-EB55E188B8E2
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 6291422
Partitions will be aligned on 2048-sector boundaries
Total free space is 2097085 sectors (1024.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         4196351   2.0 GiB     8300
+ partprobe
+ echo 'INCORRECT REPORT HERE (1G)'
INCORRECT REPORT HERE (1G)
+ lsblk /dev/loop0
NAME      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0       7:0    0    3G  0 loop
└─loop0p1 259:0    0 1023M  0 part
+ echo 'CORRECT REPORT HERE (2G)'
CORRECT REPORT HERE (2G)
+ partprobe /dev/loop0
+ lsblk /dev/loop0
NAME      MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0       7:0    0   3G  0 loop
└─loop0p1 259:0    0   2G  0 part
# output end

-- 
Damian Szuberski