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

tcmu_dev_get_memory_info() #588

Merged
merged 1 commit into from
Sep 9, 2019
Merged

Conversation

dfsmith
Copy link

@dfsmith dfsmith commented Aug 23, 2019

Our handler/device needs more information about the tcmu shared memory block (so that it can pass offsets to another process). This patch adds a function to retrieve that information about the shared memory.

Also updated install_dep.sh so that it works with Debian installations.

Copy link
Collaborator

@lxbsz lxbsz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems you have messed up your new commits and the exist ones, please rebase to the upstream and push it again.

extra/install_dep.sh Outdated Show resolved Hide resolved
libtcmu.c Outdated Show resolved Hide resolved
libtcmu.c Outdated Show resolved Hide resolved
libtcmu.c Outdated Show resolved Hide resolved
libtcmu_common.h Outdated Show resolved Hide resolved
libtcmu.c Outdated Show resolved Hide resolved
libtcmu.c Outdated Show resolved Hide resolved
libtcmu.c Outdated Show resolved Hide resolved
@dfsmith
Copy link
Author

dfsmith commented Aug 26, 2019

Thank you everyone for your comments (and dedication to keeping the source and history clean).
I've incorporated your comments, and hope this pull request is more in-keeping with the project.

Note: I couldn't stomach making the goto err_* maze in add_device() even more complex, so the allocs are now at the start of the function. Both must succeed or -ENOMEM is returned.

@lxbsz
Copy link
Collaborator

lxbsz commented Aug 27, 2019

@dfsmith
BTW, in both of your commits there are no "Signed-off-by".
Is that okay @mikechristie ?

All the others looks good to me.
Thanks.

@mikechristie
Copy link
Collaborator

Note: I couldn't stomach making the goto err_* maze in add_device() even more complex, so the allocs are now at the start of the function. Both must succeed or -ENOMEM is returned.

Fix the unwinding so it works like the other code. It may be more complex to you, but not to the others that are used to the linux kernel style of goto error unwinding.

libtcmu.c Outdated
mmap_name = tcmu_dev_get_memory_info(dev, NULL, NULL, &mmap_offset);
if (!mmap_name) {
free(dev);
dev = NULL;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the other code in this repo works like this, so when scanning and handling errors we would have to account for the goto style and your style. Use the goto style so it matches the existing code and so everyone else does not have to adjust for your style.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem! This is a slightly more invasive patch*, but is more in keeping with the rest of the file.

Let me know if you need it rebased.

(On a philosophical note, my original coding choice was because the "goto unwind" style is error-prone when re-ordering resource allocations with many exit paths. add_device(), specifically, is long and complex. I'd quite like to split this procedure into separate nested "allocation" and "discovery" functions, but it would be a more disruptive patch.)

  • Mostly because there was another (misnamed?) "ret" variable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know what you mean. I agree with you that add_device is getting nasty. Feel free to break it up. It would be really nice.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I broke up add_device() and renamed it device_add() for (sorting) consistency with its subroutines. The chiastic structure of the goto unwind is now more apparent. Since this is a trivial but substantial change, it might be worth another pair of eyes following the device_add() logic. I believe it to be equivalent to the master code (with some extra checks and one minor bug fixed).

extra/install_dep.sh Outdated Show resolved Hide resolved
libtcmu.c Outdated Show resolved Hide resolved
libtcmu.c Outdated Show resolved Hide resolved
libtcmu.c Show resolved Hide resolved
libtcmu.c Outdated Show resolved Hide resolved
libtcmu.c Outdated Show resolved Hide resolved
@mikechristie
Copy link
Collaborator

Just some minor coding style nits. I swear I am not trying to be a pain in the butt about that :) Thanks for the updated patch with all the cleanups!

Split add_device() into multiple functions.
Rename add_device() -> device_add().
Rename remove_device() -> device_remove().
@dfsmith
Copy link
Author

dfsmith commented Sep 7, 2019

Thank you for spotting the nits. Keep it up!

@mikechristie
Copy link
Collaborator

Thanks!

@mikechristie mikechristie merged commit 1c62cc4 into open-iscsi:master Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants