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

Fix casync seed slot mounting of already-ro-mounted slots #774

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

j-licht
Copy link
Contributor

@j-licht j-licht commented Sep 21, 2021

Check mount options of the seed slot.
Unmount seed slot on casync failure too.

Esco441-91
Esco441-91 previously approved these changes Oct 19, 2021
Copy link

@Esco441-91 Esco441-91 left a comment

Choose a reason for hiding this comment

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

I've reviewed it and functionally I had no complaints. I only found few formatting changes based on defined coding style.

This was my first review on RAUC. I would appreciate if someone else would review this aswell.

src/slot.c Outdated

for (GList *l = g_unix_mounts_get(NULL); l != NULL; l = l->next) {
GUnixMountEntry *m = (GUnixMountEntry*)l->data;
if (g_strcmp0(g_unix_mount_get_device_path(m),slot->device) == 0) {

Choose a reason for hiding this comment

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

This is very much nitpicking, but I would change this to early-continue like used elsewhere in the code:

if (g_strcmp0(g_unix_mount_get_device_path(m),slot->device) != 0)
     continue;

if (g_unix_mount_is_readonly(m)) {
    ....

if (!res) {
g_propagate_prefixed_error(error, ierror, "Failed unmounting seed slot: ");
goto out;
g_message("Unmounting ext4 seed slot %s", seedslot->device);

Choose a reason for hiding this comment

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

This is again nitpicking. I would format the code to conform to the coding style used and decrease the depth of this scope:

	/* Unmount seed if needed */
	if (!seed_mounted) 
		return res;
	
	g_message("Unmounting ext4 seed slot %s", seedslot->device);
	ierror = NULL; /* any previous error was propagated already */
	if(r_umount_slot(seedslot, &ierror))
		return res;
			
	if (error && *error) {
		/* the previous error is more relevant here */
		g_warning("Ignoring umount error after previous error: %s", ierror->message);
		g_clear_error(&ierror);
	} else {
		g_propagate_error(error, ierror);
	}
	
	return FALSE;

@codecov
Copy link

codecov bot commented Apr 11, 2022

Codecov Report

Base: 71.23% // Head: 69.82% // Decreases project coverage by -1.41% ⚠️

Coverage data is based on head (4017b10) compared to base (2814dd8).
Patch coverage: 0.00% of modified lines in pull request are covered.

❗ Current head 4017b10 differs from pull request most recent head 62efd97. Consider uploading reports for the commit 62efd97 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #774      +/-   ##
==========================================
- Coverage   71.23%   69.82%   -1.42%     
==========================================
  Files          34       31       -3     
  Lines       11562    10793     -769     
==========================================
- Hits         8236     7536     -700     
+ Misses       3326     3257      -69     
Impacted Files Coverage Δ
include/slot.h 100.00% <ø> (ø)
src/slot.c 88.27% <0.00%> (-3.03%) ⬇️
src/update_handler.c 55.00% <0.00%> (-7.81%) ⬇️
src/stats.c 0.00% <0.00%> (-94.21%) ⬇️
src/signature.c 79.32% <0.00%> (-2.19%) ⬇️
src/mount.c 65.42% <0.00%> (-0.46%) ⬇️
src/main.c 74.71% <0.00%> (-0.46%) ⬇️
src/mbr.c 69.49% <0.00%> (-0.23%) ⬇️
src/utils.c 73.45% <0.00%> (-0.11%) ⬇️
... and 13 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -323,6 +323,7 @@ static gboolean casync_extract_image(RaucImage *image, gchar *dest, int out_fd,
* file systems, additional mounts, etc. */
if (!seedslot->mount_point) {
g_debug("Mounting %s to use as seed", seedslot->device);
seedslot->extra_mount_opts = r_get_slot_current_mount_options(seedslot);
Copy link
Member

Choose a reason for hiding this comment

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

We can't just replace extra_mount_opts here. Also, we should just use read-only mounts for seeding.

Copy link
Member

Choose a reason for hiding this comment

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

It is now extended instead of being replaced.

As it accepted read-write slots before and we cannot easily determine what is actually readwrite and what is not (e.g. readonly file systems) I have left this untouched for now.

Copy link
Member

Choose a reason for hiding this comment

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

What I meant is that extra_mount_opts is configuration, so we can't change it here. Also we don't need to check if the slot is currently mounted read-only, as an additional read-only mount should always work.

@ejoerns
Copy link
Member

ejoerns commented Aug 29, 2022

I have now rebased this on #957 and reworked it to give it a chance to get merged.

Things I changed:

  • added descriptions to the commit messages
  • applied uncrustify changes
  • removed "ext4" from "Unmounting ext4 seed slot.."
  • reworked adding "ro" mount opt while preserving already-exisiting extra mount options.

This adapts casync seed slot unmount handling to what is done in
archive_to_*_hanlder() for slot unmount handling already.

Signed-off-by: Jonas Licht <[email protected]>
Signed-off-by: Enrico Jorns <[email protected]>
Re-mounting a ro (readonly) slot rw (readwrite) will cause an error or a
fallback with a warning, depending on the mount version/veriant used.

Also mounting an rw slot as ro will fail.

Thus make sure we use the same option when remounting the slot for
seeding that the original mount already had.

Fixes rauc#773

Signed-off-by: Jonas Licht <[email protected]>
Signed-off-by: Enrico Jorns <[email protected]>
@jluebbe
Copy link
Member

jluebbe commented Sep 30, 2022

I've rebased it on master after the merge of #957 to make it easier to review.

@jluebbe
Copy link
Member

jluebbe commented Sep 30, 2022

We've split off the simple fix as #977. When that is merged, only the seed slot handling remains.

At that point, we should probably change it to use slot->ext_mount_point as the source of a ro-bind-mount. That side-steps the entire issue of the mount command complaining about ' already mounted on ', when trying to create an ro-mount of an existing rw-mounted FS.

@ejoerns ejoerns changed the title casync fixes Fix casync seed slot mounting of already-ro-mounted slots Sep 30, 2022
@ejoerns ejoerns modified the milestones: Unplanned, Release v1.10 Mar 2, 2023
@ejoerns ejoerns modified the milestones: Release v1.10, Release v1.11 Jun 22, 2023
@jluebbe jluebbe modified the milestones: Release v1.11, Release v1.12 Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
casync casync-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants