Skip to content

Commit 019793b

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable
* git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable: Btrfs: cleanup error handling in inode.c Btrfs: put the right bio if we have an error Btrfs: free bitmaps properly when evicting the cache Btrfs: Free free_space item properly in btrfs_trim_block_group() btrfs: add missing spin_unlock to a rare exit path Btrfs: check return value of kmalloc() btrfs: fix wrong allocating flag when reading page Btrfs: fix missing mutex_unlock in btrfs_del_dir_entries_in_log()
2 parents cb49f57 + 7cf96da commit 019793b

File tree

6 files changed

+32
-15
lines changed

6 files changed

+32
-15
lines changed

fs/btrfs/disk-io.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2824,6 +2824,7 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
28242824

28252825
spin_lock(&delayed_refs->lock);
28262826
if (delayed_refs->num_entries == 0) {
2827+
spin_unlock(&delayed_refs->lock);
28272828
printk(KERN_INFO "delayed_refs has NO entry\n");
28282829
return ret;
28292830
}

fs/btrfs/extent-tree.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8059,6 +8059,10 @@ static noinline int relocate_one_extent(struct btrfs_root *extent_root,
80598059
u64 group_start = group->key.objectid;
80608060
new_extents = kmalloc(sizeof(*new_extents),
80618061
GFP_NOFS);
8062+
if (!new_extents) {
8063+
ret = -ENOMEM;
8064+
goto out;
8065+
}
80628066
nr_extents = 1;
80638067
ret = get_new_locations(reloc_inode,
80648068
extent_key,

fs/btrfs/extent_io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2681,7 +2681,7 @@ int extent_readpages(struct extent_io_tree *tree,
26812681
prefetchw(&page->flags);
26822682
list_del(&page->lru);
26832683
if (!add_to_page_cache_lru(page, mapping,
2684-
page->index, GFP_KERNEL)) {
2684+
page->index, GFP_NOFS)) {
26852685
__extent_read_full_page(tree, page, get_extent,
26862686
&bio, 0, &bio_flags);
26872687
}

fs/btrfs/free-space-cache.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,10 +1768,13 @@ void btrfs_remove_free_space_cache(struct btrfs_block_group_cache *block_group)
17681768

17691769
while ((node = rb_last(&block_group->free_space_offset)) != NULL) {
17701770
info = rb_entry(node, struct btrfs_free_space, offset_index);
1771-
unlink_free_space(block_group, info);
1772-
if (info->bitmap)
1773-
kfree(info->bitmap);
1774-
kmem_cache_free(btrfs_free_space_cachep, info);
1771+
if (!info->bitmap) {
1772+
unlink_free_space(block_group, info);
1773+
kmem_cache_free(btrfs_free_space_cachep, info);
1774+
} else {
1775+
free_bitmap(block_group, info);
1776+
}
1777+
17751778
if (need_resched()) {
17761779
spin_unlock(&block_group->tree_lock);
17771780
cond_resched();
@@ -2301,7 +2304,7 @@ int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group,
23012304
start = entry->offset;
23022305
bytes = min(entry->bytes, end - start);
23032306
unlink_free_space(block_group, entry);
2304-
kfree(entry);
2307+
kmem_cache_free(btrfs_free_space_cachep, entry);
23052308
}
23062309

23072310
spin_unlock(&block_group->tree_lock);

fs/btrfs/inode.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,7 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
954954
1, 0, NULL, GFP_NOFS);
955955
while (start < end) {
956956
async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS);
957+
BUG_ON(!async_cow);
957958
async_cow->inode = inode;
958959
async_cow->root = root;
959960
async_cow->locked_page = locked_page;
@@ -4731,9 +4732,10 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
47314732
inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
47324733
dentry->d_name.len, dir->i_ino, objectid,
47334734
BTRFS_I(dir)->block_group, mode, &index);
4734-
err = PTR_ERR(inode);
4735-
if (IS_ERR(inode))
4735+
if (IS_ERR(inode)) {
4736+
err = PTR_ERR(inode);
47364737
goto out_unlock;
4738+
}
47374739

47384740
err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name);
47394741
if (err) {
@@ -4792,9 +4794,10 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
47924794
inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
47934795
dentry->d_name.len, dir->i_ino, objectid,
47944796
BTRFS_I(dir)->block_group, mode, &index);
4795-
err = PTR_ERR(inode);
4796-
if (IS_ERR(inode))
4797+
if (IS_ERR(inode)) {
4798+
err = PTR_ERR(inode);
47974799
goto out_unlock;
4800+
}
47984801

47994802
err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name);
48004803
if (err) {
@@ -4999,6 +5002,8 @@ static noinline int uncompress_inline(struct btrfs_path *path,
49995002
inline_size = btrfs_file_extent_inline_item_len(leaf,
50005003
btrfs_item_nr(leaf, path->slots[0]));
50015004
tmp = kmalloc(inline_size, GFP_NOFS);
5005+
if (!tmp)
5006+
return -ENOMEM;
50025007
ptr = btrfs_file_extent_inline_start(item);
50035008

50045009
read_extent_buffer(leaf, tmp, ptr, inline_size);
@@ -6036,7 +6041,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
60366041
ret = btrfs_map_block(map_tree, READ, start_sector << 9,
60376042
&map_length, NULL, 0);
60386043
if (ret) {
6039-
bio_put(bio);
6044+
bio_put(orig_bio);
60406045
return -EIO;
60416046
}
60426047

@@ -7273,9 +7278,10 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
72737278
dentry->d_name.len, dir->i_ino, objectid,
72747279
BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO,
72757280
&index);
7276-
err = PTR_ERR(inode);
7277-
if (IS_ERR(inode))
7281+
if (IS_ERR(inode)) {
7282+
err = PTR_ERR(inode);
72787283
goto out_unlock;
7284+
}
72797285

72807286
err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name);
72817287
if (err) {

fs/btrfs/tree-log.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,8 +2209,10 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
22092209

22102210
log = root->log_root;
22112211
path = btrfs_alloc_path();
2212-
if (!path)
2213-
return -ENOMEM;
2212+
if (!path) {
2213+
err = -ENOMEM;
2214+
goto out_unlock;
2215+
}
22142216

22152217
di = btrfs_lookup_dir_item(trans, log, path, dir->i_ino,
22162218
name, name_len, -1);
@@ -2271,6 +2273,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
22712273
}
22722274
fail:
22732275
btrfs_free_path(path);
2276+
out_unlock:
22742277
mutex_unlock(&BTRFS_I(dir)->log_mutex);
22752278
if (ret == -ENOSPC) {
22762279
root->fs_info->last_trans_log_full_commit = trans->transid;

0 commit comments

Comments
 (0)