]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit - drivers/scsi/sd.c
scsi: sd: Keep disk read-only when re-reading partition
authorJeremy Cline <jeremy@jcline.org>
Tue, 6 Mar 2018 21:47:32 +0000 (21:47 +0000)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 14 Aug 2018 10:29:15 +0000 (12:29 +0200)
commitcf244122a3fad97d196e577fab59863433d03601
treefe1ffdb6482e7d1489a6522b6a960f39c6c6826d
parentbe1ff848608a5ce7073ea09b0454fab401c534b0
scsi: sd: Keep disk read-only when re-reading partition

BugLink: http://bugs.launchpad.net/bugs/1783418
[ Upstream commit 20bd1d026aacc5399464f8328f305985c493cde3 ]

If the read-only flag is true on a SCSI disk, re-reading the partition
table sets the flag back to false.

To observe this bug, you can run:

1. blockdev --setro /dev/sda
2. blockdev --rereadpt /dev/sda
3. blockdev --getro /dev/sda

This commit reads the disk's old state and combines it with the device
disk-reported state rather than unconditionally marking it as RW.

Reported-by: Li Ning <lining916740672@icloud.com>
Signed-off-by: Jeremy Cline <jeremy@jcline.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/scsi/sd.c