All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-nvdimm <linux-nvdimm@ml01.01.org>,
	qemu-devel@nongnu.org, Vishal L Verma <vishal.l.verma@intel.com>
Subject: Re: [ndctl PATCH 0/8] dimm label space initialization support
Date: Wed, 19 Oct 2016 18:46:14 -0500	[thread overview]
Message-ID: <708947f5-dfdc-d6c9-4523-7436959119f3@redhat.com> (raw)
In-Reply-To: <CAPcyv4h3_OAef5n=tQ2vDXw=sntkZPTnyoeFdRQN6BKKx3q6SA@mail.gmail.com>

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

On 10/19/2016 04:29 PM, Dan Williams wrote:
> On Wed, Oct 19, 2016 at 12:41 PM, Dan Williams <dan.j.williams@intel.com> wrote:
>> On Wed, Oct 19, 2016 at 11:42 AM, Eric Blake <eblake@redhat.com> wrote:
>>> On 10/19/2016 11:47 AM, Dan Williams wrote:
>>>> The 4.9 kernel added support for sub-dividing PMEM.  With this kernel
>>>> patch [1] on top of that baseline, the PMEM-sub-division support can be
>>>> enabled for QEMU-KVM and any other platforms that advertise both un-aliased
>>>> PMEM regions and support for the label DSM commands [2].
>>>>
>>>> Given this increasing need to perform a label management operation
>>>> across a set of DIMMs this update also adds glob(3) support.  For
>>>> example you can now write commands like:
>>>>
>>>>     ndctl zero-labels nmem[2-4]
>>>
>>> This is slightly scary, as it depends on the user not having any file
>>> named nmem2, nmem3, or nmem4 in the current working directory.  Your
>>> example should probably encourage proper shell quoting, as in:
>>>
>>> ndctl zero-labels 'nmem[2-4]'
>>
>> True.  Although, the glob is run against the list of present device
>> names in the system, so local files named nmem should change the
>> operation of the command.
> 
> s/should/shouldn't/

You didn't get my complaint.  So let me demonstrate, using echo instead
of ndctl:

$ mkdir /tmp/foo
$ cd /tmp/foo
$ echo nmem[2-4]
nmem[2-4]
$ touch nmem3 nmem4
$ echo nmem[2-4]
nmem3 nmem4
$ echo 'nmem[2-4]'
nmem[2-4]

The problem is that the glob is liable to pre-expansion by the shell
UNLESS the user quotes the glob; meaning that the current working
directory controls whether ndctl even sees a glob in the first place.
If you are going to support globbing in ndctl out of laziness (since it
is indeed fewer characters to type [2-4] than it is to type {2..4}, plus
{2..4} is not supported by all shells), then you HAVE to document that
the user is responsible for quoting (omitting quoting usually does what
you want).  But by the time you quote to get the glob down to ndctl,
'[2-4]' is more typing than {2..4} expanded by the shell, at which point
were you really being lazy by adding globbing?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Eric Blake <eblake@redhat.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-nvdimm <linux-nvdimm@ml01.01.org>,
	Vishal L Verma <vishal.l.verma@intel.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [ndctl PATCH 0/8] dimm label space initialization support
Date: Wed, 19 Oct 2016 18:46:14 -0500	[thread overview]
Message-ID: <708947f5-dfdc-d6c9-4523-7436959119f3@redhat.com> (raw)
In-Reply-To: <CAPcyv4h3_OAef5n=tQ2vDXw=sntkZPTnyoeFdRQN6BKKx3q6SA@mail.gmail.com>

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

On 10/19/2016 04:29 PM, Dan Williams wrote:
> On Wed, Oct 19, 2016 at 12:41 PM, Dan Williams <dan.j.williams@intel.com> wrote:
>> On Wed, Oct 19, 2016 at 11:42 AM, Eric Blake <eblake@redhat.com> wrote:
>>> On 10/19/2016 11:47 AM, Dan Williams wrote:
>>>> The 4.9 kernel added support for sub-dividing PMEM.  With this kernel
>>>> patch [1] on top of that baseline, the PMEM-sub-division support can be
>>>> enabled for QEMU-KVM and any other platforms that advertise both un-aliased
>>>> PMEM regions and support for the label DSM commands [2].
>>>>
>>>> Given this increasing need to perform a label management operation
>>>> across a set of DIMMs this update also adds glob(3) support.  For
>>>> example you can now write commands like:
>>>>
>>>>     ndctl zero-labels nmem[2-4]
>>>
>>> This is slightly scary, as it depends on the user not having any file
>>> named nmem2, nmem3, or nmem4 in the current working directory.  Your
>>> example should probably encourage proper shell quoting, as in:
>>>
>>> ndctl zero-labels 'nmem[2-4]'
>>
>> True.  Although, the glob is run against the list of present device
>> names in the system, so local files named nmem should change the
>> operation of the command.
> 
> s/should/shouldn't/

