-
Couldn't load subscription status.
- Fork 1.9k
zpool: Add zpool status -vv error ranges #17864
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
base: master
Are you sure you want to change the base?
Conversation
|
Sample output: |
|
Just the filenames (JSON): |
Print the byte error ranges with 'zpool status -vv'. This works with the normal zpool status formatting flags (-p, -j, --json-int). In addition: - Move range_tree/btree to common userspace/kernel code. - Modify ZFS_IOC_OBJ_TO_STATS ioctl to optionally return "extended" object stats. - Let zinject corrupt zvol data. - Add test case. This commit takes code from these PRs: openzfs#17502 openzfs#9781 openzfs#8902 Signed-off-by: Tony Hutter <[email protected]> Co-authored-by:: Alan Somers <[email protected]> Co-authored-by: TulsiJain <[email protected]>
45b19a7 to
eb6a882
Compare
|
|
||
| /* Resolve symlinks to /dev/zd* device */ | ||
| if (realpath(inpath, buf) != NULL) | ||
| if (strncmp(buf, "/dev/zd", 7) == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (strncmp(buf, "/dev/zd", 7) == 0) | |
| if (strncmp(buf, "/dev/" ZVOL_DEV_NAME, 7) == 0) |
| char *slash; | ||
| int rc; | ||
| if ((fd = open(inpath, O_RDONLY|O_CLOEXEC)) == -1 || | ||
| fstat64(fd, statbuf) != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If fstat64() fails the file won't be closed. Let's simply split this in to two conditional blocks and add the close.
| if (path_is_zvol(inpath)) { | ||
| int fd; | ||
| char *slash; | ||
| int rc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing newline after the declarations.
| * | ||
| * So we hardcode that in the statbuf inode field as workaround. | ||
| */ | ||
| statbuf->st_ino = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| statbuf->st_ino = 1; | |
| statbuf->st_ino = ZVOL_OBJ; |
| if (rc != 0) | ||
| return (-1); | ||
|
|
||
| (void) strcpy(dataset, fullpath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| (void) strcpy(dataset, fullpath); | |
| (void) strlcpy(dataset, fullpath, MAXNAMELEN); |
| } | ||
|
|
||
| /* | ||
| * Given an properties nvlist like: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * Given an properties nvlist like: | |
| * Given a properties nvlist like: |
| nodist_libzfs_la_SOURCES = \ | ||
| module/zcommon/btree.c \ | ||
| module/zcommon/cityhash.c \ | ||
| module/zcommon/range_tree.c \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the btree and range_tree code is needed by libzfs we should build it as noinst convenience libraries (like libavl). To do that we'll need to make sure they're fully generic and don't have any accidental dependencies on other zfs structures or functions. This doesn't look like it should be too bad.
| /* | ||
| * highbit64 is defined in sysmacros.h for the kernel side. However, we need | ||
| * it on the libzfs side and zpool_main.c side, and there's no good place to | ||
| * put it but here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib/libspl/include/os/linux/sys/sysmacros.h would be a better spot for this. This might already be defined on the FreeBSD side, it wasn't immediately clear to me.
| VERIFY0(nvlist_add_uint32(nv, ZFS_OBJ_STAT_METADATA_BLOCK_SIZE, | ||
| doi.doi_metadata_block_size)); | ||
| VERIFY0(nvlist_add_uint64(nv, ZFS_OBJ_STAT_TYPE, | ||
| doi.doi_type)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also provide the object type converted from a uint64 to a string here. That way user space doesn't have to know how to do the translation and dmu_ot can stay where it is. Alternately, we'd need to move it to sys/dmu.h. We should give the same treatment to doi_bonus_type, so we'd have the following keys.
ZFS_OBJ_STAT_TYPE
ZFS_OBJ_STAT_TYPE_STR
ZFS_OBJ_STAT_BONUS_TYPE
ZFS_OBJ_STAT_BONUS_TYPE_STR
You'll also want the make sure to include the names from the extended types. Here's an example from the zdb code.
VERIFY0(dmu_object_info(mos, object, &doi));
if (doi.doi_type & DMU_OT_NEWTYPE) {
dmu_object_byteswap_t bswap =
DMU_OT_BYTESWAP(doi.doi_type);
name = dmu_ot_byteswap[bswap].ob_name;
} else {
name = dmu_ot[doi.doi_type].ot_name;
}| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #define panic(...) do {printf(__VA_ARGS__); exit(EXIT_FAILURE); } while (0) | ||
| #define zfs_panic_recover(...) do {printf(__VA_ARGS__); } while (0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll want to get this code to build in user space using the existing compatility wrappers. Here are a couple of thoughts which should work as long as sys/debug.h is included.
panic -> PANIC
zfs_panic_recover we should probably redefine to a PANIC.
You should be able to replace the zfs_dbgmsg and VERIFY3U with a single VERIFY3UF that will do the right thing in both user and kernel space.
Motivation and Context
Print error byte ranges with
zpool status -vvDescription
Print the byte error ranges with 'zpool status -vv'. This works with all the normal zpool status formatting flags:
-p,-j,--json-intIn addition:
This commit takes code from these PRs: #17502 #9781 #8902
How Has This Been Tested?
Test case added
Types of changes
Checklist:
Signed-off-by.