Page MenuHomeFreeBSD

savecore: uncompress cores
ClosedPublic

Authored by glebius on Nov 16 2020, 10:22 PM.
Tags
None
Referenced Files
F103537646: D27245.diff
Tue, Nov 26, 6:05 AM
Unknown Object (File)
Sun, Nov 24, 1:09 PM
Unknown Object (File)
Sat, Nov 23, 1:11 AM
Unknown Object (File)
Sat, Nov 23, 12:39 AM
Unknown Object (File)
Fri, Nov 22, 1:07 PM
Unknown Object (File)
Fri, Nov 22, 10:26 AM
Unknown Object (File)
Fri, Nov 22, 10:10 AM
Unknown Object (File)
Mon, Nov 18, 11:37 AM
Subscribers

Details

Summary

A real life scenario is that cores are compressed to reduce
size of dumpon partition, but we either don't care about space
in the /var/crash or we have a filesystem level compression of
/var/crash. And we want cores to be uncompressed in /var/crash
because we'd like to instantily read them with kgdb.

In this case we want kernel to write cores compressed, but
savecore(1) write them uncompressed.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 34897
Build 31918: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Nov 16 2020, 10:53 PM
bcr added a subscriber: bcr.

OK from manpages.

Shouldn't this also include a change to default savecore_flags in /etc/defaults/rc.conf?

This patch doesn't support ZSTD yet, since the library isn't yet installed in the base system and I'm reluctant to statically compile it into savecore(1).

It's there, it's just a private lib: /usr/lib/libprivatezstd.so.5

sbin/savecore/savecore.c
799

Why not set uncompress = false here too?

Add ZSTD support and address comments.

This revision now requires review to proceed.Nov 17 2020, 9:02 PM

Shouldn't this also include a change to default savecore_flags in /etc/defaults/rc.conf?

I don't want to change the default behavior.

Looks fine to except some nits.

sbin/savecore/savecore.c
637

The compression == KERNELDUMP_COMP_* cases should be lifted into their own subroutines IMO.

1037

It is easier to understand this when written as (iscompressed && !uncompress) || compress).

Separate decompression loops into their own subroutines. Reword
logical statement.

Some extra cruft slept in previous update.

glebius marked an inline comment as done.
markj added inline comments.
sbin/savecore/savecore.c
569

sizeof(z)

585

Static analyzers will complain that this buffer is leaked. I know it's not a real problem, but it's also easy to fix.

586

There's a missing newline here.

612

I think compression != KERNELDUMP_COMP_NONE is preferable.

This revision is now accepted and ready to land.Nov 19 2020, 2:13 AM
glebius added inline comments.
sbin/savecore/savecore.c
585

Yes. But function has several returns with different allocation conditions. Make it "right" everywhere would make it really hairy.

sbin/savecore/savecore.c
585

You would have to add three free(zbuf) calls, relying on the fact that zbuf is initialized to NULL and that free(NULL) is valid. Not really that hairy. Someone else is inevitably going to come along and fix it anyway, for better or worse, so IMO it's better to just do it now.

sbin/savecore/savecore.c
585

To do it properly the zstd context also needs to be freed, and this is where it gets hairy.