All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc MERLIN <marc@merlins.org>
To: linux-bcache@vger.kernel.org
Subject: Hard to delete/unregister caching device
Date: Thu, 18 Feb 2016 22:48:57 -0800	[thread overview]
Message-ID: <20160219064857.GA29411@merlins.org> (raw)

So, I have this:
├─nvme0n1p4   259:4    0    30G part  bcache                   8fd98dbd-4e87-4faa-8cec-d5f1e3910daa ae581b32-8c62-41a9-bfcf-ca8cec66e46a
│ └─bcache0   252:0    0   1.1T disk  crypto_LUKS              d6c98ca4-23b4-4aa3-819b-b384d4ac1b6a 
│   └─pool2   251:3    0   1.1T crypt btrfs       /mnt/btrfs_p 5ed9d54d-2f12-4735-85c2-e0445a316088 
├─sda7          8:7    0   1.1T part  bcache                   6d88cea7-6cfc-4d30-8cf5-8c8b216e019d 753dca8b-07
│ └─bcache0   252:0    0   1.1T disk  crypto_LUKS              d6c98ca4-23b4-4aa3-819b-b384d4ac1b6a 
│   └─pool2   251:3    0   1.1T crypt btrfs       /mnt/btrfs_p 5ed9d54d-2f12-4735-85c2-e0445a316088 


├─sda6          8:6    0    65G part  bcache                   21c07a2c-6ed2-42c2-aafb-8e1bbfa471a5 753dca8b-06
└─sdb1          8:17   0   1.8T part  bcache                   b324cfc4-a5ae-4888-ad6c-a5ba1002fdce 89ba6da8-01
  └─bcache1   252:1    0   1.8T disk  crypto_LUKS              b519d6ce-291a-4500-937e-a5957e6ece6b 
    └─pool3   251:4    0   1.8T crypt btrfs       /mnt/btrfs_p 5874cad5-d6dd-4b3d-a455-4e0ae2611f09 

bcache0 is fine
bcache1 ended up in a bad state, I'm not sure how.
No biggie, right, just delete/recreate/re-register sda6, except how?

https://www.kernel.org/doc/Documentation/bcache.txt
SYSFS - CACHE DEVICE:
says nothing about how I can free/release sda6

saruman:~# echo /dev/sda6 > /sys/fs/bcache/unregister
-su: /sys/fs/bcache/unregister: Permission denied
is not helpful, nothing in kern.log

saruman:~# wipefs -a /dev/sda6
wipefs: error: /dev/sda6: probing initialization failed: Device or resource busy


saruman:~# l /dev/bcache/by-uuid/
total 0
drwxr-xr-x 2 root root 80 Feb 17 20:20 ./
drwxr-xr-x 3 root root 60 Feb 17 20:20 ../
lrwxrwxrwx 1 root root 13 Feb 17 20:20 6d88cea7-6cfc-4d30-8cf5-8c8b216e019d -> ../../bcache0
lrwxrwxrwx 1 root root 13 Feb 17 20:20 b324cfc4-a5ae-4888-ad6c-a5ba1002fdce -> ../../bcache1

Those UUIDs don't show up in lsblk

Oh my, what is this?
saruman:~# l /sys/block/sda/sda6/bcache/set
lrwxrwxrwx 1 root root 0 Feb 18 22:28 /sys/block/sda/sda6/bcache/set -> ../../../../../../../../../../../fs/bcache/f419195d-184e-44b7-9f88-a834a5458f8c/

This other UUID still does not show up in lsblk, by now I've lost count
of why I have 3 different kinds of UUIDs instead of 2.

Mmmh, now I'm starting to get it, I have to look at caching devices by UUID, find the right one, and stop it:
saruman:/sys/fs/bcache# l
total 0
drwxr-xr-x  5 root root    0 Feb 18 22:32 ./
drwxr-xr-x 10 root root    0 Feb 17 20:20 ../
drwxr-xr-x  7 root root    0 Feb 18 22:07 6698753e-78d0-4f6a-a8cb-fbb6a20ddae8/
drwxr-xr-x  7 root root    0 Feb 18 22:07 b7ba27a1-2398-4649-8ae3-0959f57ba128/
drwxr-xr-x  7 root root    0 Feb 18 22:32 f419195d-184e-44b7-9f88-a834a5458f8c/

Ok, let's try
saruman:/sys/fs/bcache/f419195d-184e-44b7-9f88-a834a5458f8c# echo 1 > stop

Ah, success:
saruman:~# wipefs -a /dev/sda6
/dev/sda6: 16 bytes were erased at offset 0x00001018 (bcache): c6 85 73 f6 4e 1a 45 ca 82 65 f5 7f 48 ba 6d 81

This isn't super obvious :)
Is there a howto document where those steps could be documented in a howto fashion?
(removing a caching device and replacing it with another one, maybe you got a bigger/faster SSD)

In https://www.kernel.org/doc/Documentation/bcache.txt or otherwise?

Thanks,
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

             reply	other threads:[~2016-02-19  6:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-19  6:48 Marc MERLIN [this message]
2016-02-21  4:17 ` Hard to delete/unregister caching device Kent Overstreet
2016-02-21 21:22   ` Marc MERLIN
  -- strict thread matches above, loose matches on Subject: below --
2016-02-24 19:13 Eric Wheeler
2016-02-24 21:30 ` Marc MERLIN

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=20160219064857.GA29411@merlins.org \
    --to=marc@merlins.org \
    --cc=linux-bcache@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 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.