All of lore.kernel.org
 help / color / mirror / Atom feed
* Cannot add device "is mounted" for unmounted drive that used to be in raidset that is mounted
@ 2014-03-23 18:09 Marc MERLIN
  2014-03-23 18:58 ` Marc MERLIN
  2014-03-31  4:07 ` Anand Jain
  0 siblings, 2 replies; 5+ messages in thread
From: Marc MERLIN @ 2014-03-23 18:09 UTC (permalink / raw)
  To: linux-btrfs

I found out that a drive that used to be part of a raid system that is mounted
and running without it, btrfs apparently decides that the drive is part of the mounted
raidset and in use.
As a result, I had to eventually dd 0's over it, btrfs device scan, and finally
I was able to use it again.

btrfs should probably improve its check to see that the drive is not really used
and let me format it.


Longer details:
On a running system, I re-added a drive, it showed up as /dev/sdm1
I decrypted it
cryptsetup luksOpen /dev/sdm1 crypt_sdm1

But I can't add it:
polgara:/mnt/btrfs_backupcopy# btrfs device add -f /dev/mapper/crypt_sdm1 .
/dev/mapper/crypt_sdm1 is mounted

however, I can format it as ext4, mount it, write to it, unmount it, and
I still get the same error:
polgara:/mnt/btrfs_backupcopy# mke2fs -t ext4 /dev/mapper/crypt_sdm1
polgara:/mnt/btrfs_backupcopy# mount /dev/mapper/crypt_sdm1 /mnt/mnt
polgara:/mnt/btrfs_backupcopy# Mar 23 10:48:31 polgara kernel: [38645.955263] EXT4-fs (dm-10): mounted filesystem with ordered data mode. Opts: (null)
polgara:/mnt/btrfs_backupcopy# umount /mnt/mnt
polgara:/mnt/btrfs_backupcopy# btrfs device add -f /dev/mapper/crypt_sdm1 .
/dev/mapper/crypt_sdm1 is mounted

polgara:/mnt/btrfs_backupcopy# fuser -v /dev/mapper/crypt_sdm1
polgara:/mnt/btrfs_backupcopy# lsof -n | grep -E '(dm-10|sdm)'
polgara:/mnt/btrfs_backupcopy# mkfs.btrfs -f /dev/mapper/crypt_sdm1 
Error: /dev/mapper/crypt_sdm1 is mounted
polgara:/mnt/btrfs_backupcopy# 

In the end, I had to run
dd if=/dev/zero of=/dev/mapper/crypt_sdm1 bs=1M
for btrfs to stop telling me the filesystem was mounted.

Marc
-- 
"A mouse is a device used to point at the xterm you want to type in" - A.S.R.
Microsoft is to operating systems ....
                                      .... what McDonalds is to gourmet cooking
Home page: http://marc.merlins.org/                         | PGP 1024R/763BE901

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cannot add device "is mounted" for unmounted drive that used to be in raidset that is mounted
  2014-03-23 18:09 Cannot add device "is mounted" for unmounted drive that used to be in raidset that is mounted Marc MERLIN
@ 2014-03-23 18:58 ` Marc MERLIN
  2014-03-24 19:19   ` Duncan
  2014-03-31  4:07 ` Anand Jain
  1 sibling, 1 reply; 5+ messages in thread
From: Marc MERLIN @ 2014-03-23 18:58 UTC (permalink / raw)
  To: linux-btrfs

On Sun, Mar 23, 2014 at 11:09:07AM -0700, Marc MERLIN wrote:
> I found out that a drive that used to be part of a raid system that is mounted
> and running without it, btrfs apparently decides that the drive is part of the mounted
> raidset and in use.
> As a result, I had to eventually dd 0's over it, btrfs device scan, and finally
> I was able to use it again.

I filed a bug for this, it's a bit more minor, but worth fixing eventually
https://bugzilla.kernel.org/show_bug.cgi?id=72771

Marc

-- 
"A mouse is a device used to point at the xterm you want to type in" - A.S.R.
Microsoft is to operating systems ....
                                      .... what McDonalds is to gourmet cooking
Home page: http://marc.merlins.org/  

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cannot add device "is mounted" for unmounted drive that used to be in raidset that is mounted
  2014-03-23 18:58 ` Marc MERLIN
@ 2014-03-24 19:19   ` Duncan
  2014-03-25  0:28     ` Marc MERLIN
  0 siblings, 1 reply; 5+ messages in thread
From: Duncan @ 2014-03-24 19:19 UTC (permalink / raw)
  To: linux-btrfs

