On Mon, Feb 04, 2019 at 12:06:32AM -0800, Dan Williams wrote:
> On Sun, Feb 3, 2019 at 11:56 PM Stefan Hajnoczi <stefa...@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: signature.asc
Description: PGP signature

Reply via email to