All of lore.kernel.org
 help / color / mirror / Atom feed
* Querying the size of devdax devices from userspace
@ 2019-02-04  7:50 ` Stefan Hajnoczi
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2019-02-04  7:50 UTC (permalink / raw)
  To: Zhang Yi, Jeff Moyer, Dan Williams; +Cc: qemu-devel, linux-nvdimm

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

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?

Stefan

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

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

* [Qemu-devel] Querying the size of devdax devices from userspace
@ 2019-02-04  7:50 ` Stefan Hajnoczi
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2019-02-04  7:50 UTC (permalink / raw)
  To: Zhang Yi, Jeff Moyer, Dan Williams; +Cc: qemu-devel, linux-nvdimm

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

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?

Stefan

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

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

* Re: Querying the size of devdax devices from userspace
  2019-02-04  7:50 ` [Qemu-devel] " Stefan Hajnoczi
@ 2019-02-04  8:06   ` Dan Williams
  -1 siblings, 0 replies; 6+ messages in thread
From: Dan Williams @ 2019-02-04  8:06 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: Qemu Developers, linux-nvdimm

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
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

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

* Re: [Qemu-devel] Querying the size of devdax devices from userspace
@ 2019-02-04  8:06   ` Dan Williams
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Williams @ 2019-02-04  8:06 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: Zhang Yi, Jeff Moyer, Qemu Developers, linux-nvdimm

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

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

* Re: Querying the size of devdax devices from userspace
  2019-02-04  8:06   ` [Qemu-devel] " Dan Williams
@ 2019-02-08  1:53     ` Stefan Hajnoczi
  -1 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2019-02-08  1:53 UTC (permalink / raw)
  To: Dan Williams; +Cc: Zhang Yi, Jeff Moyer, Qemu Developers, linux-nvdimm

[-- 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 --]

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

* Re: [Qemu-devel] Querying the size of devdax devices from userspace
@ 2019-02-08  1:53     ` Stefan Hajnoczi
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2019-02-08  1:53 UTC (permalink / raw)
  To: Dan Williams; +Cc: Zhang Yi, Jeff Moyer, Qemu Developers, linux-nvdimm

[-- 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 --]

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

end of thread, other threads:[~2019-02-08  1:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2019-02-08  1:53     ` [Qemu-devel] " Stefan Hajnoczi

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.