[PATCH 08/11] fs/resctrl: Use accurate and symmetric exit flows

Reinette Chatre
2026-03-02T18:46:32Z

During schemata file write handling there is one error exit path labeled
"out" that handles all cleanup and unlocking needed on exit. The staged
configs cleared during an error exit may not have been used at the time
of exit making the clearing of the staged configs unnecessary.

Access the exit code using two labels and only clear the staged
configuration if it was in use at the time of exit. Doing so makes the
code flow obvious and simplifies upcoming changes that improve the
handling of failures during early input parsing.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
fs/resctrl/ctrlmondata.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c
index cc4237c57cbe..a8e7cdcfec6e 100644
--- a/fs/resctrl/ctrlmondata.c
+++ b/fs/resctrl/ctrlmondata.c
@@ -331,7 +331,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED) {
ret = -EINVAL;
rdt_last_cmd_puts("Resource group is pseudo-locked\n");
- goto out;
+ goto out_unlock;
}

rdt_staged_configs_clear();
@@ -341,16 +341,16 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
if (!tok) {
rdt_last_cmd_puts("Missing ':'\n");
ret = -EINVAL;
- goto out;
+ goto out_clear_staged;
}
if (tok[0] == '\0') {
rdt_last_cmd_printf("Missing '%s' value\n", resname);
ret = -EINVAL;
- goto out;
+ goto out_clear_staged;
}
ret = rdtgroup_parse_resource(resname, tok, rdtgrp);
if (ret)
- goto out;
+ goto out_clear_staged;
}

list_for_each_entry(s, &resctrl_schema_all, list) {
@@ -365,7 +365,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,

ret = resctrl_arch_update_domains(r, rdtgrp->closid);
if (ret)
- goto out;
+ goto out_clear_staged;
}

if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
@@ -378,8 +378,9 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
ret = rdtgroup_pseudo_lock_create(rdtgrp);
}

-out:
+out_clear_staged:
rdt_staged_configs_clear();
+out_unlock:
rdtgroup_kn_unlock(of->kn);
return ret ?: nbytes;
}
--
2.50.1