You didn't get my complaint.  So let me demonstrate, using echo instead
of ndctl:

$ mkdir /tmp/foo
$ cd /tmp/foo
$ echo nmem[2-4]
nmem[2-4]
$ touch nmem3 nmem4
$ echo nmem[2-4]
nmem3 nmem4
$ echo 'nmem[2-4]'
nmem[2-4]

The problem is that the glob is liable to pre-expansion by the shell
UNLESS the user quotes the glob; meaning that the current working
directory controls whether ndctl even sees a glob in the first place.
If you are going to support globbing in ndctl out of laziness (since it
is indeed fewer characters to type [2-4] than it is to type {2..4}, plus
{2..4} is not supported by all shells), then you HAVE to document that
the user is responsible for quoting (omitting quoting usually does what
you want).  But by the time you quote to get the glob down to ndctl,
'[2-4]' is more typing than {2..4} expanded by the shell, at which point
were you really being lazy by adding globbing?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2016-10-19 23:46 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-19 16:47 [ndctl PATCH 0/8] dimm label space initialization support Dan Williams
2016-10-19 16:47 ` [Qemu-devel] " Dan Williams
2016-10-19 16:47 ` [ndctl PATCH 1/8] libndctl: fix error returns for unsigned apis Dan Williams
2016-10-19 16:47 ` [ndctl PATCH 2/8] ndctl: consolidate label commands into a single file Dan Williams
2016-10-19 16:48 ` [ndctl PATCH 3/8] ndctl: glob support for label commands Dan Williams
2016-10-19 16:48 ` [ndctl PATCH 4/8] ndctl: merge {enable, disable}-dimm with " Dan Williams
2016-10-19 16:48 ` [ndctl PATCH 5/8] libndctl: add ndctl_cmd_cfg_read_get_size() Dan Williams
2016-10-19 16:48 ` [ndctl PATCH 6/8] ndctl: provide a read_labels() helper Dan Williams
2016-10-19 16:48 ` [ndctl PATCH 7/8] ndctl: init-labels command Dan Williams
2016-10-19 16:48   ` [Qemu-devel] " Dan Williams
2016-10-19 16:48 ` [ndctl PATCH 8/8] ndctl: check-labels command Dan Williams
2016-10-19 18:42 ` [ndctl PATCH 0/8] dimm label space initialization support Eric Blake
2016-10-19 18:42   ` [Qemu-devel] " Eric Blake
     [not found]   ` <6ceb7075-71fc-b725-8a1c-a7d8c727770e-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-10-19 19:41     ` Dan Williams
2016-10-19 19:41       ` Dan Williams
     [not found]       ` <CAPcyv4gbRE-ALJM6EHv6fM3Kq02HeZFMLF5T63J5qaJmHWvQCg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-19 21:29         ` Dan Williams
2016-10-19 21:29           ` Dan Williams
2016-10-19 23:46           ` Eric Blake [this message]
2016-10-19 23:46             ` Eric Blake
     [not found]             ` <708947f5-dfdc-d6c9-4523-7436959119f3-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-10-19 23:56               ` Dan Williams
2016-10-19 23:56                 ` Dan Williams
2016-10-20 19:32 ` Vishal Verma
2016-10-20 19:32   ` [Qemu-devel] " Vishal Verma
2016-10-20 20:06   ` Dan Williams
2016-10-20 20:06     ` [Qemu-devel] " Dan Williams

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=708947f5-dfdc-d6c9-4523-7436959119f3@redhat.com \
    --to=eblake@redhat.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-nvdimm@ml01.01.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vishal.l.verma@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.