-
Notifications
You must be signed in to change notification settings - Fork 33
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
[WIP] Fix: avoid using deprecated valloc & frequent aligned alloc #134
Conversation
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.
Looks good to me
src/sbd-md.c
Outdated
@@ -108,6 +109,7 @@ open_device(const char* devname, int loglevel) | |||
|
|||
if (io_setup(1, &st->ioctx) != 0) { | |||
cl_perror("io_setup failed"); | |||
free(st->buffer); |
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.
This isn't necessary since st is allocated just above here, and buf hasn't been set yet
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.
But doesn't hurt either ;-)
Added when I was still undecided what to do first.
Anyway whole thing wasn't meant to be reviewed yet - just wanted to see posix_memalign being handled by all the targets CI builds against.
src/sbd-md.c
Outdated
@@ -120,6 +122,7 @@ open_device(const char* devname, int loglevel) | |||
} else { | |||
cl_log(loglevel, "Opening device %s failed.", devname); | |||
} | |||
free(st->buffer); |
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.
ditto here
coverity seems to be complaining about a pre-existing memory leak in header_get() |
74a4449
to
f9bf272
Compare
Yeah allocation method changed so that preexisting baseline doesn't match anymore. |
That's what I was thinking too
Sounds reasonable |
f9bf272
to
3c7a550
Compare
switch to using a single aligned buffer that stays allocated. - free to use allocation mechanism that doesn't allow to use free() to hand back (not needed for current posix_memalign) - avoid memory fragmentation risk (and thus risk to run out of hogged memory) due to frequent alloc/free of aligned memory
d500274
to
bdd28f9
Compare
8a004d2
to
dd3004a
Compare
Looks good after a quick review without getting too deep into it If we're going to introduce a compatibility break with pacemaker, I'm wondering if we have enough information requirements to make a public library worthwhile. Pacemaker SBD support could depend on the availability of the library, which would provide equivalents of panic_sbd(), pcmk__locate_sbd(), pcmk__get_sbd_timeout(), and pcmk__get_sbd_sync_resource_startup(). We could possibly drop the requirement that SBD and pacemaker be built with the same sync default, instead pacemaker could adapt to SBD's default. |
...
You mean a library coming from the sbd-package? |
Yes
I wasn't thinking of putting anything pacemaker-related in sbd's public API, since that's just for sbd's internal use. The public API would just have low-level stuff for external code to check on sbd. It should be segregated in a separate directory and not use any pacemaker APIs. |
That wasn't my point. sbd already has pacemaker as build-time requirement. |
Ah right, of course. Hmm. Isolating the pacemaker-related stuff into the pacemaker project or even its own project could be worthwhile. I believe at one point we had discussed making the interface more generic so the corosync/pacemaker stuff wasn't so tightly integrated. I'm not sure if that would open any demand for other sbd "plugins" but it could be interesting. The question is whether it's worth the effort ... |
dd3004a
to
9e6cbba
Compare
As said moved the start-type things to a separate PR to concentrate on aligned-allocation and fix of use of the AIO API with this PR. |
looks good to me |
Specifically about |
That's more relevant to #135, which was stripped out of this one so it could focus on the memory alignment and async I/O usage issues |
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.
The switch to posix_memalign() and the relevant changes/fixes look sensible and thorough to me. Nice work, thanks!
Fix: avoid using deprecated valloc & frequent aligned alloc
switch to using a single aligned buffer that stays allocated.
free to use allocation mechanism that doesn't allow to
use free() to hand back (not needed for current posix_memalign)
avoid memory fragmentation risk (and thus risk to run out of
hogged memory) due to frequent alloc/free of aligned memory
Switching from
forking
tosimple
should probably bethought over again as sbd is doing quite some checks that
should be done before systemd should assume sbd as started
and thus start pacemaker.
Nothing severe should happen though since we have startup-
synchronization between the daemons meanwhile.
To leave legacy
forking
startup behind and still have thebehavior that pacemaker is just started by systemd when sbd
has checked config, watchdog-device & disks
notify
isprobably the only way.
More important is that pacemaker is atm using the sbd-pid-file to
detect a running sbd-daemon and thus assume it should
synchronize with it. More robust would probably be to ask
systemd (if compiled with systemd-support) if sbd is enabled
and it would work without a pid-file.