Linux 4.4.0: wrong value for /sys/*/queue/discard_granularity

Bug #1576451 reported by Steve Langasek
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Fedora)
Fix Released
Undecided
linux (Ubuntu)
Triaged
Medium
Unassigned

Bug Description

With kernel 4.4.0-21.37 in xenial and yakkety, the value of queue/discard_granularity is set to '1' instead of to a multiple of the block size as expected.

$ cat /sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda/queue/discard_granularity
1
$

This is at odds with the values on ramdisks:
$ cat /sys/devices/virtual/block/ram0/queue/discard_granularity
4096
$

And with lvm2 2.02.150-1ubuntu1, currently in yakkety-proposed, this always results in an error message from lvremove if discard is configured, and discard is not actually used; e.g., from my schroot output:

E: 05lvm: WARNING: Device /dev/sda7: queue/discard_granularity is 1 and is unexpectedly less than sector.

This bug has also been reported against Linux 4.4 in Fedora.
https://bugzilla.redhat.com/show_bug.cgi?id=1314687

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: linux-image-4.4.0-21-generic 4.4.0-21.37
ProcVersionSignature: Ubuntu 4.4.0-21.37-generic 4.4.6
Uname: Linux 4.4.0-21-generic x86_64
ApportVersion: 2.20.1-0ubuntu2
Architecture: amd64
AudioDevicesInUse:
 USER PID ACCESS COMMAND
 /dev/snd/controlC1: vorlon 3681 F.... pulseaudio
 /dev/snd/pcmC0D0p: vorlon 3681 F...m pulseaudio
 /dev/snd/controlC0: vorlon 3681 F.... pulseaudio
CurrentDesktop: Unity
Date: Thu Apr 28 16:39:54 2016
HibernationDevice: RESUME=UUID=6df76279-19ea-45a4-bec9-e4fdc858729a
InstallationDate: Installed on 2010-09-24 (2043 days ago)
InstallationMedia: Ubuntu 10.04.1 LTS "Lucid Lynx" - Release amd64 (20100816.1)
MachineType: LENOVO 2306CTO
ProcFB: 0 inteldrmfb
ProcKernelCmdLine: BOOT_IMAGE=/vmlinuz-4.4.0-21-generic root=/dev/mapper/hostname-root ro quiet splash vt.handoff=7
RelatedPackageVersions:
 linux-restricted-modules-4.4.0-21-generic N/A
 linux-backports-modules-4.4.0-21-generic N/A
 linux-firmware 1.157
SourcePackage: linux
UpgradeStatus: Upgraded to xenial on 2016-04-15 (13 days ago)
dmi.bios.date: 10/25/2013
dmi.bios.vendor: LENOVO
dmi.bios.version: G2ET97WW (2.57 )
dmi.board.asset.tag: Not Available
dmi.board.name: 2306CTO
dmi.board.vendor: LENOVO
dmi.board.version: Not Defined
dmi.chassis.asset.tag: No Asset Information
dmi.chassis.type: 10
dmi.chassis.vendor: LENOVO
dmi.chassis.version: Not Available
dmi.modalias: dmi:bvnLENOVO:bvrG2ET97WW(2.57):bd10/25/2013:svnLENOVO:pn2306CTO:pvrThinkPadX230:rvnLENOVO:rn2306CTO:rvrNotDefined:cvnLENOVO:ct10:cvrNotAvailable:
dmi.product.name: 2306CTO
dmi.product.version: ThinkPad X230
dmi.sys.vendor: LENOVO

Revision history for this message
In , Till (till-redhat-bugs) wrote :

Description of problem:
See bug 1313377

Instead of reporting 4096, the kernel reports 1 for
cat /sys/dev/block/8:0/queue/discard_granularity

Version-Release number of selected component (if applicable):
4.4.2-301.fc23.x86_64
4.4.3-300.fc23.x86_64

Not affected: 4.3.5-300.fc23.x86_64

Additional info:
This makes lvremove not discard logical volumes, since it assumes that the granularity is always bigger or equal to 512 for devices supporting discard/trim.

Revision history for this message
In , Mike (mike-redhat-bugs) wrote :
Revision history for this message
In , Mike (mike-redhat-bugs) wrote :

Can you confirm whether or not your underlying SCSI device supports LBPRZ?

Please report what you have in: /sys/block/<scsi_dev_name>/queue/discard_zeroes_data

Revision history for this message
In , Till (till-redhat-bugs) wrote :

$ cat /sys/block/sda/queue/discard_zeroes_data
1

Does this meant that LBPRZ is supported? What does LBPRZ mean? Is it something like Read Zero After Trim (RZAT)?

Revision history for this message
In , Scott (scott-redhat-bugs) wrote :

I use Debian but this has happened to me also. Their kernel 4.3.3-7
correctly reports 512 as the discard_granularity (although, my understanding
is that the hardware actually has 8k erase blocks), while kernel 4.4.6-1
reports discard_granularity 1. This then causes the device-mapper to report:

 discard granularity unexpectedly less than sector size

According to the vendor data sheet, the device does in fact zero discarded
blocks. This concurs with /sys/block/sda/queue/discard_zeroes_data on
my device ('1').

Model Family: Intel X18-M/X25-M/X25-V G2 SSDs
Device Model: INTEL SSDSA2M160G2GC
...
Firmware Version: 2CV102M3
User Capacity: 160,041,885,696 bytes [160 GB]
Sector Size: 512 bytes logical/physical
Rotation Rate: Solid State Device
...
ATA Version is: ATA/ATAPI-7 T13/1532D revision 1
SATA Version is: SATA 2.6, 3.0 Gb/s
...

I cannot seem to find the data sheet now, but I remember looking for it before
when determining if I needed to overwrite the blocks or not to sanitize it.

Revision history for this message
Steve Langasek (vorlon) wrote :
Revision history for this message
Brad Figg (brad-figg) wrote : Status changed to Confirmed

This change was made by a bot.

Changed in linux (Ubuntu):
status: New → Confirmed
Changed in linux (Ubuntu):
importance: Undecided → Medium
tags: added: kernel-da-key
Changed in linux (Ubuntu):
status: Confirmed → Triaged
Revision history for this message
In , Laura (laura-redhat-bugs) wrote :

*********** MASS BUG UPDATE **************

We apologize for the inconvenience. There is a large number of bugs to go through and several of them have gone stale. Due to this, we are doing a mass bug update across all of the Fedora 23 kernel bugs.

Fedora 23 has now been rebased to 4.7.4-100.fc23. Please test this kernel update (or newer) and let us know if you issue has been resolved or if it is still present with the newer kernel.

If you have moved on to Fedora 24 or 25, and are still experiencing this issue, please change the version to Fedora 24 or 25.

If you experience different issues, please open a new bug report for those.

Revision history for this message
In , Till (till-redhat-bugs) wrote :

kernel 4.7.4-100.fc23.x86_64 reports 512, thank you for fixing it:
$ cat /sys/dev/block/8:0/queue/discard_granularity
512

Changed in linux (Fedora):
importance: Unknown → Undecided
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.