Hi,

piorunz wrote:
> CD inserted:
> $ lsblk -b -o VENDOR,MODEL,SIZE,PHY-SEC,LOG-SEC /dev/sr0
> VENDOR   MODEL               SIZE PHY-SEC LOG-SEC
> hp       hp_DVDRW_GUE1N 627656704    2048    2048
> DVD inserted:
> $ lsblk -b -o VENDOR,MODEL,SIZE,PHY-SEC,LOG-SEC /dev/sr0
> VENDOR   MODEL                SIZE PHY-SEC LOG-SEC
> hp       hp_DVDRW_GUE1N 3353346048    2048    2048

So we know that the kernel-perceived block size is correctly 2048 when
a medium is inserted. Do the complaints continue to appear in the logs
while the medium is loaded ?

The remaining question is what the kernel perceives after the system
has booted and no medium was inserted since then. And for completeness,
what the kernel perceives when the tray is empty after the running system
already saw a medium in it

(I'll give my own answers to that question further below.)


> I noticed it when DVD disc was loading and until it did, lsblk was happily
> reporting that 627656704 bytes CD is still there for every userspace app to
> use and send queries to.

The problem is actually that the size does not get set to 0 when the medium
gets unloaded. (Further bug: Blank media get attributed size 2048.)

In preparation of a fix, Karel Zak of util-linux changed lsblk so that it
would report devices of SIZE 0. But after getting no feedback on other bug
fix patches for Linux, i did not submit my fix for the size problem to the
kernel developers.
Back in september 2020 it would have consisted of four patches:
  cdrom: introduce new exported function cdrom_disc_information()
  sr: introduce resetter functions for sr_cd_check() and get_sectorsize()
  sr: attribute size 0 to "empty" (aka blank) media
  sr: attribute size 0 to not loaded or unusable media


> And queries are being sent, my guess is from file
> manager, to query and display CD name etc. if there is one, because it
> thinks everything is fine and its okay to ask.

That's my suspicion too.

I now am baffled by the result on a Debian 11 with drives not used since
booting it:

  $ lsblk -b -o VENDOR,MODEL,SIZE,PHY-SEC,LOG-SEC /dev/sr*
  VENDOR   MODEL                       SIZE PHY-SEC LOG-SEC
  PIONEER  PIONEER_BD-RW_BDR-S09 1073741312     512     512
  TSSTcorp CDDVDW_SH-S223B       1073741312     512     512

The first one is a built-in SATA drive, the second is SATA in a USB box.
All are perceived with wrong block size and a fictional capacity of
1 GiB - 512 bytes.
I'd say that this is some clueless default setting that must be new since
kernel 4.19 of Debian 10. Back in 2020 i would quite surely have noticed
if that behavior had been shown.

  $ uname -a
  Linux ... 5.10.0-13-amd64 #1 SMP Debian 5.10.106-1 (2022-03-17) x86_64 
GNU/Linux

Are users of Debian 10 (actually of kernel 4.19) here who are willing to
run
  lsblk -b -o VENDOR,MODEL,SIZE,PHY-SEC,LOG-SEC /dev/sr*
directly after booting with empty drive tray ?


Whatever, when i let a DVD+RW wander through the drives and then put it
back on the shelf, i afterwards get the usual outdated capacity and the
correct block size:

  VENDOR   MODEL                       SIZE PHY-SEC LOG-SEC
  PIONEER  PIONEER_BD-RW_BDR-S09 4700372992    2048    2048
  TSSTcorp CDDVDW_SH-S223B       4700372992    2048    2048

>From now on the system seems to behave like i am used from older Debian
versions. Wrong but reliable.

I know of no way to bring the capacity perception to 0. But the size can
be reduced to 2048 bytes by inserting a blank CD-R, CD-RW, DVD-R, DVD+R,
or unformatted blank DVD-RW or BD-R medium. A totally unused BD-RE or
DVD+RW might do the trick too (do not allow a burn program to format them).

Here i used a blank BD-R on the Pioneer and a blank DVD-R on the Samsung:

  VENDOR   MODEL                  SIZE PHY-SEC LOG-SEC
  PIONEER  PIONEER_BD-RW_BDR-S09  2048    2048    2048
  TSSTcorp CDDVDW_SH-S223B        2048    2048    2048

This state remains when the medium is removed until the next medium is
inserted and fully assessed by the drive.

The drive groping software on your machine seems to want to read more than
just a single block of 2048 bytes. So reducing the perceived size to 2048
by inserting a blank medium once after booting might already do the trick.


(I wonder why the "VENDOR" name gets prepended to the actual "MODEL" name
with the Pioneer drive and probably the HP one of piorunz but not to the
Samsung drive CDDVDW_SH-S223B.
I know that the Pioneer identifies its model name as "BD-RW BDR-S09",
not as "PIONEER BD-RW BDR-S09".)


Have a nice day :)

Thomas

Reply via email to