bcache device numbers increase by 16

Bug #1667078 reported by Ryan Harper
16
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Fix Released
Medium
Stefan Bader

Bug Description

On 4.10 kernel, when creating bcache devices, each device kname is now incremented by 16

/dev/bcache0
/dev/bcache16
/dev/bcache32

etc.

This was to support partitioning of bcache devices[1], however, This also will limit the number of bcache devices and doesn't match how other block devices name themselves, md for example, you get md0p1, md1p1, md2p1 etc.

Ideally we'd continue to see devices increment by 1, and ensure we allocate partition numbers as well.

I think the patch[1] below is incomplete; I think we also want to shift the minor value by the number of partitions when we set the disk_name value.

drivers/md/bcache/super.c:

   snprintf(d->disk->disk_name, DISK_NAME_LEN, "bcache%i", minor);

to

   snprintf(d->disk->disk_name, DISK_NAME_LEN, "bcache%i", minor >> 4);

This should keep the devname index based, while creating the device node with
the appropriate space for partitions, like this:

$ ls -al /dev/bcache*
brw-rw---- 1 root disk 251, 0 Feb 22 17:40 /dev/bcache0
brw-rw---- 1 root disk 251, 1 Feb 22 17:40 /dev/bcache0p1
brw-rw---- 1 root disk 251, 16 Feb 22 17:40 /dev/bcache1
brw-rw---- 1 root disk 251, 17 Feb 22 17:40 /dev/bcache1p1

1. https://www.spinics.net/lists/linux-bcache/msg04267.html

ProblemType: Bug
DistroRelease: Ubuntu 17.04
Package: linux-image-4.10.0-8-generic 4.10.0-8.10
ProcVersionSignature: User Name 4.10.0-8.10-generic 4.10.0-rc8
Uname: Linux 4.10.0-8-generic x86_64
AlsaDevices:
 total 0
 crw-rw---- 1 root audio 116, 1 Feb 22 17:36 seq
 crw-rw---- 1 root audio 116, 33 Feb 22 17:36 timer
AplayDevices: Error: [Errno 2] No such file or directory: 'aplay'
ApportVersion: 2.20.4-0ubuntu2
Architecture: amd64
ArecordDevices: Error: [Errno 2] No such file or directory: 'arecord'
AudioDevicesInUse: Error: command ['fuser', '-v', '/dev/snd/seq', '/dev/snd/timer'] failed with exit code 1:
CRDA: N/A
Date: Wed Feb 22 17:41:18 2017
Ec2AMI: ami-0000056c
Ec2AMIManifest: FIXME
Ec2AvailabilityZone: nova
Ec2InstanceType: m1.small
Ec2Kernel: unavailable
Ec2Ramdisk: unavailable
IwConfig: Error: [Errno 2] No such file or directory: 'iwconfig'
Lsusb: Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
MachineType: OpenStack Foundation OpenStack Nova
PciMultimedia:

ProcEnviron:
 TERM=xterm
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
ProcFB:

ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-4.10.0-8-generic root=UUID=15278dff-350d-42a1-8767-1424dfca7894 ro console=tty1 console=ttyS0
RelatedPackageVersions:
 linux-restricted-modules-4.10.0-8-generic N/A
 linux-backports-modules-4.10.0-8-generic N/A
 linux-firmware N/A
RfKill: Error: [Errno 2] No such file or directory: 'rfkill'
SourcePackage: linux
UpgradeStatus: No upgrade log present (probably fresh install)
dmi.bios.date: 04/01/2014
dmi.bios.vendor: SeaBIOS
dmi.bios.version: Ubuntu-1.8.2-1ubuntu1
dmi.chassis.type: 1
dmi.chassis.vendor: QEMU
dmi.chassis.version: pc-i440fx-xenial
dmi.modalias: dmi:bvnSeaBIOS:bvrUbuntu-1.8.2-1ubuntu1:bd04/01/2014:svnOpenStackFoundation:pnOpenStackNova:pvr13.1.2:cvnQEMU:ct1:cvrpc-i440fx-xenial:
dmi.product.name: OpenStack Nova
dmi.product.version: 13.1.2
dmi.sys.vendor: OpenStack Foundation

Revision history for this message
Ryan Harper (raharper) wrote :
tags: added: curtin
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
Revision history for this message
Joseph Salisbury (jsalisbury) wrote :