Marc MERLIN posted on Sun, 23 Mar 2014 11:58:16 -0700 as excerpted:

> On Sun, Mar 23, 2014 at 11:09:07AM -0700, Marc MERLIN wrote:
>> I found out that a drive that used to be part of a raid system that is
>> mounted and running without it, btrfs apparently decides that the drive
>> is part of the mounted raidset and in use.
>> As a result, I had to eventually dd 0's over it, btrfs device scan, and
>> finally I was able to use it again.
> 
> I filed a bug for this, it's a bit more minor, but worth fixing
> eventually https://bugzilla.kernel.org/show_bug.cgi?id=72771

The reason for this is the device-scanning that btrfs does, detecting 
btrfs superblocks in ordered to assemble filesystems from multiple 
devices, etc.

The canonical method for wiping such superblocks and thus avoiding btrfs 
detecting it as a btrfs filesystem component is to use wipefs, part of 
the util-linux package.  I think it's covered somewhere on the wiki; let 
me see if I can find it...

Yes.  See the problem-FAQ:

https://btrfs.wiki.kernel.org/index.php/Problem_FAQ#How_to_clean_up_old_superblock_.3F

As you'll note, however, it mentions the dd method as a workaround if 
wipefs isn't available, but all you need to wipe is the 8-byte magic 
string. =:^)  (Tho there's three superblocks and while wiping the first 
is generally enough and is all wipefs does, you can wipe the others too 
if you like as well.  There are also instructions for restoring the magic 
string using dd, if it should be come necessary.)





-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cannot add device "is mounted" for unmounted drive that used to be in raidset that is mounted
  2014-03-24 19:19   ` Duncan
@ 2014-03-25  0:28     ` Marc MERLIN
  0 siblings, 0 replies; 5+ messages in thread
From: Marc MERLIN @ 2014-03-25  0:28 UTC (permalink / raw)
  To: Duncan; +Cc: linux-btrfs

On Mon, Mar 24, 2014 at 07:19:14PM +0000, Duncan wrote:
> Marc MERLIN posted on Sun, 23 Mar 2014 11:58:16 -0700 as excerpted:
> 
> > On Sun, Mar 23, 2014 at 11:09:07AM -0700, Marc MERLIN wrote:
> >> I found out that a drive that used to be part of a raid system that is
> >> mounted and running without it, btrfs apparently decides that the drive
> >> is part of the mounted raidset and in use.
> >> As a result, I had to eventually dd 0's over it, btrfs device scan, and
> >> finally I was able to use it again.
> > 
> > I filed a bug for this, it's a bit more minor, but worth fixing
> > eventually https://bugzilla.kernel.org/show_bug.cgi?id=72771
> 
> The reason for this is the device-scanning that btrfs does, detecting 
> btrfs superblocks in ordered to assemble filesystems from multiple 
> devices, etc.

Yep, and thanks for reminding me of wipefs.
However this was still a bug to say that a device was mounted when it sure
wasn't :)

I'm ok using -f because I didn't use wipefs, but being told "no you can't
reformat this because it's mounted", spending too long looking what in the
kernel would make it think so, and then realizing the check is wrong, isn't
as user friendly :)

Marc
-- 
"A mouse is a device used to point at the xterm you want to type in" - A.S.R.
Microsoft is to operating systems ....
                                      .... what McDonalds is to gourmet cooking
Home page: http://marc.merlins.org/  

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cannot add device "is mounted" for unmounted drive that used to be in raidset that is mounted
  2014-03-23 18:09 Cannot add device "is mounted" for unmounted drive that used to be in raidset that is mounted Marc MERLIN
  2014-03-23 18:58 ` Marc MERLIN
@ 2014-03-31  4:07 ` Anand Jain
  1 sibling, 0 replies; 5+ messages in thread
From: Anand Jain @ 2014-03-31  4:07 UTC (permalink / raw)
  To: Marc MERLIN; +Cc: linux-btrfs


On 24/03/2014 02:09, Marc MERLIN wrote:
> I found out that a drive that used to be part of a raid system that is mounted
> and running without it, btrfs apparently decides that the drive is part of the mounted
> raidset and in use.

  yes. A known issue its in the list to fix.

-Anand

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-03-31  4:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-23 18:09 Cannot add device "is mounted" for unmounted drive that used to be in raidset that is mounted Marc MERLIN
2014-03-23 18:58 ` Marc MERLIN
2014-03-24 19:19   ` Duncan
2014-03-25  0:28     ` Marc MERLIN
2014-03-31  4:07 ` Anand Jain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.