Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -gLp to zpool subcommands for alt vdev names #4343

Closed
wants to merge 1 commit into from

Conversation

behlendorf
Copy link
Contributor

The following options have been added to the zpool add, iostat,
list, status, and split subcommands. The default behavior was
not modified, from zfs(8).

-g Display vdev GUIDs instead of the normal short
device names. These GUIDs can be used in-place of
device names for the zpool detach/off‐
line/remove/replace commands.

-L Display real paths for vdevs resolving all symbolic
links. This can be used to lookup the current block
device name regardless of the /dev/disk/ path used
to open it.

-p Display full paths for vdevs instead of only the
last component of the path. This can be used in
conjunction with the -L flag.

This change is based on worked originally started by Richard Yao
to add a -g option. Then extended by @ilovezfs to add a -L option
for openzfsonosx. Those changes have been merged, re-factored,
a -p option added and extended to all relevant zpool subcommands.

Original-patch-by: Richard Yao ryao@gentoo.org
Extended-by: ilovezfs ilovezfs@icloud.com
Extended-by: Brian Behlendorf behlendorf1@llnl.gov
Issue #2011
Issue #4341

@behlendorf
Copy link
Contributor Author

@ryao @ilovezfs I took the opportunity to build on the work you've both done adding options to control the output of vdevs names show by various zpool subcommands. This is a refactoring of those changes with an additional options, -p, and extending it to more of the subcommands. It would be great if I could get your feedback. This has been lightly tested and works as expected.

@ryao
Copy link
Contributor

ryao commented Feb 18, 2016

@behlendorf I see that you are burning the midnight oil on this. :)

The thing that kept this from being accepted in the past was that people wanted to see nvlists used and I never made time to refactor it, although an int is enough for an internal interface.

There is nothing that jumps out at me as being bad in this patch.

.ad
.RS 12n
.rt
Display vdev GUIDs instead of the normal short device names. These GUIDs can be used in-place of device names for the zpool detach/offline/remove/replace commands.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"in place" not "in-place"

@ilovezfs
Copy link
Contributor

@behlendorf ryao is referring to
#2012 (comment)
#2012 (comment)

I'm not sure I ever actually really "agreed" with that, but it's the reason I used an nvlist. I think I actually prefer the flag instead, but it would be good if you could explain why you think it's a good idea to use a flag and not an nvlist as @wca had been requesting.

@ilovezfs
Copy link
Contributor

"detach/offline/remove/replace"

Does it work with online, split, or reopen (undocumented) also?

extern char *zpool_vdev_name(libzfs_handle_t *, zpool_handle_t *, nvlist_t *,
boolean_t verbose);
int name_flags);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryao Is libzfs.h sufficiently "internal" to consider this an "internal interface"?

The following options have been added to the zpool add, iostat,
list, status, and split subcommands.  The default behavior was
not modified, from zfs(8).

  -g    Display vdev GUIDs  instead  of  the  normal  short
        device  names.  These GUIDs can be used in-place of
        device   names   for    the    zpool    detach/off‐
        line/remove/replace commands.

  -L    Display real paths for vdevs resolving all symbolic
        links. This can be used to lookup the current block
        device  name regardless of the /dev/disk/ path used
        to open it.

  -p    Display  full  paths  for vdevs instead of only the
        last component of the path.  This can  be  used  in
        conjunction with the -L flag.

This behavior may also be enabled using the following environment
variables.

  ZPOOL_VDEV_NAME_GUID
  ZPOOL_VDEV_NAME_FOLLOW_LINKS
  ZPOOL_VDEV_NAME_PATH

This change is based on worked originally started by Richard Yao
to add a -g option.  Then extended by @ilovezfs to add a -L option
for openzfsonosx.  Those changes have been merged, re-factored,
a -p option added and extended to all relevant zpool subcommands.

Original-patch-by: Richard Yao <ryao@gentoo.org>
Extended-by: ilovezfs <ilovezfs@icloud.com>
Extended-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue openzfs#2011
Issue openzfs#4341
@behlendorf
Copy link
Contributor Author

The thing that kept this from being accepted in the past was that people wanted to see nvlists used and I never made time to refactor it, although an int is enough for an internal interface.

Actually, I was under the exact opposite impression. One of the reasons it wasn't accepted was because it did introduce this nvlist. At least personally I felt it was an unnecessary complication for very little gain. I should have been clearer about that in the original PR. Let's debate the point though if you feel strongly about it.

Does it work with "detach/offline/remove/replace"

No it doesn't. It was added to the expected status/iostat/list commands and other command which supported a dryrun option. Although it looks like I missed zpool create. Are there any others you can think of which should support this?

@ilovezfs
Copy link
Contributor

@behlendorf Personally I prefer the flag. I just wanted to make sure everyone's on the same page about what the requirements should or shouldn't be.

No it doesn't.

I don't think I was clear. I was actually quoting the new man page entries regarding the use of the printed GUIDs:

Display vdev GUIDs instead of the normal device names. These GUIDs can be used in place of device names for the zpool detach/offline/remove/replace commands.

That references specific commands that accept GUID but I don't think it's a complete list.

Does it work with online, split, or reopen (undocumented) also?

The "it" in question is the ability to accept GUIDs in place of device names. Is "detach/offline/remove/replace" actually the full list?

@behlendorf
Copy link
Contributor Author

That references specific commands that accept GUID but I don't think it's a complete list.

I suspect you're right. Most command should accept guids but I'm not sure if they all do.

@behlendorf
Copy link
Contributor Author

@ilovezfs @ryao are we agreed that this is a reasonable approach? If so can I add your signed-off-by and merge this.

@ilovezfs
Copy link
Contributor

Yeah, the only outstanding concern I have is that each additional format if more are added will consume another option in each command that uses this. Would it be better to have this be a -o format=%g type thing?

@behlendorf
Copy link
Contributor Author

That would certainly be more flexible. I flirted with a similar idea but eventually decided against it because I felt it would be a somewhat awkward interface. While we are using a few extra flags, which isn't ideal, I personally think it's a tradeoff worth making in this case.

@ilovezfs
Copy link
Contributor

@behlendorf OK, that's fine. If someone else wants to complain about that, they can make some other pull request changing the CLI accordingly. I have no further objections.

@behlendorf
Copy link
Contributor Author

Merged as:

d2f3e29 Add -gLp to zpool subcommands for alt vdev names

@behlendorf behlendorf closed this Feb 25, 2016
@timemaster67
Copy link

There is a documentation error in this pull request.
switch "-p" does not work and return "invalid option 'p'"
Instead, switch "P" (uppercase P) is recognised and does the intended behavior.

invalid option 'p'
usage:
status [-gLPvxD] [-T d|u] [pool] ... [interval [count]]

@behlendorf
Copy link
Contributor Author

@timemaster67 this was addressed by commit a77f29f.

@behlendorf behlendorf deleted the issue-2012 branch April 19, 2021 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants