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

vdev type missing in zpool status #57

Closed
behlendorf opened this issue Aug 31, 2010 · 15 comments
Closed

vdev type missing in zpool status #57

behlendorf opened this issue Aug 31, 2010 · 15 comments
Milestone

Comments

@behlendorf
Copy link
Contributor

Interestingly the top level vdev type is missing from the zpool status command. It should say 'raidz2-0' below instead of just '-0'. Everything appears OK for other top level vdev types. This is probably a pretty easy bug I just wanted to file it so I don't forget.

$ sudo ./cmd/zpool/zpool status tank
  pool: tank
 state: ONLINE
 scan: none requested
config:

    NAME        STATE     READ WRITE CKSUM
    tank        ONLINE       0     0     0
      -0        ONLINE       0     0     0
        loop0   ONLINE       0     0     0
        loop1   ONLINE       0     0     0
        loop2   ONLINE       0     0     0
        loop3   ONLINE       0     0     0
$ sudo ./cmd/zpool/zpool status
  pool: tank
 state: ONLINE
 scan: none requested
config:

    NAME        STATE     READ WRITE CKSUM
    tank        ONLINE       0     0     0
      mirror-0  ONLINE       0     0     0
        loop0   ONLINE       0     0     0
        loop1   ONLINE       0     0     0
      mirror-1  ONLINE       0     0     0
        loop2   ONLINE       0     0     0
        loop3   ONLINE       0     0     0
@bitloggerig
Copy link

This issue is back again:

# zpool status storage
  pool: storage
 state: ONLINE
 scan: scrub repaired 0 in 6h36m with 0 errors on Sun Mar 11 09:46:45 2012
config:

        NAME                                 STATE     READ WRITE CKSUM
        storage                              ONLINE       0     0     0
          -0                                 ONLINE       0     0     0
            ata-ST2000DL003-9VT166_5YD0WD7H  ONLINE       0     0     0
            ata-ST2000DL003-9VT166_5YD0WEGB  ONLINE       0     0     0
            ata-ST2000DL003-9VT166_5YD0WEVK  ONLINE       0     0     0

@mgmartin
Copy link

I came across this cosmetic issue on current builds. zpool status only shows -0 . Suggest a Reopen .

@dechamps
Copy link
Contributor

I confirm this on rc10:

# zpool status
  pool: zyklos
 state: ONLINE
 scan: resilvered 16K in 0h0m with 0 errors on Tue Oct 25 21:08:39 2011
config:

NAME                                             STATE     READ WRITE CKSUM
zyklos                                           ONLINE       0     0     0
  -0                                             ONLINE       0     0     0
    scsi-SATA_WDC_WD20EARX-00_WD-WMAZA5001367    ONLINE       0     0     0
    scsi-SATA_WDC_WD20EARX-00_WD-WMAZA5001577    ONLINE       0     0     0
    scsi-SATA_WDC_WD20EARX-00_WD-WMAZA5049004    ONLINE       0     0     0
    scsi-SATA_WDC_WD20EARX-00_WD-WMAZA5316968    ONLINE       0     0     0
    scsi-SATA_WDC_WD20EARX-00_WD-WMAZA5325048    ONLINE       0     0     0
    scsi-SATA_WDC_WD20EARX-00_WD-WMAZA5610759    ONLINE       0     0     0
logs
  ata-M4-CT128M4SSD2_00000000113703195874-part3  ONLINE       0     0     0
cache
  ata-M4-CT128M4SSD2_00000000113703195874-part4  ONLINE       0     0     0

errors: No known data errors

No idea what causes it, though.

@behlendorf behlendorf reopened this Aug 30, 2012
@behlendorf
Copy link
Contributor Author

The original issue was fixed by commit 858219c which still looks intact. This is going to take some digging to see what happened, but since it's a regression we want it fixed before -rc11.

@mgmartin
Copy link

I did a little more digging around in here. It seems commit 858219c make more sense down below in the "if (verbose)" section of the code. Initially, buf and path would never point to the same location. Once path = buf is set on a raidz vdev, the code may drop into the verbose section depending on the verbose flag. In here, using a tmpbuf makes sense since now, buf==path . My initial test with this patch applied to rc-10 shows the correct values. First time patch post for me, so let me if there is a more-appropriate procedure.

Results with patch applied:

root@debian:~# zpool status -v
  pool: test
 state: ONLINE
 scan: none requested
config:

    NAME          STATE     READ WRITE CKSUM
    test          ONLINE       0     0     0
      raidz1-0    ONLINE       0     0     0
        /root/d1  ONLINE       0     0     0
        /root/d2  ONLINE       0     0     0
        /root/d3  ONLINE       0     0     0

errors: No known data errors

  pool: test2
 state: ONLINE
 scan: none requested
config:

    NAME          STATE     READ WRITE CKSUM
    test2         ONLINE       0     0     0
      mirror-0    ONLINE       0     0     0
        /root/d4  ONLINE       0     0     0
        /root/d5  ONLINE       0     0     0

errors: No known data errors

  pool: test3
 state: ONLINE
 scan: none requested