It doesn't look like that patch ever landed in mainline. Do you plan on responding to the upstream thread with your recommendation?

Changed in linux (Ubuntu):
importance: Undecided → Medium
tags: added: kernel-da-key
Revision history for this message
Ryan Harper (raharper) wrote : Re: [Bug 1667078] Re: bcache device numbers increase by 16

On Fri, Feb 24, 2017 at 10:39 AM, Joseph Salisbury <
<email address hidden>> wrote:

> It doesn't look like that patch ever landed in mainline. Do you plan on
> responding to the upstream thread with your recommendation?
>

It's an untested change; I've not pushed anything upstream.
If time permits, I'd recompile a kernel with the change and test out that
we get index increments and don't break partitioning.

Revision history for this message
Stefan Bader (smb) wrote :

The partitioning support is a 4.10 change, so changes are high they did not yet see the implications. The change might move into the right direction but certainly should not use a hard-coded shift. The number of minors is a define so more something like (minor / BCACHE_MINORS).

Stefan Bader (smb)
Changed in linux (Ubuntu):
assignee: nobody → Stefan Bader (smb)
Revision history for this message
Stefan Bader (smb) wrote :

I created a modified patch and verified that
- bcache base devices again are numbered 0,1,...
- partioning a bcache device creates the expected bcacheXpY devices
Will submit this change upstream (and for pre-stable zesty).

tags: added: patch
Revision history for this message
Ryan Harper (raharper) wrote :

On Thu, Mar 2, 2017 at 4:56 AM, Stefan Bader <email address hidden>
wrote:

> I created a modified patch and verified that
> - bcache base devices again are numbered 0,1,...
> - partioning a bcache device creates the expected bcacheXpY devices
> Will submit this change upstream (and for pre-stable zesty).
>
> ** Patch added: "0001-bcache-Fix-bcache-device-names.patch"
> https://bugs.launchpad.net/ubuntu/+source/linux/+bug/
> 1667078/+attachment/4829714/+files/0001-bcache-Fix-bcache-
> device-names.patch
>
>
If possible, it would be good to avoid the div; that's why I had used a
shift.

In other drivers, they define a PART_BITS 4 or so
and use that to shift up or down to get index vs. minor.

> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1667078
>
> Title:
> bcache device numbers increase by 16
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/ubuntu/+source/linux/+bug/
> 1667078/+subscriptions
>

Revision history for this message
Stefan Bader (smb) wrote :

@Ryan, yeah, they did not for bcache. But this code is only executed once during the lifetime of a device. So I would not worry too much about optimization here. Might even be that gcc cleverly does this anyway. :)

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package linux - 4.10.0-13.15

---------------
linux (4.10.0-13.15) zesty; urgency=low

  [ Tim Gardner ]

  * Release Tracking Bug
    - LP: #1671614

  * ehci-platform needed in usb-modules udeb (LP: #1671589)
    - d-i: add ehci-platform to usb-modules

  * irqchip/gic-v3-its: Enable cacheable attribute Read-allocate hints
    (LP: #1671598)
    - irqchip/gic-v3-its: Enable cacheable attribute Read-allocate hints

  * iommu: Fix static checker warning in iommu_insert_device_resv_regions
    (LP: #1671599)
    - iommu: Fix static checker warning in iommu_insert_device_resv_regions

  * QDF2400: Fix panic introduced by erratum 1003 (LP: #1671602)
    - arm64: Avoid clobbering mm in erratum workaround on QDF2400

  * QDF2400 PCI ports require ACS quirk (LP: #1671601)
    - PCI: Add ACS quirk for Qualcomm QDF2400 and QDF2432

  * tty: pl011: Work around QDF2400 E44 stuck BUSY bit (LP: #1671600)
    - tty: pl011: Work around QDF2400 E44 stuck BUSY bit

  * CVE-2017-2636
    - tty: n_hdlc: get rid of racy n_hdlc.tbuf

  * Sync virtualbox to 5.1.16-dfsg-1 in zesty (LP: #1671470)
    - ubuntu: vbox -- Update to 5.1.16-dfsg-1

 -- Tim Gardner <email address hidden> Thu, 09 Mar 2017 06:16:24 -0700

Changed in linux (Ubuntu):
status: Confirmed → 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.