Re: [PATCH] ndctl: daxctl: Adding io option for daxctl

2017-08-08 Thread Dan Williams
Finally circling back on this...

On Thu, Jun 15, 2017 at 3:42 PM, Dave Jiang  wrote:
> The daxctl io option allows I/Os to be performed between block/file to
> and from device dax files. It also provides a way to zero a device dax
> device.
>
> i.e. daxctl io --input=/home/myfile --output=/dev/dax1.0
>
> Signed-off-by: Dave Jiang 
> ---
>  Documentation/Makefile.am   |3
>  Documentation/daxctl-io.txt |   71 +
>  daxctl/Makefile.am  |5
>  daxctl/daxctl.c |2
>  daxctl/io.c |  567 
> +++
>  5 files changed, 646 insertions(+), 2 deletions(-)
>  create mode 100644 Documentation/daxctl-io.txt
>  create mode 100644 daxctl/io.c
>
> diff --git a/Documentation/Makefile.am b/Documentation/Makefile.am
> index c7e0758..8efdbc2 100644
> --- a/Documentation/Makefile.am
> +++ b/Documentation/Makefile.am
> @@ -26,7 +26,8 @@ man1_MANS = \
> ndctl-destroy-namespace.1 \
> ndctl-check-namespace.1 \
> ndctl-list.1 \
> -   daxctl-list.1
> +   daxctl-list.1 \
> +   daxctl-io.1
>
>  CLEANFILES = $(man1_MANS)
>
> diff --git a/Documentation/daxctl-io.txt b/Documentation/daxctl-io.txt
> new file mode 100644
> index 000..c3ddd15
> --- /dev/null
> +++ b/Documentation/daxctl-io.txt
> @@ -0,0 +1,71 @@
> +daxctl-io(1)
> +===
> +
> +NAME
> +
> +daxctl-io - Perform I/O on Device-DAX devices or zero a Device-DAX device.
> +
> +SYNOPSIS
> +
> +[verse]
> +'daxctl io' []
> +
> +There must be a Device-DAX device involved whether as the input or the output
> +device. Read from a Device-DAX device and write to a file, a block device,
> +another Device-DAX device, or stdout (if no output is provided). Write
> +to a Device-DAX device from a file, a block device, or stdin, or another
> +Device-DAX device.

Why does it matter if a block-device is involved? I.e. this should
operate between a device-dax instance and a file descriptor. It
shouldn't matter what that file descriptor represents.

