zfsonlinux/zfs — Issue #440: EBUSY on /dev/zfs for replace
Author: bill-mcgonigle
Created: 2011-11-07 23:04:33+00:00
State: open

zpool is getting EBUSY on /dev/zfs when I try to replace a disk. The new disk isn't actually in use and I've rebooted a few times and zeroed out the disk.

```config:

NAME STATE READ WRITE CKSUM
storage DEGRADED 0 0 0
mirror-0 DEGRADED 0 0 0
10094699726010659595 UNAVAIL 0 0 0 was /dev/sdd1
sdg ONLINE 0 0 0
logs
mirror-1 ONLINE 0 0 0
sdi1 ONLINE 0 0 0
sdf1 ONLINE 0 0 0
cache
sdh1 ONLINE 0 0 0
```

```
[root@librescu ~]# strace zpool replace storage 10094699726010659595 sde 2>&1| egrep '(sde|sdg|= 4|ioctl)'
....
open("/dev/zfs", O_RDWR) = 4
ioctl(4, 0x5a04, 0x7fffe5a0b430) = 0
ioctl(4, 0x5a12, 0x7fffe5a0b430) = 0
ioctl(4, 0x5a05, 0x7fffe5a06e10) = 0
ioctl(4, 0x5a14, 0x7fffe5a0b400) = 0
ioctl(4, 0x5a14, 0x7fffe5a06e00) = -1 ESRCH (No such process)
ioctl(4, 0x5a2a, 0x7fffe5a03c70) = 0
ioctl(4, 0x5a14, 0x7fffe5a0b400) = -1 ESRCH (No such process)
ioctl(4, 0x5a12, 0x7fffe5a0b430) = 0
ioctl(4, 0x5a05, 0x7fffe5a06e10) = 0
ioctl(4, 0x5a14, 0x7fffe5a0b400) = 0
ioctl(4, 0x5a14, 0x7fffe5a0b400) = 0
ioctl(4, 0x5a14, 0x7fffe5a0b400) = -1 ENOMEM (Cannot allocate memory)
ioctl(4, 0x5a14, 0x7fffe5a0b400) = 0
ioctl(4, 0x5a14, 0x7fffe5a0b400) = 0
ioctl(4, 0x5a14, 0x7fffe5a0b400) = 0
ioctl(4, 0x5a14, 0x7fffe5a06e00) = -1 ESRCH (No such process)
ioctl(4, 0x5a2a, 0x7fffe5a03c70) = 0
ioctl(4, 0x5a14, 0x7fffe5a0b400) = -1 ENOMEM (Cannot allocate memory)
ioctl(4, 0x5a14, 0x7fffe5a0b400) = 0
ioctl(4, 0x5a14, 0x7fffe5a0b400) = 0
ioctl(4, 0x5a14, 0x7fffe5a0b400) = 0
ioctl(4, 0x5a14, 0x7fffe5a0b400) = 0
ioctl(4, 0x5a14, 0x7fffe5a0b400) = 0
ioctl(4, 0x5a14, 0x7fffe5a0b400) = -1 ESRCH (No such process)
open("/proc/filesystems", O_RDONLY) = 4
open("/usr/lib/locale/locale-archive", O_RDONLY) = 4
open("/proc/modules", O_RDONLY) = 4
open("/dev/zfs", O_RDWR) = 4
ioctl(4, 0x5a05, 0x7fffe5a07340) = 0
access("/dev/sde", F_OK) = 0
open("/dev/sde", O_RDWR|O_EXCL|O_DIRECT) = 7
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000398934016) = 0
readlink("/proc/self", "8083", 4095) = 4
readlink("/proc/8083/fd/7", "/dev/sde", 4095) = 8
lstat("/dev/sde", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 64), ...}) = 0
open("/dev/sdes0", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)
open("/dev/sde", O_RDWR|O_EXCL|O_DIRECT) = 7
readlink("/proc/self", "8083", 4095) = 4
readlink("/proc/8083/fd/7", "/dev/sde", 4095) = 8
lstat("/dev/sde", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 64), ...}) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000398934016) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000398934016) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000398934016) = 0
stat("/dev/sde1", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 65), ...}) = 0
open("/dev/sde1", O_RDONLY) = 9
stat("/dev/sde9", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 73), ...}) = 0
open("/dev/sde9", O_RDONLY) = 9
lstat("/dev/sde", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 64), ...}) = 0
ioctl(4, 0x5a2a, 0x7fffe5a01b10) = 0
readlink("/proc/self", "8083", 4095) = 4
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 3000591450112) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 3000591450112) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 3000591450112) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 3000591450112) = 0
open("/dev/sdg1", O_RDWR|O_DIRECT) = 7
readlink("/proc/self", "8083", 4095) = 4
readlink("/proc/8083/fd/7", "/dev/sdg1", 4095) = 9
lstat("/dev/sdg1", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 97), ...}) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000389479936) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000389479936) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000389479936) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000389479936) = 0
open("/dev/sde", O_RDWR|O_DIRECT) = 7
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000398934016) = 0
readlink("/proc/self", "8083", 4095) = 4
readlink("/proc/8083/fd/7", "/dev/sde", 4095) = 8
lstat("/dev/sde", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 64), ...}) = 0
readlink("/proc/self", "8083", 4095) = 4
readlink("/proc/8083/fd/7", "/dev/sde", 4095) = 8
lstat("/dev/sde", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 64), ...}) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000398934016) = 0
ioctl(7, BLKFLSBUF, 0) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000398934016) = 0
ioctl(7, BLKFLSBUF, 0) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000398934016) = 0
ioctl(7, BLKFLSBUF, 0) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000398934016) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000398934016) = 0
ioctl(7, BLKFLSBUF, 0) = 0
ioctl(7, BLKRRPART, 0x3920195238) = 0
stat("/dev/sde1", {st_mode=S_IFBLK|0600, st_rdev=makedev(8, 65), ...}) = 0
open("/dev/sde", O_RDWR|O_DIRECT) = 7
readlink("/proc/self", "8083", 4095) = 4
readlink("/proc/8083/fd/7", "/dev/sde", 4095) = 8
lstat("/dev/sde", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 64), ...}) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000398934016) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000398934016) = 0
ioctl(7, BLKSSZGET, 512) = 0
ioctl(7, BLKGETSIZE64, 2000398934016) = 0
stat("/dev/sde1", {st_mode=S_IFBLK|0600, st_rdev=makedev(8, 65), ...}) = 0
open("/dev/sde1", O_WRONLY|O_EXCL) = 7
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 4096
ioctl(4, 0x5a0e, 0x7fffe5a06f70) = -1 EBUSY (Device or resource busy)
write(2, "cannot replace 10094699726010659"..., 58cannot replace 10094699726010659595 with sde: sde is busy
```
similar for trying to attach:

```
[root@librescu ~]# strace zpool attach storage sdg sde 2>&1| egrep '(sde|sdg|= 4|ioctl)'

stat("/dev/sde1", {st_mode=S_IFBLK|0600, st_rdev=makedev(8, 65), ...}) = 0
open("/dev/sde1", O_WRONLY|O_EXCL) = 7
write(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 4096
access("/dev/sdg", F_OK) = 0
ioctl(4, 0x5a0e, 0x7fff8c13d8f0) = -1 EBUSY (Device or resource busy)
write(2, "cannot attach sde to sdg: sde is"..., 38cannot attach sde to sdg: sde is busy
```

spl-0.6.0-rc6.x86_64
spl-modules-0.6.0-rc6_2.6.40_4.fc15.x86_64
spl-modules-devel-0.6.0-rc5_2.6.40_4.fc15.x86_64
zfs-0.6.0-rc6.x86_64
zfs-devel-0.6.0-rc6.x86_64
zfs-dracut-0.6.0-rc6.x86_64
zfs-modules-0.6.0-rc6_2.6.40_4.fc15.x86_64
zfs-modules-devel-0.6.0-rc6_2.6.40_4.fc15.x86_64
zfs-test-0.6.0-rc6.x86_64