Bug 2149790

Summary: [PATCH] block: Do not reread partition table on exclusively open device
Product: Red Hat Enterprise Linux 9 Reporter: Ming Lei <minlei>
Component: kernelAssignee: Ming Lei <minlei>
kernel sub component: Block Layer QA Contact: ChanghuiZhong <czhong>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: czhong, jmoyer
Version: 9.2Keywords: Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: kernel-5.14.0-225.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2151112 (view as bug list) Environment:
Last Closed: 2023-05-09 08:09:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2151112    

Description Ming Lei 2022-11-30 23:37:57 UTC
Description of problem:

https://lore.kernel.org/linux-block/20221130175653.24299-1-jack@suse.cz/

Subject: [PATCH] block: Do not reread partition table on exclusively open device
Date: Wed, 30 Nov 2022 18:56:53 +0100	[thread overview]
Message-ID: <20221130175653.24299-1-jack> (raw)

Since commit 10c70d95c0f2 ("block: remove the bd_openers checks in
blk_drop_partitions") we allow rereading of partition table although
there are users of the block device. This has an undesirable consequence
that e.g. if sda and sdb are assembled to a RAID1 device md0 with
partitions, BLKRRPART ioctl on sda will rescan partition table and
create sda1 device. This partition device under a raid device confuses
some programs (such as libstorage-ng used for initial partitioning for
distribution installation) leading to failures.

Fix the problem refusing to rescan partitions if there is another user
that has the block device exclusively open.

Link: https://lore.kernel.org/all/20221130135344.2ul4cyfstfs3znxg@quack3
Fixes: 10c70d95c0f2 ("block: remove the bd_openers checks in blk_drop_partitions")
Signed-off-by: Jan Kara <jack>

Comment 1 Ming Lei 2022-11-30 23:41:07 UTC
The actual report link:

https://lore.kernel.org/linux-block/20221130135344.2ul4cyfstfs3znxg@quack3/

Comment 4 ChanghuiZhong 2022-12-19 10:17:04 UTC
reproduce this is on 5.14.0-205.el9.x86_64,

mdadm -CR /dev/md0 -l 1 -n 2 /dev/sda /dev/sdb -e 1.0
sgdisk -n 0:0:+100MiB /dev/md0
cat /proc/partitions
mdadm -S /dev/md0
mdadm -A /dev/md0 /dev/sda /dev/sdb
cat /proc/partitions


# cat /proc/partitions 
major minor  #blocks  name

   8        0  468851544 sda
   8        1     102400 sda1
   8       16  468851544 sdb
   8       17     102400 sdb1
   8       48  468851544 sdd
   8       32  468851544 sdc
   8       33    1048576 sdc1
   8       34  467801088 sdc2
 253        0   73400320 dm-0
 253        1    8077312 dm-1
 253        2  386322432 dm-2
   9        0  468851392 md0
 259        0     102400 md0p1
# lsblk
NAME                         MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
sda                            8:0    0 447.1G  0 disk  
├─sda1                         8:1    0   100M  0 part  
└─md0                          9:0    0 447.1G  0 raid1 
  └─md0p1                    259:0    0   100M  0 part  
sdb                            8:16   0 447.1G  0 disk  
├─sdb1                         8:17   0   100M  0 part  
└─md0                          9:0    0 447.1G  0 raid1 
  └─md0p1                    259:0    0   100M  0 part  
sdc                            8:32   0 447.1G  0 disk  
├─sdc1                         8:33   0     1G  0 part  /boot
└─sdc2                         8:34   0 446.1G  0 part  
  ├─rhel_storageqe--103-root 253:0    0    70G  0 lvm   /
  ├─rhel_storageqe--103-swap 253:1    0   7.7G  0 lvm   [SWAP]
  └─rhel_storageqe--103-home 253:2    0 368.4G  0 lvm   /home
sdd                            8:48   0 447.1G  0 disk  
 


can not reproduce this issue on test kernel  5.14.0-206.mr1740_714212637.el9

Comment 8 ChanghuiZhong 2022-12-27 03:19:37 UTC
this issue no longer be triggered on kernel-5.14.0-225.el9,
https://beaker.engineering.redhat.com/recipes/13153324#task154341708

fix patch has been applied to kernel tree,
move to verified

Comment 10 errata-xmlrpc 2023-05-09 08:09:03 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: kernel security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:2458