Skip to content
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

More bugfixes and remove infrastructure #148

Merged
merged 4 commits into from
Oct 10, 2023
Merged

Conversation

bmarzins
Copy link
Member

@bmarzins bmarzins commented Oct 9, 2023

I still keep having other things on my plate that are keeping me from being able to finish up the remove work. Instead, I'll just send you what I currently have, so you can see the direction I'm heading. I've split out the remove work from the regular scan work, although it still uses the "usid scan" command, since there is a lot of code overlap with regular scans. It currently doesn't do anything special on removes. That's what I'm working on next. Also, here are fixes for two bugs that were keeping resyncing the device hierarchy from working on removes.

When _delta_step_calc() is building the delta buffers, it can add
entries to the delta->final and delta->minus buffers that point to data
stored in the old vvalue (delta->plus will only ever point to new data,
which isn't stored in the old vvalue). When _kv_delta_set finally writes
the new vvalue from delta->final, the old vvalue is freed. This means
that there can be entries in delta->final and delta->minus that point to
freed memory. The same thing can happen to abs_delta->plus and
abs_delta->minus after those are written out.

Where this is actually visible is when a device is removed and the
device hierarchy is updated. In this case, delta->minus ends up with
entries pointing to freed memory. If that memory is overwritten, it
will effect both the DELTA_WITH_DIFF and DELTA_WITH_REL output.

The easiest way to avoid this is to run _kv_delta_set() inside a
transaction, so the old values don't get freed until the end, when
the transaction is ended.
_refresh_device_partition_hierarchy_from_sysfs() always assumed that
the partition was being added.
If SID fails to get the module name at all, it will not run the ident
functions of the block modules. However, it will run all the other scan
phase functions. In all these other scan phase functions, the block
modules will be run, regardless of whether the device has a type module,
even if the module name couldn't be determined.  Make the ident phase
also run the block modules, even if the module name can't be determined,
to be consistent.
Instead of using the regular scan phases for removes, use a separate
set, with just the same initialization and cleanup as a regular scan.
The main remove is done in two phases. The first calls the new module
function, scan_remove for the appropriate type and block modules.
These are currently all stubs. The second phase removes the core SID
kvstore values. Currently this just removes the device from the
device hierarchy in the kvstore.
@prajnoha
Copy link
Member

prajnoha commented Oct 10, 2023

Yup, that looks good. The "fix freed memory access in _kv_delta_set" - wow, that was quite a bug, slipped through the cracks. Thanks!

@prajnoha prajnoha merged commit 59e818b into sid-project:main Oct 10, 2023
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants