Public bug reported:

I'm opening a raw disk device (like /dev/sdb) with O_DIRECT and then
doing write() calls. The device is actually USB mass storage. Looking at
the USB packets with Wireshark, I see that the write() calls are being
split into multiple SCSI writes. That part is okay I guess. The problem
is that these writes can happen in reverse order. Suppose the write()
call is writing to sectors 100 to 200. The first SCSI write may write
150 to 200 and the second SCSI write may write 100 to 149.

Correctness does appear to be maintained. I only had a problem with
correctness because I'm abusing the protocol for writing to a hacked
digital photo frame via
https://github.com/dreamlayers/st220x/blob/master/libst2205/st2205.c .
The photo frame doesn't fully process the protocol and only looks at the
data as a series of USB packets.

However, this is bad for performance with hard disks. Surely if you have
a sequential write, the optimal way to do that write is sequentially
from start to finish. Since changing the scheduler for that block device
from cfq to noop fixes this problem, I assume it has to do with the
elevator algorithm use to optimize hard disk access. But surely such
optimization only makes sense between contiguous sequential writes, and
not for splitting up one such write.

ProblemType: Bug
DistroRelease: Ubuntu 17.10
Package: linux-image-4.13.0-19-generic 4.13.0-19.22
ProcVersionSignature: Ubuntu 4.13.0-19.22-generic 4.13.13
Uname: Linux 4.13.0-19-generic x86_64
NonfreeKernelModules: nvidia_uvm nvidia
AlsaVersion: Advanced Linux Sound Architecture Driver Version 
k4.13.0-19-generic.
ApportVersion: 2.20.7-0ubuntu3.6
Architecture: amd64
AudioDevicesInUse:
 USER        PID ACCESS COMMAND
 /dev/snd/controlC0:  bgjenero   2116 F.... pulseaudio
Card0.Amixer.info:
 Card hw:0 'Intel'/'HDA Intel at 0xfa200000 irq 30'
   Mixer name   : 'Realtek ALC889A'
   Components   : 'HDA:10ec0885,1458a002,00100101'
   Controls      : 63
   Simple ctrls  : 26
CurrentDesktop: XFCE
Date: Mon Dec 11 05:23:12 2017
HibernationDevice: RESUME=UUID=a44c3385-e1ba-4456-91ec-be27c892ff11
IwConfig:
 eth0      no wireless extensions.
 
 lo        no wireless extensions.
MachineType: Gigabyte Technology Co., Ltd. P35-DS3R
ProcFB:
 
ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-4.13.0-19-generic 
root=UUID=52543c1b-1764-4766-a504-f4b94422fa6e ro
RelatedPackageVersions:
 linux-restricted-modules-4.13.0-19-generic N/A
 linux-backports-modules-4.13.0-19-generic  N/A
 linux-firmware                             1.169.1
RfKill: Error: [Errno 2] No such file or directory: 'rfkill': 'rfkill'
SourcePackage: linux
UpgradeStatus: Upgraded to artful on 2017-09-30 (71 days ago)
dmi.bios.date: 06/19/2009
dmi.bios.vendor: Award Software International, Inc.
dmi.bios.version: F13
dmi.board.name: P35-DS3R
dmi.board.vendor: Gigabyte Technology Co., Ltd.
dmi.chassis.type: 3
dmi.chassis.vendor: Gigabyte Technology Co., Ltd.
dmi.modalias: 
dmi:bvnAwardSoftwareInternational,Inc.:bvrF13:bd06/19/2009:svnGigabyteTechnologyCo.,Ltd.:pnP35-DS3R:pvr:rvnGigabyteTechnologyCo.,Ltd.:rnP35-DS3R:rvr:cvnGigabyteTechnologyCo.,Ltd.:ct3:cvr:
dmi.product.name: P35-DS3R
dmi.sys.vendor: Gigabyte Technology Co., Ltd.

** Affects: linux (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug artful

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1737522

Title:
  cfq scheduler can write parts of sequential write in reverse order

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1737522/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to