Commit a08625f
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 <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>1 parent bf1c74c commit a08625f
1 file changed
Lines changed: 7 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1843 | 1843 | | |
1844 | 1844 | | |
1845 | 1845 | | |
1846 | | - | |
1847 | 1846 | | |
1848 | 1847 | | |
1849 | 1848 | | |
| |||
1866 | 1865 | | |
1867 | 1866 | | |
1868 | 1867 | | |
1869 | | - | |
1870 | | - | |
1871 | | - | |
1872 | | - | |
1873 | 1868 | | |
1874 | 1869 | | |
1875 | | - | |
1876 | | - | |
1877 | 1870 | | |
1878 | 1871 | | |
1879 | 1872 | | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
1880 | 1879 | | |
1881 | 1880 | | |
1882 | 1881 | | |
| |||
1972 | 1971 | | |
1973 | 1972 | | |
1974 | 1973 | | |
| 1974 | + | |
1975 | 1975 | | |
1976 | 1976 | | |
1977 | | - | |
1978 | 1977 | | |
1979 | 1978 | | |
1980 | 1979 | | |
| |||
0 commit comments