diff options
| author | Filipe Manana <[email protected]> | 2025-05-13 09:27:44 +0000 |
|---|---|---|
| committer | David Sterba <[email protected]> | 2025-05-15 16:24:23 +0000 |
| commit | a08625f8250622f538641efa159a946b4b546165 (patch) | |
| tree | e4d34e212441ddf57e4be5e5fe9cac4abd6b5c78 /lib/pm-notifier-error-inject.c | |
| parent | btrfs: pass true to btrfs_delalloc_release_space() at btrfs_page_mkwrite() (diff) | |
| download | kernel-a08625f8250622f538641efa159a946b4b546165.tar.gz kernel-a08625f8250622f538641efa159a946b4b546165.zip | |
btrfs: simplify early error checking in btrfs_page_mkwrite()
We have this entangled error checks early at btrfs_page_mkwrite():
1) Try to reserve delalloc space by calling btrfs_delalloc_reserve_space()
and storing the return value in the ret2 variable;
2) If the reservation succeed, call file_update_time() and store the
return value in ret2 and also set the local variable 'reserved' to
true (1);
3) Then do an error check on ret2 to see if any of the previous calls
failed and if so, jump either to the 'out' label or to the
'out_noreserve' label, depending on whether 'reserved' is true or
not.
This is unnecessarily complex. Instead change this to a simpler and
more straightforward approach:
1) Call btrfs_delalloc_reserve_space(), if that returns an error jump to
the 'out_noreserve' label;
2) The call file_update_time() and if that returns an error jump to the
'out' label.
Like this there's less nested if statements, no need to use a local
variable to track if space was reserved and if statements are used only
to check errors.
Also move the call to extent_changeset_free() out of the 'out_noreserve'
label and under the 'out' label since the changeset is allocated only if
the call to reserve delalloc space succeeded.
Reviewed-by: Qu Wenruo <[email protected]>
Signed-off-by: Filipe Manana <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
Diffstat (limited to 'lib/pm-notifier-error-inject.c')
0 files changed, 0 insertions, 0 deletions
