Skip to content

zms: zms_clear() unusable when ZMS partition is corrupt #100948

@antevir

Description

@antevir

Describe the bug

We have a scenario where we changed the block size used in the ZMS partition. When upgrading from old FW this result in an expected error when calling zms_mount(). We detect this in our fw and call zms_clear() to just wipe the partition.
However, if you call zms_clear() after zms_mount() has failed zms_clear() will do nothing and return -EACCES due to these lines:

	if (!fs->ready) {
		LOG_ERR("zms not initialized");
		return -EACCES;
	}

fs->ready will be set to true only if zms_mount() succeeds completely. Hence, zms_clear() can currently not be used for recovering from a corrupt ZMS partition.

The workaround is of course to manually set fs->ready = true before calling zms_clear().

I can make a simple patch just removing the if statement, but I'm guessing there maybe was a specific reason why it is there in the first place so I want to check here first.

Regression

  • This is a regression.

Steps to reproduce

No response

Relevant log output

Impact

Functional Limitation – Some features not working as expected, but system usable.

Environment

SHA: we use ff8f0c5, but current main cb2109e has the same lines in zms_clear()

Additional Context

No response

Metadata

Metadata

Assignees

Labels

area: StorageStorage subsystembugThe issue is a bug, or the PR is fixing a bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions