mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 11:19:37 +00:00
btrfs: clarify error returns values in __load_free_space_cache
Return value in __load_free_space_cache is not properly set after
(unlikely) memory allocation failures and 0 is returned instead.
This is not a problem for the caller load_free_space_cache because only
value 1 is considered as 'cache loaded' but for clarity it's better
to set the errors accordingly.
Fixes: a67509c300
("Btrfs: add a io_ctl struct and helpers for dealing with the space cache")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
4f4317c13a
commit
3cc64e7ebf
1 changed files with 5 additions and 1 deletions
|
@ -775,8 +775,10 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
|
||||||
while (num_entries) {
|
while (num_entries) {
|
||||||
e = kmem_cache_zalloc(btrfs_free_space_cachep,
|
e = kmem_cache_zalloc(btrfs_free_space_cachep,
|
||||||
GFP_NOFS);
|
GFP_NOFS);
|
||||||
if (!e)
|
if (!e) {
|
||||||
|
ret = -ENOMEM;
|
||||||
goto free_cache;
|
goto free_cache;
|
||||||
|
}
|
||||||
|
|
||||||
ret = io_ctl_read_entry(&io_ctl, e, &type);
|
ret = io_ctl_read_entry(&io_ctl, e, &type);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -785,6 +787,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!e->bytes) {
|
if (!e->bytes) {
|
||||||
|
ret = -1;
|
||||||
kmem_cache_free(btrfs_free_space_cachep, e);
|
kmem_cache_free(btrfs_free_space_cachep, e);
|
||||||
goto free_cache;
|
goto free_cache;
|
||||||
}
|
}
|
||||||
|
@ -805,6 +808,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
|
||||||
e->bitmap = kmem_cache_zalloc(
|
e->bitmap = kmem_cache_zalloc(
|
||||||
btrfs_free_space_bitmap_cachep, GFP_NOFS);
|
btrfs_free_space_bitmap_cachep, GFP_NOFS);
|
||||||
if (!e->bitmap) {
|
if (!e->bitmap) {
|
||||||
|
ret = -ENOMEM;
|
||||||
kmem_cache_free(
|
kmem_cache_free(
|
||||||
btrfs_free_space_cachep, e);
|
btrfs_free_space_cachep, e);
|
||||||
goto free_cache;
|
goto free_cache;
|
||||||
|
|
Loading…
Reference in a new issue