Hi Colin,
On 07.02.22 16:41, 'Colin McAllister' via swupdate wrote:
> Hi Stefano,
>
> Sorry, I didn't reply all again...
>
>> You are just mitigating and reducing the time
>> window when this can happen.
>
>
> Yes, this is correct. There are some use cases we have identified where
> a large file needs to be updated. The probability of a partially written
> or empty file greatly increases as the file size increases.
Of course.
> This patch
> intends to add a feature that significantly minimizes the chance that a
> larger file is left in a corrupted state.
Yes, but there is still a chance that file gets corrupted.
The rename is done at filesystem level - change is propagated to
lowlevel to the storage driver, maybe a SDHC driver that split the
changes from SWUpdate in multiple commands (or multiple blocks), and
they are not atomic, too. So we can say reduce the risk, but it cannot
eliminate it.
>
>
>> I disagree here - it creates a lot of dependencies between the updater
>> and the software that runs. For example, a new file is updated but for
>> some reasons the new SW after a reboot does not run, and there is a
>> fallback to the (running at the time of the update) version. How can an
>> older version know about new files coming from a newer version ?
>
> Breaking compatibility is a problem that could occur, but there are many
> ways to handle that.
>
> There are use cases where an empty or corrupted file is worse than
> having the older file.
Absolutely - it should never happen that systems runs after an
incomplete update. But this is exactly your case.
> Our specific use case is when we only update
> update ancillary data and not the whole system.
This is my point - your system update can be interrupted, it has surely
much larger files as in the case you report, but it does not happen (I
hope !!) that an uncompleted update can run, if your integration is correct.
On the other side, you update a single large file, and you see you get
into trouble because the updated file is corrupted. You see a
discrepancy here. If this is a generic issue, it could often happen on a
system update because SWU / files are usually much larger. But a system
update is treated by you as transaction, and until SWUpdate does not
commit the transaction, the updated software is just garbage. It does
not matter if files are partially written. The transaction flag is a
commit to signal that all files are correctly installed. This seems to
be missing in your design.
If you update a single file, you should create the atomicity yourself.
For example, still having two copies (current and standby), and let them
toggling in a safe environment (it could be by stopping the app instead
of rebooting), etc. This really depends on the project and I agree that
I am speculating because I do not know the details, but it is just to
tell you that an incompleted update can happen in any conditions
(power-cut, crash, etc.). The state machine and transaction flags in
SWUpdate are set if an update is valid or not. In your case, it works if
the update of the single file is not declared valid until SWUpdate
terminates with success.
> In this case we are not
> worried about API compatibility between the file and the rest of the
> system. Instead, we are concerned about the state of the system being
> left in a corrupted state with blank or partially written files.
Again, this is due to your update concept for this single file. It
becomes much worse if you update from a tarball that imply many files. I
guess you are updating a "live" system.
>
> The atomic flag proposed in this patch allows the writer of the swupdate
> file to make the decision if a partial or corrupted file is worse than
> an old copy of the file.
I could merge this even if I think that it is just a work-around for a
not safe update concept. It is still compatible with the past, and a
user can simply decide to not use it.
Anyway, the commit message is not correct: " Once
the .tmp file is installed, it is atomically renamed to the specified
file in path. This ensures that a partial install does not affect the
currently installed file.".
This can confuse and make thinking that any update using the rawfile
handler leads to corrupted data - this is not true, it is just that the
update itself is considered atomic (ok or not ok), but not the run of a
single handler (we can say the same for each handler), so please
reformulate.
Best regards,
Stefano
> Phone:
+49-8142-66989-53 <tel:+49%208142%206698953> Fax:
>
+49-8142-66989-80 <tel:+49%208142%206698980> Email:
sba...@denx.de
> =====================================================================
>
> --
> You received this message because you are subscribed to the Google
> Groups "swupdate" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
swupdate+u...@googlegroups.com
> <mailto:
swupdate+u...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/swupdate/d77596aa-4db5-48a9-9a11-9099fba5a5c5n%40googlegroups.com
> <
https://groups.google.com/d/msgid/swupdate/d77596aa-4db5-48a9-9a11-9099fba5a5c5n%40googlegroups.com?utm_medium=email&utm_source=footer>.