All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: Zhang Yi <yi.z.zhang@linux.intel.com>,
	Jeff Moyer <jmoyer@redhat.com>,
	Qemu Developers <qemu-devel@nongnu.org>,
	linux-nvdimm <linux-nvdimm@lists.01.org>
Subject: Re: Querying the size of devdax devices from userspace
Date: Fri, 8 Feb 2019 09:53:13 +0800	[thread overview]
Message-ID: <20190208015313.GA16257@stefanha-x1.localdomain> (raw)
In-Reply-To: <CAPcyv4huSKQueADyF5wJPWxMdLAn6yvEqWyMZfWPVQ4vQ_X0RA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1659 bytes --]

On Mon, Feb 04, 2019 at 12:06:32AM -0800, Dan Williams wrote:
> On Sun, Feb 3, 2019 at 11:56 PM Stefan Hajnoczi <stefanha@redhat.com> wrote:
> >
> > How can userspace applications query the size of devdax character
> > devices?
> >
> > stat(1) doesn't know how large the device is:
> >
> >   # stat /dev/dax0.0
> >     File: /dev/dax0.0
> >     Size: 0             Blocks: 0          IO Block: 4096   character special file
> >   Device: 6h/6d Inode: 56764       Links: 1     Device type: fa,d
> >
> > ndctl(1) finds out by digging in /sys:
> >
> >   # ndctl list
> >   [
> >     {
> >       "dev":"namespace0.0",
> >       "mode":"devdax",
> >       "map":"dev",
> >       "size":2111832064,
> >       "uuid":"235acf4d-503f-46be-bf64-f26faf9777ef",
> >       "chardev":"dax0.0"
> >     }
> >   ]
> >
> > I'm not sure how to do it without enumerating all nvdimms in /sys.  Is
> > there a mapping from devdax major/minor number to a /sys path?
> >
> > The use case I have in mind is that QEMU currently takes the size as a
> > command-line parameter.  The failure mode is ugly when users get this
> > value wrong: the guest gets a softlockup and there is no error message
> > on the host side.
> >
> > I'd like QEMU to detect the size or at least reject size values that are
> > too large.  In order to do that userspace needs a convenient way of
> > querying the size.  Any ideas?
> 
> You're looking for /sys/dev/char. That will wake you from major:minor
> to sysfs. Perhaps borrow fio's implementation for the same:
> 
>    http://git.kernel.dk/cgit/fio/tree/engines/dev-dax.c#n258

Excellent, thanks!

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: Zhang Yi <yi.z.zhang@linux.intel.com>,
	Jeff Moyer <jmoyer@redhat.com>,
	Qemu Developers <qemu-devel@nongnu.org>,
	linux-nvdimm <linux-nvdimm@lists.01.org>
Subject: Re: [Qemu-devel] Querying the size of devdax devices from userspace
Date: Fri, 8 Feb 2019 09:53:13 +0800	[thread overview]
Message-ID: <20190208015313.GA16257@stefanha-x1.localdomain> (raw)
In-Reply-To: <CAPcyv4huSKQueADyF5wJPWxMdLAn6yvEqWyMZfWPVQ4vQ_X0RA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1659 bytes --]

On Mon, Feb 04, 2019 at 12:06:32AM -0800, Dan Williams wrote:
> On Sun, Feb 3, 2019 at 11:56 PM Stefan Hajnoczi <stefanha@redhat.com> wrote:
> >
> > How can userspace applications query the size of devdax character
> > devices?
> >
> > stat(1) doesn't know how large the device is:
> >
> >   # stat /dev/dax0.0
> >     File: /dev/dax0.0
> >     Size: 0             Blocks: 0          IO Block: 4096   character special file
> >   Device: 6h/6d Inode: 56764       Links: 1     Device type: fa,d
> >
> > ndctl(1) finds out by digging in /sys:
> >
> >   # ndctl list
> >   [
> >     {
> >       "dev":"namespace0.0",
> >       "mode":"devdax",
> >       "map":"dev",
> >       "size":2111832064,
> >       "uuid":"235acf4d-503f-46be-bf64-f26faf9777ef",
> >       "chardev":"dax0.0"
> >     }
> >   ]
> >
> > I'm not sure how to do it without enumerating all nvdimms in /sys.  Is
> > there a mapping from devdax major/minor number to a /sys path?
> >
> > The use case I have in mind is that QEMU currently takes the size as a
> > command-line parameter.  The failure mode is ugly when users get this
> > value wrong: the guest gets a softlockup and there is no error message
> > on the host side.
> >
> > I'd like QEMU to detect the size or at least reject size values that are
> > too large.  In order to do that userspace needs a convenient way of
> > querying the size.  Any ideas?
> 
> You're looking for /sys/dev/char. That will wake you from major:minor
> to sysfs. Perhaps borrow fio's implementation for the same:
> 
>    http://git.kernel.dk/cgit/fio/tree/engines/dev-dax.c#n258

Excellent, thanks!

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  reply	other threads:[~2019-02-08  1:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-04  7:50 Querying the size of devdax devices from userspace Stefan Hajnoczi
2019-02-04  7:50 ` [Qemu-devel] " Stefan Hajnoczi
2019-02-04  8:06 ` Dan Williams
2019-02-04  8:06   ` [Qemu-devel] " Dan Williams
2019-02-08  1:53   ` Stefan Hajnoczi [this message]
2019-02-08  1:53     ` Stefan Hajnoczi

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=20190208015313.GA16257@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=dan.j.williams@intel.com \
    --cc=jmoyer@redhat.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=qemu-devel@nongnu.org \
    --cc=yi.z.zhang@linux.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.