cfq scheduler can write parts of sequential write in reverse order
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
linux (Ubuntu) |
Expired
|
Medium
|
Unassigned |
Bug Description
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:/
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-
ProcVersionSign
Uname: Linux 4.13.0-19-generic x86_64
NonfreeKernelMo
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/
Card0.Amixer.info:
Card hw:0 'Intel'/'HDA Intel at 0xfa200000 irq 30'
Mixer name : 'Realtek ALC889A'
Components : 'HDA:10ec0885,
Controls : 63
Simple ctrls : 26
CurrentDesktop: XFCE
Date: Mon Dec 11 05:23:12 2017
HibernationDevice: RESUME=
IwConfig:
eth0 no wireless extensions.
lo no wireless extensions.
MachineType: Gigabyte Technology Co., Ltd. P35-DS3R
ProcFB:
ProcKernelCmdLine: BOOT_IMAGE=
RelatedPackageV
linux-
linux-
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:bvnAwardSof
dmi.product.name: P35-DS3R
dmi.sys.vendor: Gigabyte Technology Co., Ltd.
This change was made by a bot.