Page MenuHomeFreeBSD

savecore: uncompress cores
ClosedPublic

Authored by glebius on Nov 16 2020, 10:22 PM.
Tags
None
Referenced Files
F103239694: D27245.id79733.diff
Fri, Nov 22, 1:07 PM
F103227081: D27245.id79684.diff
Fri, Nov 22, 10:26 AM
F103225811: D27245.diff
Fri, Nov 22, 10:10 AM
Unknown Object (File)
Mon, Nov 18, 11:37 AM
Unknown Object (File)
Mon, Nov 18, 8:11 AM
Unknown Object (File)
Sun, Nov 17, 9:54 AM
Unknown Object (File)
Sun, Nov 17, 6:55 AM
Unknown Object (File)
Sun, Nov 3, 11:39 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 34840
Build 31870: 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
750

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
576

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

995

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
504

sizeof(z)

520

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

521

There's a missing newline here.

551

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
520

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

sbin/savecore/savecore.c
520

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
520

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