From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Ning, Yu" <yu.ning@intel.com>
Cc: Jin Qian <jinqian@android.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Jeff Sharkey <jsharkey@google.com>,
David Turner <digit@google.com>,
"pprabhu@google.com" <pprabhu@google.com>
Subject: Re: allocate an official device major number for virtio device?
Date: Thu, 3 Mar 2016 09:18:46 -0800 [thread overview]
Message-ID: <20160303171846.GC20826@kroah.com> (raw)
In-Reply-To: <C29659EAAA3E0143B583467412621C60225C8EC1@SHSMSX101.ccr.corp.intel.com>
A: No.
Q: Should I include quotations after my reply?
http://daringfireball.net/2007/07/on_top
On Thu, Mar 03, 2016 at 03:52:20AM +0000, Ning, Yu wrote:
> Well, virtio_blk does use dynamic major number allocation, but the
> allocated block major just happens to fall in the "experimental" range
> (240-254)...
That all depends on what else is registered in the system at the moment.
> In more detail:
>
> virtio_blk calls register_blkdev() with major = 0 in init() (drivers/block/virtio_blk.c:872):
>
> major = register_blkdev(0, "virtblk");
>
> This line has been there since day one. And register_blkdev() implements dynamic major allocation pretty straightforwardly:
>
> /* temporary */
> if (major == 0) {
> for (index = ARRAY_SIZE(major_names)-1; index > 0; index--) {
> if (major_names[index] == NULL)
> break;
> }
>
> So it goes from index = 254 to 1 and picks the first unused.
> Apparently, there's a good chance that the allocated major is between
> 240-254 (although lower numbers are also possible, theoretically).
> Indeed, we always get 253 for virtio_blk with the x86_64 Android
> emulator kernel.
>
> But "dynamic" means we can't rely on checking major == 253 to detect
> virtio_blk.
Nor should you, why would you care?
> That's why we are doing a fnmatch() using pattern
> /sys/devices/*/block/vd* instead. Is that the recommended approach?
Yes, or just look at the device node that is already created in /dev/
for you automatially by devtmpfs. Doesn't that work as expected today?
I still don't understand the issue you are having here at all, sorry.
greg k-h
next prev parent reply other threads:[~2016-03-03 17:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-03 1:08 allocate an official device major number for virtio device? Jin Qian
2016-03-03 1:25 ` Greg Kroah-Hartman
2016-03-03 1:48 ` Jin Qian
2016-03-03 3:52 ` Ning, Yu
2016-03-03 14:46 ` One Thousand Gnomes
2016-03-03 17:18 ` Greg Kroah-Hartman [this message]
2016-03-03 19:32 ` Jin Qian
2016-03-03 20:00 ` Greg Kroah-Hartman
2016-03-03 22:12 ` Jeff Sharkey
2016-03-03 22:35 ` Richard Weinberger
2016-03-03 22:43 ` Greg Kroah-Hartman
2016-03-03 17:17 ` Greg Kroah-Hartman
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=20160303171846.GC20826@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=digit@google.com \
--cc=jinqian@android.com \
--cc=jsharkey@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pprabhu@google.com \
--cc=yu.ning@intel.com \
/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.