> +
> +No length specified will default to input file/device length. If input is
> +a special char file then length will be the output file/device length.
> +
> +No input will default to stdin. No output will default to stdout.
> +
> +For a Device-DAX device, attempts to clear badblocks within range of writes
> +will be performed.
> +
> +EXAMPLE
> +---
> +[verse]
> +# daxctl io --zero /dev/dax1.0
> +
> +# daxctl io --input=/dev/dax1.0 --output=/home/myfile --len=2097152 
> --seek=4096
> +
> +# cat /dev/zero | daxctl io --output=/dev/dax1.0
> +
> +# daxctl io --input=/dev/zero --output=/dev/dax1.0 --skip=4096
> +
> +OPTIONS
> +---
> +-i::
> +--input=::
> +   Input device or file to read from.
> +
> +-o::
> +--output=::
> +   Output device or file to write to.
> +
> +-z::
> +--zero::
> +   Zero the output device for 'len' size. Or the entire device if no
> +   length was provided. The output device must be a Device DAX device.
> +
> +-l::
> +--len::
> +   The length in bytes to perform the I/O.
> +
> +-s::
> +--seek::
> +   The number of bytes to skip over on the output before performing a
> +   write.
> +
> +-k::
> +--skip::
> +   The number of bytes to skip over on the input before performing a 
> read.
> +
> +COPYRIGHT
> +-
> +Copyright (c) 2017, Intel Corporation. License GPLv2: GNU GPL
> +version 2 .  This is free software:
> +you are free to change and redistribute it.  There is NO WARRANTY, to
> +the extent permitted by law.
> diff --git a/daxctl/Makefile.am b/daxctl/Makefile.am
> index fe467d0..1ba1f07 100644
> --- a/daxctl/Makefile.am
> +++ b/daxctl/Makefile.am
> @@ -5,10 +5,13 @@ bin_PROGRAMS = daxctl
>  daxctl_SOURCES =\
> daxctl.c \
> list.c \
> +   io.c \
> ../util/json.c
>
>  daxctl_LDADD =\
> lib/libdaxctl.la \
> +   ../ndctl/lib/libndctl.la \
> ../libutil.a \
> $(UUID_LIBS) \
> -   $(JSON_LIBS)
> +   $(JSON_LIBS) \
> +   -lpmem
> diff --git a/daxctl/daxctl.c b/daxctl/daxctl.c
> index 91a4600..db2e495 100644
> --- a/daxctl/daxctl.c
> +++ b/daxctl/daxctl.c
> @@ -67,11 +67,13 @@ static int cmd_help(int argc, const char **argv, void 
> *ctx)
>  }
>
>  int cmd_list(int argc, const char **argv, void *ctx);
> +int cmd_io(int argc, const char **argv, void *ctx);
>
>  static struct cmd_struct commands[] = {
> { "version", cmd_version },
> { "list", cmd_list },
> { "help", cmd_help },
> +   { "io", cmd_io },
>  };
>
>  int main(int argc, const char **argv)
> diff --git a/daxctl/io.c b/daxctl/io.c
> new file mode 100644
> index 000..92e2878
> --- /dev/null
> +++ b/daxctl/io.c
> @@ -0,0 +1,567 @@
> +/*
> + * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * 

Re: [PATCH] ndctl: daxctl: Adding io option for daxctl

2017-06-16 Thread Jeff Moyer
Dan Williams  writes:

> On Fri, Jun 16, 2017 at 10:00 AM, Jeff Moyer  wrote:
>> Dave Jiang  writes:
>>
>>> The daxctl io option allows I/Os to be performed between block/file to
>>> and from device dax files. It also provides a way to zero a device dax
>>> device.
>>>
>>> i.e. daxctl io --input=/home/myfile --output=/dev/dax1.0
>>
>> Does that really belong in daxctl?
>
> I'm open to teaching other utilities how to do mmap based i/o, but is
> there any harm in carrying this dedicated utility for this purpose?

Well, what is the purpose of daxctl, exactly?  Given the 'ctl' in the
name, I figured it was used for configuration.

> Certainly the error clearing interface to send custom nvdimm ioctls is
> not something I expect 'cp' or 'dd' to comprehend.

Sure, clearing errors makes sense.  I don't see a need to reimplement dd
or xfs_io, though.

Cheers,
Jeff
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH] ndctl: daxctl: Adding io option for daxctl

2017-06-16 Thread Dan Williams
On Fri, Jun 16, 2017 at 10:00 AM, Jeff Moyer  wrote:
> Dave Jiang  writes:
>
>> The daxctl io option allows I/Os to be performed between block/file to
>> and from device dax files. It also provides a way to zero a device dax
>> device.
>>
>> i.e. daxctl io --input=/home/myfile --output=/dev/dax1.0
>
> Does that really belong in daxctl?

I'm open to teaching other utilities how to do mmap based i/o, but is
there any harm in carrying this dedicated utility for this purpose?
Certainly the error clearing interface to send custom nvdimm ioctls is
not something I expect 'cp' or 'dd' to comprehend.
___
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm


Re: [PATCH] ndctl: daxctl: Adding io option for daxctl

2017-06-16 Thread Jeff Moyer
Dave Jiang  writes:

> The daxctl io option allows I/Os to be performed between block/file to
> and from device dax files. It also provides a way to zero a device dax
> device.
>
> i.e. daxctl io --input=/home/myfile --output=/dev/dax1.0

Does that really belong in daxctl?

-Jeff

> Signed-off-by: Dave Jiang 
> ---
>  Documentation/Makefile.am   |3 
>  Documentation/daxctl-io.txt |   71 +
>  daxctl/Makefile.am  |5 
>  daxctl/daxctl.c |2 
>  daxctl/io.c |  567 
> +++
>  5 files changed, 646 insertions(+), 2 deletions(-)
>  create mode 100644 Documentation/daxctl-io.txt
>  create mode 100644 daxctl/io.c
>
> diff --git a/Documentation/Makefile.am b/Documentation/Makefile.am
> index c7e0758..8efdbc2 100644
> --- a/Documentation/Makefile.am
> +++ b/Documentation/Makefile.am
> @@ -26,7 +26,8 @@ man1_MANS = \
>   ndctl-destroy-namespace.1 \
>   ndctl-check-namespace.1 \
>   ndctl-list.1 \
> - daxctl-list.1
> + daxctl-list.1 \
> + daxctl-io.1
>  
>  CLEANFILES = $(man1_MANS)
>  
> diff --git a/Documentation/daxctl-io.txt b/Documentation/daxctl-io.txt
> new file mode 100644
> index 000..c3ddd15
> --- /dev/null
> +++ b/Documentation/daxctl-io.txt
> @@ -0,0 +1,71 @@
> +daxctl-io(1)
> +===
> +
> +NAME
> +
> +daxctl-io - Perform I/O on Device-DAX devices or zero a Device-DAX device.
> +
> +SYNOPSIS
> +
> +[verse]
> +'daxctl io' []
> +
> +There must be a Device-DAX device involved whether as the input or the output
> +device. Read from a Device-DAX device and write to a file, a block device,
> +another Device-DAX device, or stdout (if no output is provided). Write
> +to a Device-DAX device from a file, a block device, or stdin, or another
> +Device-DAX device.
> +
> +No length specified will default to input file/device length. If input is
> +a special char file then length will be the output file/device length.
> +
> +No input will default to stdin. No output will default to stdout.
> +
> +For a Device-DAX device, attempts to clear badblocks within range of writes
> +will be performed.
> +
> +EXAMPLE
> +---
> +[verse]
> +# daxctl io --zero /dev/dax1.0
> +
> +# daxctl io --input=/dev/dax1.0 --output=/home/myfile --len=2097152 
> --seek=4096
> +
> +# cat /dev/zero | daxctl io --output=/dev/dax1.0
> +
> +# daxctl io --input=/dev/zero --output=/dev/dax1.0 --skip=4096
> +
> +OPTIONS
> +---
> +-i::
> +--input=::
> + Input device or file to read from.
> +
> +-o::
> +--output=::
> + Output device or file to write to.
> +
> +-z::
> +--zero::
> + Zero the output device for 'len' size. Or the entire device if no
> + length was provided. The output device must be a Device DAX device.
> +
> +-l::
> +--len::
> + The length in bytes to perform the I/O.
> +
> +-s::
> +--seek::
> + The number of bytes to skip over on the output before performing a
> + write.
> +
> +-k::
> +--skip::
> + The number of bytes to skip over on the input before performing a read.
> +
> +COPYRIGHT
> +-
> +Copyright (c) 2017, Intel Corporation. License GPLv2: GNU GPL
> +version 2 .  This is free software:
> +you are free to change and redistribute it.  There is NO WARRANTY, to
> +the extent permitted by law.
> diff --git a/daxctl/Makefile.am b/daxctl/Makefile.am
> index fe467d0..1ba1f07 100644
> --- a/daxctl/Makefile.am
> +++ b/daxctl/Makefile.am
> @@ -5,10 +5,13 @@ bin_PROGRAMS = daxctl
>  daxctl_SOURCES =\
>   daxctl.c \
>   list.c \
> + io.c \
>   ../util/json.c
>  
>  daxctl_LDADD =\
>   lib/libdaxctl.la \
> + ../ndctl/lib/libndctl.la \
>   ../libutil.a \
>   $(UUID_LIBS) \
> - $(JSON_LIBS)
> + $(JSON_LIBS) \
> + -lpmem
> diff --git a/daxctl/daxctl.c b/daxctl/daxctl.c
> index 91a4600..db2e495 100644
> --- a/daxctl/daxctl.c
> +++ b/daxctl/daxctl.c
> @@ -67,11 +67,13 @@ static int cmd_help(int argc, const char **argv, void 
> *ctx)
>  }
>  
>  int cmd_list(int argc, const char **argv, void *ctx);
> +int cmd_io(int argc, const char **argv, void *ctx);
>  
>  static struct cmd_struct commands[] = {
>   { "version", cmd_version },
>   { "list", cmd_list },
>   { "help", cmd_help },
> + { "io", cmd_io },
>  };
>  
>  int main(int argc, const char **argv)
> diff --git a/daxctl/io.c b/daxctl/io.c
> new file mode 100644
> index 000..92e2878
> --- /dev/null
> +++ b/daxctl/io.c
> @@ -0,0 +1,567 @@
> +/*
> + * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of version 2 of the GNU General Public License as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty