2002-03-17 01:44:23

by dean gaudet

[permalink] [raw]
Subject: /dev/md0: Device or resource busy

i'm using 2.4.19-pre3-ac1 (on debian woody) and i was playing with md. it
appears impossible to "raidstop /dev/md0" when i'm using the 0xfd
autodetect partition type.

i have 3 other md devices which i can stop no problem (even with 0xfd
autodetection), just not /dev/md0.

% raidstop /dev/md0
/dev/md0: Device or resource busy

i don't have any filesystem mounted on md0, and "lsof | grep md" doesn't
show anything.

% dmesg | grep md0
md: created md0
md0: max total readahead window set to 124k
md0: 1 data-disks, max readahead per data-disk: 124k
raid1: raid set md0 active with 2 out of 2 mirrors
md: updating md0 RAID superblock on device
md: md0 still in use.

if i change the partition type to 0xda (is there something more
appropriate?), and let /etc/init.d/raid2 do the "raidstart /dev/md0" then
i can raidstop /dev/md0 no problem.

is there maybe a reference counting problem when 0xfd is in use?

note that my other md partitions are all 0xfd ... and i can raidstop them
just fine. (although i have to do it in a particular order since /dev/md3
is a stripe of /dev/md{1,2}, which are mirrors. /dev/md1 happens to be
other partitions on the same disks as /dev/md0.)

-dean


2002-03-17 03:10:58

by Alan

[permalink] [raw]
Subject: Re: /dev/md0: Device or resource busy

> i have 3 other md devices which i can stop no problem (even with 0xfd
> autodetection), just not /dev/md0.
>
> % raidstop /dev/md0
> /dev/md0: Device or resource busy
>
> i don't have any filesystem mounted on md0, and "lsof | grep md" doesn't
> show anything.

lsof isnt always the most reliable to tools if a kernel thread or nfs
ran off with it. Is md0 doing anything else - like rebuilding. Is there
anything that has been triggered or run from it - paticularly kernel
threads

2002-03-17 03:18:20

by dean gaudet

[permalink] [raw]
Subject: Re: /dev/md0: Device or resource busy

On Sun, 17 Mar 2002, Alan Cox wrote:

> > i have 3 other md devices which i can stop no problem (even with 0xfd
> > autodetection), just not /dev/md0.
> >
> > % raidstop /dev/md0
> > /dev/md0: Device or resource busy
> >
> > i don't have any filesystem mounted on md0, and "lsof | grep md" doesn't
> > show anything.
>
> lsof isnt always the most reliable to tools if a kernel thread or nfs
> ran off with it. Is md0 doing anything else - like rebuilding. Is there
> anything that has been triggered or run from it - paticularly kernel
> threads

nothing that i'm aware of -- i've never put these devices into fstab. i
disabled smartsuite because it was holding /dev/hdN open, but that didn't
change anything.

i just tried a "linux init=/bin/sh" boot, and it's still saying Device or
resource busy:

init-2.05a# raidstop /dev/md0
md: md0 still in use.
/dev/md0: Device or resource busy
init-2.05a# mount /proc
init-2.05a# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1]
read_ahead 1024 sectors
md0 : active raid1 hdi1[1] hde1[0]
131392 blocks [2/2] [UU]

md1 : active raid1 hdi2[1] hde2[0]
78045824 blocks [2/2] [UU]

md2 : active raid1 hdk1[1] hdg1[0]
78177344 blocks [2/2] [UU]

unused devices: <none>
init-2.05a# ps auxww
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 6.9 0.1 2312 1284 ? S 11:11 0:07 init
root 2 0.0 0.0 0 0 ? SW 11:11 0:00 [keventd]
root 3 0.0 0.0 0 0 ? SWN 11:11 0:00 [ksoftirqd_CPU0]
root 4 0.0 0.0 0 0 ? SWN 11:11 0:00 [ksoftirqd_CPU1]
root 5 0.0 0.0 0 0 ? SW 11:11 0:00 [kswapd]
root 6 0.0 0.0 0 0 ? SW 11:11 0:00 [bdflush]
root 7 0.0 0.0 0 0 ? SW 11:11 0:00 [kupdated]
root 8 0.0 0.0 0 0 ? SW 11:11 0:00 [mdrecoveryd]
root 9 0.0 0.0 0 0 ? SW 11:11 0:00 [raid1d]
root 10 0.0 0.0 0 0 ? SW 11:11 0:00 [raid1d]
root 11 0.0 0.0 0 0 ? SW 11:11 0:00 [raid1d]
root 16 0.0 0.0 2600 792 ? R 11:13 0:00 ps auxww

-dean

2002-03-17 03:22:19

by Robert A. Hayden

[permalink] [raw]
Subject: Re: /dev/md0: Device or resource busy

Alan et al,

I have this happen quite frequently as well, and only on /dev/md0. I end up
having to reboot to single user to work with it in these situations. The
other md devices (two others) stop and start just fine.

> lsof isnt always the most reliable to tools if a kernel thread or nfs
> ran off with it. Is md0 doing anything else - like rebuilding. Is there
> anything that has been triggered or run from it - paticularly kernel
> threads


2002-03-17 03:26:29

by Alan

[permalink] [raw]
Subject: Re: /dev/md0: Device or resource busy

> i just tried a "linux init=/bin/sh" boot, and it's still saying Device or
> resource busy:
>
> init-2.05a# raidstop /dev/md0
> md: md0 still in use.
> /dev/md0: Device or resource busy
> init-2.05a# mount /proc

Duplicated. Seems the md code deos indeed have a bug there

2002-03-17 03:43:50

by dean gaudet

[permalink] [raw]
Subject: Re: /dev/md0: Device or resource busy

On Sun, 17 Mar 2002, Alan Cox wrote:

> > i just tried a "linux init=/bin/sh" boot, and it's still saying Device or
> > resource busy:
> >
> > init-2.05a# raidstop /dev/md0
> > md: md0 still in use.
> > /dev/md0: Device or resource busy
> > init-2.05a# mount /proc
>
> Duplicated. Seems the md code deos indeed have a bug there

ACK! sorry. it's not the kernel code, it's raidstop. it seems to open
/dev/md0 an extra time for what reason i'm not sure. it even does it when
you're referring to other md devices. for example:

# strace raidstop /dev/md3
...
open("/dev/md0", O_RDONLY) = 4
ioctl(4, 0x800c0910, 0x804fd1c) = 0
open("/dev/md3", O_RDWR) = 5
fstat64(5, {st_mode=S_IFBLK|0660, st_rdev=makedev(9, 3), ...}) = 0
ioctl(5, 0x932, 0) = 0
...

mdctl doesn't have this problem.

fwiw dpkg tells me i've got raidtools 0.90.20010914-9

-dean

2002-03-17 12:29:15

by Eric Lammerts

[permalink] [raw]
Subject: Re: /dev/md0: Device or resource busy


On Sat, 16 Mar 2002, dean gaudet wrote:
> ACK! sorry. it's not the kernel code, it's raidstop. it seems to open
> /dev/md0 an extra time for what reason i'm not sure. it even does it when
> you're referring to other md devices. for example:

It does this for checking the md driver version. For some reason, the
close() was commented out. I alerted the Debian maintainer about this
a few days ago.

> fwiw dpkg tells me i've got raidtools 0.90.20010914-9

It's fixed in 0.90.20010914-11.

Eric