Bug 387384 - Rewritable media is not cleared on burn
Summary: Rewritable media is not cleared on burn
Status: RESOLVED DUPLICATE of bug 381074
Alias: None
Product: k3b
Classification: Applications
Component: Burning/Hardware (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: k3b developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-28 08:21 UTC by Luigi Baldoni
Modified: 2018-04-18 15:21 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
dvd+rw-mediainfo and dvd+rw-format log (1.51 KB, text/plain)
2017-12-01 09:45 UTC, Luigi Baldoni
Details
stuck k3b burn prompt (94.12 KB, image/jpeg)
2017-12-01 09:45 UTC, Luigi Baldoni
Details
screenshot K3b asking for suitable medium on Arch Linux (70.89 KB, image/png)
2017-12-01 17:37 UTC, Patrick Silva
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Luigi Baldoni 2017-11-28 08:21:04 UTC
Using latest stable (17.08.3) on openSUSE linux.
A new DVD-RW or BD-RE is written regularly, but then k3b refuses to clear it the next time claiming there is no empty medium in the drive.

Same hardware works with Brasero.
Comment 1 Leslie Zhai 2017-12-01 03:17:24 UTC
Hi Thomas, Call for help!

Hi Aloysius, I can not reproduce the issue by simulator - CDEmu, please attach some log or screenshot?

Regards,
Leslie Zhai
Comment 2 Leslie Zhai 2017-12-01 03:18:10 UTC
> Same hardware works with Brasero

Please use Brasero for hurry requirement firstly.
Comment 3 Thomas Schmitt 2017-12-01 08:44:13 UTC
Hi,

it would also be interesting to see whether the DVD-RW medium is formatted.
BD-RE media are always formatted, but DVD-RW can be used unformatted and
then need a blanking run to get re-usable.
Formatted media can be overwritten without precautions. One just has to
convince the burn program that one does not want to keep the old content.

-------------------------------------------------------------------------
Questions to Aloysius:

So what do you get from the shell command

  dvd+rw-mediainfo /dev/sr0

when the DVD-RW is inserted and the tray already loaded ?

Do you get any user prompt to decide about overwriting of BD-RE:
  "Found BD-RE medium in [...burner name...] Should it be overwritten?"

Does K3B work better with your DVD-RW if you format it by this shell command ?

  dvd+rw-format /dev/sr0

(If it is already formatted it will refuse. That would be ok then.)

-------------------------------------------------------------------------
Code inspection:

Strangely, libk3b/jobs/k3bblankingjob.cpp only talks of CD-RW, not of
DVD-RW media. CD-RW and unformatted DVD-RW are the only media types
which need real SCSI blanking.

The handling of used media is probably in src/k3bemptydiscwaiter.cpp
function K3b::EmptyDiscWaiter::slotMediumChanged().
For BD-RE it does:
  // check if the media contains a filesystem
If it finds an ISO 9660 filesystem (with or without UDF parasite filesystem)
then it is supposed to ask by
  KMessageBox::warningContinueCancel( parentWidgetToUse(),
                  i18n("Found %1 medium in %2 - %3. Should it be overwritten?",

This happens only if the medium is perceived in state Device::STATE_EMPTY.
If the BD-RE is not perceived as STATE_EMPTY then it seems that an add-on
ISO 9660 session will get appended to the medium.

I still have to find out how K3B perceives BD-RE writability state. On
hardware level there are only two states: unformatted and formatted.
The CD states "empty/blank", "appendable", and "closed" do not apply to
formatted media.


Now for DVD-RW.
slotMediumChanged() has:
    // DVD-RW in sequential mode can be empty. DVD-RW in restricted overwrite mode is always complete.
(The obscure names "seq. incr." and "restr. ovw." mean unformatted and
 formatted, repectively.)

Formatted DVD-RW with an ISO 9660 filesystem should cause a user prompt
like with BD-RE:
   i18n("Found %1 medium in %2 - %3. "
        "Should it be overwritten?",

I see no code path which would cause blanking of an unformatted DVD-RW.

-------------------------------------------------------------------------

Have a nice day :)

Thomas
Comment 4 Leslie Zhai 2017-12-01 09:19:53 UTC
Hi Thomas,

Thanks for your kind response!

> libk3b/jobs/k3bblankingjob.cpp

https://github.com/KDE/k3b/commits/master/libk3b/jobs/k3bblankingjob.cpp

The latest git commit:

commit 3fbe112ed24676fb65bb40d2c3f82b44b6fcd806
Author: Pino Toscano <pino@debian.org>
Date:   Sun Feb 15 20:21:05 2015 +0100

    i18n fixes
    
    - spell "CD-Text", "CDDB", "ISO 9660", "MD5", "MP3", "SoX, "URL", and "WMA" correctly
    - remove extra white space in few places
    - a couple of small changes



Hi Aloysius, Could you add some qDebug to Basic Blocks in the slotStartErasing Function? 


> src/k3bemptydiscwaiter.cpp

The latest git commit: Teach K3B learned to handle BD by Thomas Schmitt to fix BUG-381074
Perhaps we might need to teach K3B again to handle "formatted" media :)


Hi Aloysius, Could you attach some log and screenshot before reviewing the history code.

Regards,
Leslie Zhai
Comment 5 Luigi Baldoni 2017-12-01 09:45:06 UTC
Created attachment 109147 [details]
dvd+rw-mediainfo and dvd+rw-format log
Comment 6 Luigi Baldoni 2017-12-01 09:45:56 UTC
Created attachment 109148 [details]
stuck k3b burn prompt
Comment 7 Luigi Baldoni 2017-12-01 09:48:46 UTC
(In reply to Thomas Schmitt from comment #3)
>
> Questions to Aloysius:
> 
> So what do you get from the shell command
> 
>   dvd+rw-mediainfo /dev/sr0
> 
> when the DVD-RW is inserted and the tray already loaded ?

See attached log.

> Do you get any user prompt to decide about overwriting of BD-RE:
>   "Found BD-RE medium in [...burner name...] Should it be overwritten?"

Nope, no prompt at all. I might add this hasn't worked for at least a
couple of years for me, even with a standard dvd burner.
Apparently the problems started after ditching the old 2.03 qt4 k3b.

> Does K3B work better with your DVD-RW if you format it by this shell command
> ?
> 
>   dvd+rw-format /dev/sr0
> 
> (If it is already formatted it will refuse. That would be ok then.)

See attachment. Unless you actually want me to go through with the
full format.

Regards
Comment 8 Luigi Baldoni 2017-12-01 10:48:43 UTC
(In reply to Leslie Zhai from comment #4)
> Hi Aloysius, Could you add some qDebug to Basic Blocks in the
> slotStartErasing Function? 

I tried, but nothing came out, so I'm afraid I'll have
to ask you to be more specific.

> The latest git commit: Teach K3B learned to handle BD by Thomas Schmitt to
> fix BUG-381074
> Perhaps we might need to teach K3B again to handle "formatted" media :)
 
I backported this:

> -    return K3b::Device::MEDIA_WRITABLE_DVD;
> +    return K3b::Device::MEDIA_WRITABLE_DVD | K3b::Device::MEDIA_WRITABLE_BD;
Comment 9 Thomas Schmitt 2017-12-01 11:11:06 UTC
Hi,

i wrote:
> > dvd+rw-mediainfo /dev/sr0 when the DVD-RW is inserted 

Aloysius wrote:
> See attached log.

But https://bugsfiles.kde.org/attachment.cgi?id=109147 is from a BD-RE
medium. My question was about the formatting state of the DVD-RW.

> >   dvd+rw-format /dev/sr0

> See attachment. Unless you actually want me to go through with the
> full format.

Not with BD-RE. The proposal was for DVD-RW in case that it is not
formatted. (The formatting run can last as long as a full write run
with maximum speed.)

The BD-RE is in formatted state and thus dvd+rw-format correctly did
not change it. No need to re-run with option -force.


> https://bugsfiles.kde.org/attachment.cgi?id=109148

This reminds me of the bug with image burning where K3B did not recognize
empty BD-R media for writing of media image files (data projects worked
well).

  https://bugs.kde.org/show_bug.cgi?id=381074

Decisive fix was in
  https://cgit.kde.org/k3b.git/commit/?id=329c969be1dbc3455d65925bcad32f4df3a5b428
by the two changes in K3b::Iso9660ImageWritingJob::startWriting():

  - mt = K3b::Device::MEDIA_WRITABLE_DVD;
  + mt = K3b::Device::MEDIA_WRITABLE_DVD | K3b::Device::MEDIA_WRITABLE_BD;

  - mt = K3b::Device::MEDIA_WRITABLE_DVD;
  + mt = K3b::Device::MEDIA_WRITABLE_DVD | K3b::Device::MEDIA_WRITABLE_BD;

So, Leslie and Aloysius, please find out whether Aloysius' K3B already
has this fix.

If not, then we need to explain why a first burn run on BD-RE succeeded.
Was it by chance a data project (composed from several files) rather than
an image burn run (only one file involved, typically with suffix ".iso") ?


If the fix is already applied, then my next best candidate would be in
line 268 of file jobs/k3biso9660imagewritingjob.cpp :

    Device::MediaType media = waitForMedium( m_device, K3b::Device::STATE_EMPTY, mt, K3b::imageFilesize( QUrl::fromLocalFile(m_imagePath) )/2048 );

I understand this wants medium state STATE_EMPTY whereas the BD-RE is
reported as STATE_INCOMPLETE (i assume from the word "COMPLETE" in the
screenshot).

This state is indeed reported by the drive (and complies to the SCSI specs):
  Mounted Media:         43h, BD-RE
  ...
  Disc status:           complete
But with formatted media it does not mean that one could not write an
image to the medium beginning at block 0.

So for a test, but not as final solution, one could change the line to

    Device::MediaType media = waitForMedium( m_device, 
               K3b::Device::STATE_EMPTY | K3b::Device::STATE_COMPLETE,
               K3b::imageFilesize( QUrl::fromLocalFile(m_imagePath) )/2048 );

and check whether it works with BD-RE and other formatted media.

In this case the first burn would have worked because the BD-RE was not
yet formatted and thus STATE_EMPTY.

As final solution, one would have to make K3B smarter, so that it takes
into respect the purpose of the job and the formatting state of the medium.
E.g. that it takes STATE_COMPLETE as alias of STATE_EMPTY if the medium
is DVD-RAM, DVD+RW, or BD-RE and shall be written from scratch.

Possibly we can learn from the data project code.

---------------------------------------------------------------------

The DVD-RW problem cannot stem from bug 381074.
But if the cause for the BD-RE problem is the missing acceptance for
STATE_COMPLETE, then this would also apply to formatted DVD-RW:

  Mounted Media:         13h, DVD-RW Restricted Overwrite
  ...
  Disc status:           complete


Have a nice day :)

Thomas
Comment 10 Luigi Baldoni 2017-12-01 11:48:45 UTC
(In reply to Thomas Schmitt from comment #9)
>
> i wrote:
> > > dvd+rw-mediainfo /dev/sr0 when the DVD-RW is inserted 
> 
> Aloysius wrote:
> > See attached log.
> 
> But https://bugsfiles.kde.org/attachment.cgi?id=109147 is from a BD-RE
> medium. My question was about the formatting state of the DVD-RW.
> 
> > >   dvd+rw-format /dev/sr0
> 
> > See attachment. Unless you actually want me to go through with the
> > full format.
> 
> Not with BD-RE. The proposal was for DVD-RW in case that it is not
> formatted. (The formatting run can last as long as a full write run
> with maximum speed.)
> 
> The BD-RE is in formatted state and thus dvd+rw-format correctly did
> not change it. No need to re-run with option -force.

I'm sorry, I have to amend my complaint.
DVD-RW rewriting works correctly on 17.08.03.

> > https://bugsfiles.kde.org/attachment.cgi?id=109148
> 
> This reminds me of the bug with image burning where K3B did not recognize
> empty BD-R media for writing of media image files (data projects worked
> well).
> 
>   https://bugs.kde.org/show_bug.cgi?id=381074
> 
> Decisive fix was in
>  
> https://cgit.kde.org/k3b.git/commit/
> ?id=329c969be1dbc3455d65925bcad32f4df3a5b428
> by the two changes in K3b::Iso9660ImageWritingJob::startWriting():
> 
>   - mt = K3b::Device::MEDIA_WRITABLE_DVD;
>   + mt = K3b::Device::MEDIA_WRITABLE_DVD | K3b::Device::MEDIA_WRITABLE_BD;
> 
>   - mt = K3b::Device::MEDIA_WRITABLE_DVD;
>   + mt = K3b::Device::MEDIA_WRITABLE_DVD | K3b::Device::MEDIA_WRITABLE_BD;
> 

Adding this definitely fixed the problem, thank you very much.

Is that all that is required in case one wanted to backport the fix to 17.08 and 17.04 ?

Regards.
Comment 11 Luigi Baldoni 2017-12-01 11:51:11 UTC
Addendum: the only fly in the ointment is that the "overwrite" prompt appears twice.
But perhaps that's for another report:)
Comment 12 Thomas Schmitt 2017-12-01 12:09:23 UTC
Hi,

i wrote:
> >   - mt = K3b::Device::MEDIA_WRITABLE_DVD;
> >   + mt = K3b::Device::MEDIA_WRITABLE_DVD | K3b::Device::MEDIA_WRITABLE_BD;
> > 
> >   - mt = K3b::Device::MEDIA_WRITABLE_DVD;
> >   + mt = K3b::Device::MEDIA_WRITABLE_DVD | K3b::Device::MEDIA_WRITABLE_BD;

Aloysius wrote:
> Adding this definitely fixed the problem, thank you very much.

So this is really a duplicate of bug 381074.
Quite a surprise to me.

But it matches my confusion about the way how the data project job would
cope with formatted media. It requests STATE_EMPTY and not STATE_COMPLETE.
So the proposed intelligence seems to be already present and i am not
smart enough to recognize it.
Well, next time ...

Have a nice day :)

Thomas
Comment 13 Thomas Schmitt 2017-12-01 12:23:59 UTC
Hi,

Aloysius wrote:
> Is that all that is required in case one wanted to backport the fix to 17.08
> and 17.04 ?

Good question. That bug report has a long discussion ...

We have the two occurences in
  https://cgit.kde.org/k3b.git/commit/?id=329c969be1dbc3455d65925bcad32f4df3a5b428
which i already proposed and you already implemented.

Then there is the one in
  https://cgit.kde.org/k3b.git/commit/?id=a359173975e574c4cae62214f7de28648d14167c
for function K3b::Device::MediaTypes K3b::VideoDvdDoc::supportedMediaTypes().
(We did not test this one. Blu-ray movie is an adventure on its own.)

All other code changes in these two commits are about debugging only
and supposed to have been removed meanwhile.

Have a nice day :)

Thomas
Comment 14 Patrick Silva 2017-12-01 17:37:55 UTC
Created attachment 109159 [details]
screenshot K3b asking for suitable medium on Arch Linux

On Arch Linux sometimes K3b asks for a "suitable medium" even when an empty cd-rw is already inserted.
Is this situation related to the problem described here?
Unfortunately I know no specific steps to reproduce.
Comment 15 Luigi Baldoni 2017-12-01 18:11:37 UTC

*** This bug has been marked as a duplicate of bug 381074 ***
Comment 16 Thomas Schmitt 2017-12-01 18:19:58 UTC
Hi,

Dr. Chapatin wrote:
> On Arch Linux sometimes K3b asks for a "suitable medium" even when an empty
> cd-rw is already inserted.
> Is this situation related to the problem described here?

The bug fixed here is only about BD media. So: no.

Your screenshot shows a text "Searching for old ses" which i assume is
the start of "Searching for old session".
The small window says to have found an "Empty CD-RW medium".
Such a CD-RW cannot bear an old session to be found and loaded for
appending a new session based on the old one.

Is it possible that you checked "Continue multisession" in the "Settings"
tab of the "Data Project" dialog. The web has screenshots like
  https://www.granneman.com/files/2713/1493/5335/k3b-Data-Project-Burn-Settings.gif

I expect "No multisession" to demand an empty medium and to close it
after writing, whereas "Start multisession" expects an empty medium too
but will not close it and thus enable "Continue multisession" for
this medium for further sessions. The medium for "Continue multisession"
must be classified by K3B as "Incomplete" (or "Complete" if it's formatted).

Have a nice day :)

Thomas
Comment 17 Patrick Silva 2017-12-01 18:59:46 UTC
Thanks for your reply Thomas.
You are right, I get the result shown in my screenshot when I try to burn a "continue multissesion project" using an empty disc.
K3b should prevent this situation and/or show a better warning when it occurs.
Maybe "Actual disc is not multisession. Insert a suitable medium to continue."
Comment 18 Thomas Schmitt 2017-12-01 19:37:13 UTC
Hi,

Dr. Chapatin wrote:
> K3b should prevent this situation and/or show a better warning when it
> occurs.

At least the little window should not hide parts of the text which tells
which kind of medium is expected.

(I see that i forgot to mention that "Finish multisession" would expect
 an "Incomplete" medium and finally convert it into a "Complete" medium.)

Have a nice day :)

Thomas