Bug 872831

Summary: wipefs error: /dev/sda: probing initialization failed: Device or resource busy
Product: [Fedora] Fedora Reporter: Richard W.M. Jones <rjones>
Component: util-linuxAssignee: Karel Zak <kzak>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: jonathan, kzak, mluscon, satellitgo
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-03 14:24:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Richard W.M. Jones 2012-11-03 17:14:18 UTC
Description of problem:

We use wipefs as part of the libguestfs tests, and I've noticed
two (related) changes recently.  One is not a bug, the other
seems to be a bug.

First change: You can no longer wipe a mounted filesystem, eg:
 mount /dev/sda1 /foo
 wipefs -a /dev/sda1
fails with:
 /dev/sda1: probing initialization failed: Device or resource busy

That is obviously NOT a bug.  You don't want to be able to
wipe a filesystem which the kernel has mounted.

However a second error looks like it is a bug:

 wipefs -a /dev/sda
 /dev/sda: probing initialization failed: Device or resource busy

In this second case, /dev/sda contains partitions, but nothing is
mounted.  Obviously I want to erase the partitions which is the
whole point of running wipefs(!)

Version-Release number of selected component (if applicable):

util-linux.x86_64 0:2.22.1-3.fc19
(for other packages, see:
http://kojipkgs.fedoraproject.org//work/tasks/1830/4651830/root.log)

How reproducible:

100%

Steps to Reproduce:
1. Run the libguestfs tests on Rawhide.

Additional info:

Example of the second failure:
http://kojipkgs.fedoraproject.org//work/tasks/1830/4651830/build.log

Comment 1 Richard W.M. Jones 2012-11-03 18:29:55 UTC
This worked with util-linux 2.22.1-1.fc19 & coreutils 8.17.
It was when I upgraded to util-linux 2.22.1-3 & coreutils 8.20
that it breaks.

Comment 2 Richard W.M. Jones 2012-11-19 15:42:26 UTC
Patch posted to add --force option:
http://article.gmane.org/gmane.linux.utilities.util-linux-ng/6801

Comment 3 Richard W.M. Jones 2012-11-19 15:45:43 UTC
Here is the libguestfs patch that this was tested alongside:
https://www.redhat.com/archives/libguestfs/2012-November/msg00028.html

Comment 4 Karel Zak 2012-11-20 13:47:41 UTC
(In reply to comment #0)
> However a second error looks like it is a bug:
> 
>  wipefs -a /dev/sda
>  /dev/sda: probing initialization failed: Device or resource busy
> 
> In this second case, /dev/sda contains partitions, but nothing is
> mounted. 

I have doubts that nothing is mounted... partitioned device, 
nothing mounted:

  # strace -e open ./wipefs --no-act -a /dev/sdb 2>&1 | grep sdb
  open("/dev/sdb", O_RDWR|O_EXCL)         = 3

  success!

partitioned device, sdb1 mounted:

  # mount /dev/sdb1 /mnt/test

  # strace -e open ./wipefs --no-act -a /dev/sdb 2>&1 | grep sdb
  open("/dev/sdb", O_RDWR|O_EXCL)         = -1 EBUSY (Device or resource busy)

it means that partition table has no impact to O_EXCL, the problem is if any partition is mounted.

It all seems like correct and expected ... I think we don't want to allow to delete partition table if any partition is actively used.

Comment 5 Richard W.M. Jones 2012-11-20 14:53:18 UTC
Continued on list at:
http://article.gmane.org/gmane.linux.utilities.util-linux-ng/6806

Since the --force patch has been added to wipefs and it
appears to work, I'm closing the bug as fixed, but would
appreciate it if the patch could be added to F18 also
to make the virt-format tool work.

Comment 6 Karel Zak 2012-11-22 10:40:25 UTC
Fixed by upstream commit 2968c3fc7388f88b8debe64d61d9785601c16436.