Skip to content

zdb gets confused by datasets starting with numbers #12845

@rincebrain

Description

@rincebrain

System information

Type Version/Name
Distribution Name Debian
Distribution Version 11
Kernel Version 5.10.0-9-amd64
Architecture x86_64
OpenZFS Version c9d62d1 or so

Describe the problem you're observing

(I'll go figure out a "correct" handling for this later, I just wanted to mention it in case I forgot after I ran into it...)

I tried to examine a child dataset under a dataset named "1M", at the top of a pool, "lz4newtestpool".

# sudo zdb -dbdbdbdbdbdb lz4newtestpool/1M/largefiles 256
failed to hold objset 1: Invalid argument
zdb: can't open 'lz4newtestpool/1M/largefiles': Invalid argument

But if I rename 1M to sigh1M, it works as expected.

I would presume this is due to:

zfs/cmd/zdb/zdb.c

Lines 8525 to 8539 in 510885a

char *endptr;
errno = 0;
objset_id = strtoull(objset_str, &endptr, 0);
/* dataset 0 is the same as opening the pool */
if (errno == 0 && endptr != objset_str &&
objset_id != 0) {
target_is_spa = B_FALSE;
dataset_lookup = B_TRUE;
} else if (objset_id != 0) {
printf("failed to open objset %s "
"%llu %s", objset_str,
(u_longlong_t)objset_id,
strerror(errno));
exit(1);
}

since patching the second check to not exit(1) and reset objset_id to -1 allows us to proceed, albeit having printed the error.

Describe how to reproduce the problem

sudo zdb -d pool/1zzz

Include any warning/errors/backtraces from the system logs

GOTO 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: DefectIncorrect behavior (e.g. crash, hang)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions