linux-bcache.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Goran <via-bcache@pvgoran.name>
To: linux-bcache@vger.kernel.org
Cc: Stefan Priebe - Profihost AG <s.priebe@profihost.ag>
Subject: Re[2]: best way to get the bdev of a bcache block device
Date: Tue, 23 Jan 2018 07:32:19 +0300	[thread overview]
Message-ID: <1983233152.20180123073219@pvgoran.name> (raw)
In-Reply-To: <120a1d62-87bf-c9c5-81aa-254e619c7398@lyle.org>

Hello Michael,

Tuesday, January 23, 2018, 1:20:28 AM, you wrote:

> On 01/22/2018 01:59 PM, Stefan Priebe - Profihost AG wrote:
>> Hello,
>> 
>> what's the best way to get the correct bcache backing device (bdev) form
>> a known dev (f.e. /dev/bcache2)?
>> 
>> I haven't found an easy reliable way through /sys/block.
>> 
>> Thanks!
>> 
>> Greets,
>> Stefan

> /sys/block/bcache0/slaves

This lists both the backing device and the cache device(s), without an
(apparent) way of identifying which one is backing.

> /sys/block/bcache0/bcache/cache/bdev0

/sys/block/bcache0/bcache/cache links to the cache set (/sys/fs/bcache/[UUID])
which can serve several bcache devices, so bdev0 would link to the first
backing device registered in the set, not the backing device that corresponds
to the bcache device we started with.

However, it's actually possible to go further: iterate all bdevX devices and
identify the correct one by looking at the "dev" symlink:

/sys/block/bcache0/bcache/cache/bdev0/dev
/sys/block/bcache0/bcache/cache/bdev1/dev
etc.

The device whose "dev" symlink points to bcache0 should be the backing device
for bcache0.

Pavel Goran
  

      reply	other threads:[~2018-01-23  4:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22 21:59 best way to get the bdev of a bcache block device Stefan Priebe - Profihost AG
2018-01-22 22:20 ` Michael Lyle
2018-01-23  4:32   ` Pavel Goran [this message]

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=1983233152.20180123073219@pvgoran.name \
    --to=via-bcache@pvgoran.name \
    --cc=linux-bcache@vger.kernel.org \
    --cc=s.priebe@profihost.ag \
    /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).