md devices may leave remnants in /sys/class/block after removal

Bug #1682456 reported by Ryan Harper
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Confirmed
Medium
Unassigned
Xenial
Confirmed
Medium
Unassigned

Bug Description

1. root@x1:~# cat /proc/version_signature
Ubuntu 4.4.0-72.93-generic 4.4.49

2. attached

3. # lsb_release -rd
Description: Ubuntu 16.04.2 LTS
Release: 16.04

4. # apt-cache policy linux-image-`uname -r`
linux-image-4.4.0-72-generic:
  Installed: 4.4.0-72.93
  Candidate: 4.4.0-72.93
  Version table:
 *** 4.4.0-72.93 500
        500 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
        100 /var/lib/dpkg/status

5. After stopping an md device, the sysfs and /dev entry should be removed:

mdadm --stop /dev/md0 && [ "`test -e /sys/class/block/md0`" = "1" ]; echo $rc
should return 0;

6. /dev/md0 is gone, but /sys/class/block/md0 remains

I believe this is related to this thread here:

https://www.spinics.net/lists/raid/msg54859.html

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: linux-image-4.4.0-72-generic 4.4.0-72.93
ProcVersionSignature: Ubuntu 4.4.0-72.93-generic 4.4.49
Uname: Linux 4.4.0-72-generic x86_64
AlsaDevices:
 total 0
 crw-rw---- 1 root audio 116, 1 Apr 12 21:55 seq
 crw-rw---- 1 root audio 116, 33 Apr 12 21:55 timer
AplayDevices: Error: [Errno 2] No such file or directory: 'aplay'
ApportVersion: 2.20.1-0ubuntu2.5
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: Thu Apr 13 14:32:17 2017
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: QEMU Standard PC (i440FX + PIIX, 1996)
PciMultimedia:

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

ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-4.4.0-72-generic root=UUID=4c974bc3-8fe8-41b5-a563-23b2dcf974c9 ro console=tty1 console=ttyS0
RelatedPackageVersions:
 linux-restricted-modules-4.4.0-72-generic N/A
 linux-backports-modules-4.4.0-72-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-1ubuntu2
dmi.chassis.type: 1
dmi.chassis.vendor: QEMU
dmi.chassis.version: pc-i440fx-yakkety
dmi.modalias: dmi:bvnSeaBIOS:bvrUbuntu-1.8.2-1ubuntu2:bd04/01/2014:svnQEMU:pnStandardPC(i440FX+PIIX,1996):pvrpc-i440fx-yakkety:cvnQEMU:ct1:cvrpc-i440fx-yakkety:
dmi.product.name: Standard PC (i440FX + PIIX, 1996)
dmi.product.version: pc-i440fx-yakkety
dmi.sys.vendor: QEMU

Revision history for this message
Ryan Harper (raharper) 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
Revision history for this message
Ryan Harper (raharper) wrote :

After partitioning two disks with two 1G partitions each, then this script will create two RAID1 devices (md0, md1) to test mdadm --stop commands

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

I run this script to watch whether the sysfs md structure goes away after stopping the device.

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

To recreate:

1. partition two disks sized the same into two equal partitions (2G disk, two 1G partitions each)

# cat /proc/partitions
major minor #blocks name

 252 32 2097152 vdc
 252 33 1048576 vdc1
 252 34 1047552 vdc2
 252 48 2097152 vdd
 252 49 1048576 vdd1
 252 50 1047552 vdd2

2. sudo apt install mdadm --no-install-recommends

3. sudo bash -x ./create-mirror.sh

4. cat /proc/mdstat # check that the array's are resyncing

5. sudo mdadm --stop /dev/md1

6. test -e /sys/class/block/md1

If the arrays completely resync before attempting --stop; we don't see the failure;
however, if a resync is present then stopping md0 or md1 will succeed but
/sys/class/block/mdX/* contains files even if /dev/mdX is not present.

Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

Please try Linux kernel at http://people.canonical.com/~khfeng/lp1682456/

I cherry-picked two commits into Xenial kernel:
3fe7292f621a4fc9a52aff3a61dde21f24317810 md: fix refcount problem on mddev when stopping array.
a841891c56826e6086a8a24ed9c036b71d023d75 md: changes for MD_STILL_CLOSED flag

Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

Uh I pasted the commits in reverse order, but you get the idea...

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

I tested with the updated kernel and unfortunately, it does not resolve the issue. Since these are recently uncovered issues upstream, could you cherry pick those against the Zesty kernel? Once we know it's resolved in the latest kernel we can track down what changes needed for Xenial.

Changed in linux (Ubuntu):
importance: Undecided → Medium
Changed in linux (Ubuntu Xenial):
importance: Undecided → Medium
status: New → Confirmed
tags: added: kernel-da-key
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.