My PC has two Optical Disc Drives (ODDs). I burn file (3.8 G) to two ODDs at the same time.
- On CentOS 6.9 Linux Kernel 2.6.32, it takes about 10 minutes
- On CentOS 7.2 Linux Kernel 3.10.0, it takes about 16 minutes
I checked the system log and found that only one command can be running at the same time.
That means send ATAPI commands to ODD1 and ODD2 at the same time. They are not executed in parallel.
I checked Linux Kernel Drivers sr.c sr_block_ioctl()
.
They added mutex_lock
at Linux kernel 2.6.36.
I found this makes ATAPI commands not execute in parallel.
I added debug log to dump the &sr_mutex
, and I found the two ODDs use the same mutex key...sr_mutex
is a global variable in sr.c
(static DEFINE_MUTEX(sr_mutex);)
On the other hand, I found sd.c
does not use a lock at ioctl
in Linux kernel last version...
Questions:
Why do the two ODD driver use the same global variable?
Why add
mutex_lock
here? ODD may need 2~3 seconds to complete a command.