From: "Richard W.M. Jones" <rjones@redhat.com>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH] wipefs: Add --force option
Date: Tue, 20 Nov 2012 14:41:11 +0000 [thread overview]
Message-ID: <20121120144111.GN1444@rhmail.home.annexia.org> (raw)
In-Reply-To: <20121120135246.GB2006@x2.net.home>
On Tue, Nov 20, 2012 at 02:52:46PM +0100, Karel Zak wrote:
> On Tue, Nov 20, 2012 at 12:16:34PM +0100, Karel Zak wrote:
> > On Mon, Nov 19, 2012 at 03:41:16PM +0000, Richard W.M. Jones wrote:
> > > This change adds the --force option which, when used, undoes the above
> > > flag change. However you still have to use --force most of the time
> > > when erasing something that isn't a plain unmounted filesystem.
> >
> > I'll improve the code. It's stupid disadvantage that --force is
> > necessary for things like partitions tables. We have to use
> > O_EXCL more carefully.
>
> ... it seems that this is unnecessary. It's possible to delete
> partition table (open with O_EXCL) if any of the partitions is not
> mounted. It seems that only mount(2) has any impact to O_EXCL.
>
> I guess that --force is enough.
Sorry, that was my mistake. My initial report had a simplifying
assumption that wasn't correct.
In fact the problem case is where you try to wipe a device which
contains a volume groups and a logical volume; note the LVs don't
contain filesystems, and nothing is mounted.
A simple reproducer is:
$ guestfish -N lv wipefs /dev/sda
libguestfs: error: wipefs: wipefs: error: /dev/sda: probing initialization failed: Device or resource busy
Adding -x shows what's going on:
$ guestfish -N lv wipefs /dev/sda -x
libguestfs: trace: set_pgroup true
libguestfs: trace: set_pgroup = 0
libguestfs: trace: add_drive "test1.img"
libguestfs: trace: add_drive = 0
libguestfs: trace: is_config
libguestfs: trace: is_config = 1
libguestfs: trace: launch
libguestfs: trace: get_tmpdir
libguestfs: trace: get_tmpdir = "/tmp"
libguestfs: trace: get_cachedir
libguestfs: trace: get_cachedir = "/var/tmp"
libguestfs: trace: disk_format "/home/rjones/test1.img"
libguestfs: trace: disk_format = "raw"
libguestfs: trace: get_cachedir
libguestfs: trace: get_cachedir = "/var/tmp"
libguestfs: trace: launch = 0
libguestfs: trace: part_disk "/dev/sda" "mbr"
libguestfs: trace: part_disk = 0
libguestfs: trace: pvcreate "/dev/sda1"
libguestfs: trace: pvcreate = 0
libguestfs: trace: vgcreate "VG" "/dev/sda1"
libguestfs: trace: vgcreate = 0
libguestfs: trace: lvcreate_free "LV" "VG" 100
libguestfs: trace: lvcreate_free = 0
libguestfs: trace: wipefs "/dev/sda"
libguestfs: trace: wipefs = -1 (error)
libguestfs: error: wipefs: wipefs: error: /dev/sda: probing initialization failed: Device or resource busy
libguestfs: trace: close
libguestfs: trace: internal_autosync
libguestfs: trace: internal_autosync = 0
Use -v to get more details.
I don't want to claim this is a bug, but it is certainly a change in
behaviour, and we want the --force option in libguestfs so we can say
"just do it".
By the way:
Just a partition + a PV: wipefs doesn't need to be forced.
guestfish -N part pvcreate /dev/sda1 : wipefs /dev/sda
Just a partition + a PV + a VG: wipefs doesn't need to be forced.
guestfish -N part pvcreate /dev/sda1 : vgcreate VG /dev/sda1 : wipefs /dev/sda
Partition + PV + VG + LV (but no filesystem): wipefs needs --force.
[for example see above]
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming blog: http://rwmj.wordpress.com
Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
next prev parent reply other threads:[~2012-11-20 14:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-19 15:41 [PATCH] wipefs: Add --force option Richard W.M. Jones
2012-11-20 11:16 ` Karel Zak
2012-11-20 13:52 ` Karel Zak
2012-11-20 14:41 ` Richard W.M. Jones [this message]
2012-11-20 15:07 ` Milan Broz
2012-11-20 15:41 ` Richard W.M. Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121120144111.GN1444@rhmail.home.annexia.org \
--to=rjones@redhat.com \
--cc=kzak@redhat.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).