config:

    NAME        STATE     READ WRITE CKSUM
    test3       ONLINE       0     0     0
      /root/d6  ONLINE       0     0     0

errors: No known data errors
root@debian:~# zpool iostat -v
                 capacity     operations    bandwidth
pool          alloc   free   read  write   read  write
------------  -----  -----  -----  -----  -----  -----
test           172K   286M      0      0      2     32
  raidz1       172K   286M      0      0      2     32
    /root/d1      -      -      0      0     27    303
    /root/d2      -      -      0      0     26    303
    /root/d3      -      -      0      0     27    303
------------  -----  -----  -----  -----  -----  -----
test2           93K  95.4M      0      3    246  3.15K
  mirror        93K  95.4M      0      3    246  3.15K
    /root/d4      -      -      0      2    700  30.4K
    /root/d5      -      -      0      2    454  30.4K
------------  -----  -----  -----  -----  -----  -----
test3           90K  95.4M      0      2    855  37.0K
  /root/d6      90K  95.4M      0      2    855  37.0K
------------  -----  -----  -----  -----  -----  -----
diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c
index 68bfdee..4f2de99 100644
--- a/lib/libzfs/libzfs_pool.c
+++ b/lib/libzfs/libzfs_pool.c
@@ -3205,14 +3205,14 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
                /*
                 * If it's a raidz device, we need to stick in the parity level.
                 */
+
                if (strcmp(path, VDEV_TYPE_RAIDZ) == 0) {
-                       char tmpbuf[PATH_BUF_LEN];

                        verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NPARITY,
                            &value) == 0);
-                       (void) snprintf(tmpbuf, sizeof (tmpbuf), "%s%llu", path,
+                       (void) snprintf(buf, sizeof (buf), "%s%llu", path,
                            (u_longlong_t)value);
-                       path = tmpbuf;
+                       path = buf;
                }

                /*
@@ -3220,13 +3220,14 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
                 * naming convention.
                 */
                if (verbose) {
+                       char tmpbuf[PATH_BUF_LEN];
                        uint64_t id;

                        verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_ID,
                            &id) == 0);
-                       (void) snprintf(buf, sizeof (buf), "%s-%llu", path,
+                       (void) snprintf(tmpbuf, sizeof (tmpbuf), "%s-%llu", path,
                            (u_longlong_t)id);
-                       path = buf;
+                       path = tmpbuf;
                }
        } 

@behlendorf
Copy link
Contributor Author

@mgmartin: Your fix looks good to me. When submit a patch you'll want to open a pull request with the change. This allows me to easily review it, merge it, and properly attribute the path. Here's a link which describes the process:

https://help.github.com/articles/using-pull-requests

@behlendorf
Copy link
Contributor Author

@mgmartin I'd like to get this merged but I want to properly attribute you with the fix. I'm happy to do the leg work merging the patch but I need a name and email address from you for the commit author field.

@mgmartin
Copy link

mgmartin commented Sep 5, 2012

Thanks, Brian. My public email should be visible here now. I'll work on getting familiar with the pull requests features of git hub for future fixes.

@behlendorf
Copy link
Contributor Author

Great, I'll get it done tomorrow.

@imp
Copy link
Contributor

imp commented Sep 5, 2012

In the if (verbose) case the tmpbuf variable is local to this if clause and "path = tmpbuf" sends its address beyond the if () construct. Does it feel right ?

@mgmartin
Copy link

mgmartin commented Sep 5, 2012

tmpbuf goes out of scope, but the stack allocated array--which path now points to--remains on the stack through the return call where zfs_strdup returns a copy of the array. Moving tmpbuf scope up would always allocated the space on the stack--even when verbose was false.

@behlendorf
Copy link
Contributor Author

Indeed, I'll widen the scope of tmpbuf. I'm a bit surprised gcc didn't catch this.

@mgmartin
Copy link

mgmartin commented Sep 6, 2012

I think it's fine where it's at. My point was it could be moved up, but where it is now shouldn't cause any issues, and avoids creating the buffer if it's not going to be used.

@behlendorf
Copy link
Contributor Author

It works, but it doesn't feel safe. At that point we're just counting on the fact that nothing else will touch that bit of the stack. It happens to be true right now, but another code block added latter in the function could cause that chunk of the stack to be overwritten and that would be a pain to debug.

@mgmartin
Copy link

mgmartin commented Sep 6, 2012

Good point. I was assuming the stack wasn't really freed until the entire method was finished. I'll have too look into how that works, but better safe.

Follow up: My assumption was wrong. A quick test program shows how it could definitely be clobbered by later code. Good catch.

richardelling pushed a commit to richardelling/zfs that referenced this issue Oct 15, 2018
Replace redundant_metadata all value by none, which should be the new
default. We cannot extend the set of existing values (all and most),
because of compatibility reason.

Fix minor ref count leak on mgmt connection due to iscsi target quering
zvol which is not associated with mgmt connection.

Signed-off-by: Jan Kryl <jan.kryl@cloudbyte.com>
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

No branches or pull requests

5 participants