Commit 019793b7 authored by Linus Torvalds's avatar Linus Torvalds

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()
parents cb49f577 7cf96da3
...@@ -2824,6 +2824,7 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, ...@@ -2824,6 +2824,7 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
spin_lock(&delayed_refs->lock); spin_lock(&delayed_refs->lock);
if (delayed_refs->num_entries == 0) { if (delayed_refs->num_entries == 0) {
spin_unlock(&delayed_refs->lock);
printk(KERN_INFO "delayed_refs has NO entry\n"); printk(KERN_INFO "delayed_refs has NO entry\n");
return ret; return ret;
} }
......
...@@ -8059,6 +8059,10 @@ static noinline int relocate_one_extent(struct btrfs_root *extent_root, ...@@ -8059,6 +8059,10 @@ static noinline int relocate_one_extent(struct btrfs_root *extent_root,
u64 group_start = group->key.objectid; u64 group_start = group->key.objectid;
new_extents = kmalloc(sizeof(*new_extents), new_extents = kmalloc(sizeof(*new_extents),
GFP_NOFS); GFP_NOFS);
if (!new_extents) {
ret = -ENOMEM;
goto out;
}
nr_extents = 1; nr_extents = 1;
ret = get_new_locations(reloc_inode, ret = get_new_locations(reloc_inode,
extent_key, extent_key,
......
...@@ -2681,7 +2681,7 @@ int extent_readpages(struct extent_io_tree *tree, ...@@ -2681,7 +2681,7 @@ int extent_readpages(struct extent_io_tree *tree,
prefetchw(&page->flags); prefetchw(&page->flags);
list_del(&page->lru); list_del(&page->lru);
if (!add_to_page_cache_lru(page, mapping, if (!add_to_page_cache_lru(page, mapping,
page->index, GFP_KERNEL)) { page->index, GFP_NOFS)) {
__extent_read_full_page(tree, page, get_extent, __extent_read_full_page(tree, page, get_extent,
&bio, 0, &bio_flags); &bio, 0, &bio_flags);
} }
......
...@@ -1768,10 +1768,13 @@ void btrfs_remove_free_space_cache(struct btrfs_block_group_cache *block_group) ...@@ -1768,10 +1768,13 @@ void btrfs_remove_free_space_cache(struct btrfs_block_group_cache *block_group)
while ((node = rb_last(&block_group->free_space_offset)) != NULL) { while ((node = rb_last(&block_group->free_space_offset)) != NULL) {
info = rb_entry(node, struct btrfs_free_space, offset_index); info = rb_entry(node, struct btrfs_free_space, offset_index);
if (!info->bitmap) {
unlink_free_space(block_group, info); unlink_free_space(block_group, info);
if (info->bitmap)
kfree(info->bitmap);
kmem_cache_free(btrfs_free_space_cachep, info); kmem_cache_free(btrfs_free_space_cachep, info);
} else {
free_bitmap(block_group, info);
}
if (need_resched()) { if (need_resched()) {
spin_unlock(&block_group->tree_lock); spin_unlock(&block_group->tree_lock);
cond_resched(); cond_resched();
...@@ -2301,7 +2304,7 @@ int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group, ...@@ -2301,7 +2304,7 @@ int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group,
start = entry->offset; start = entry->offset;
bytes = min(entry->bytes, end - start); bytes = min(entry->bytes, end - start);
unlink_free_space(block_group, entry); unlink_free_space(block_group, entry);
kfree(entry); kmem_cache_free(btrfs_free_space_cachep, entry);
} }
spin_unlock(&block_group->tree_lock); spin_unlock(&block_group->tree_lock);
......
...@@ -954,6 +954,7 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page, ...@@ -954,6 +954,7 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
1, 0, NULL, GFP_NOFS); 1, 0, NULL, GFP_NOFS);
while (start < end) { while (start < end) {
async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS); async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS);
BUG_ON(!async_cow);
async_cow->inode = inode; async_cow->inode = inode;
async_cow->root = root; async_cow->root = root;
async_cow->locked_page = locked_page; async_cow->locked_page = locked_page;
...@@ -4731,9 +4732,10 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, ...@@ -4731,9 +4732,10 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
dentry->d_name.len, dir->i_ino, objectid, dentry->d_name.len, dir->i_ino, objectid,
BTRFS_I(dir)->block_group, mode, &index); BTRFS_I(dir)->block_group, mode, &index);
if (IS_ERR(inode)) {
err = PTR_ERR(inode); err = PTR_ERR(inode);
if (IS_ERR(inode))
goto out_unlock; goto out_unlock;
}
err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name);
if (err) { if (err) {
...@@ -4792,9 +4794,10 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, ...@@ -4792,9 +4794,10 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
dentry->d_name.len, dir->i_ino, objectid, dentry->d_name.len, dir->i_ino, objectid,
BTRFS_I(dir)->block_group, mode, &index); BTRFS_I(dir)->block_group, mode, &index);
if (IS_ERR(inode)) {
err = PTR_ERR(inode); err = PTR_ERR(inode);
if (IS_ERR(inode))
goto out_unlock; goto out_unlock;
}
err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name);
if (err) { if (err) {
...@@ -4999,6 +5002,8 @@ static noinline int uncompress_inline(struct btrfs_path *path, ...@@ -4999,6 +5002,8 @@ static noinline int uncompress_inline(struct btrfs_path *path,
inline_size = btrfs_file_extent_inline_item_len(leaf, inline_size = btrfs_file_extent_inline_item_len(leaf,
btrfs_item_nr(leaf, path->slots[0])); btrfs_item_nr(leaf, path->slots[0]));
tmp = kmalloc(inline_size, GFP_NOFS); tmp = kmalloc(inline_size, GFP_NOFS);
if (!tmp)
return -ENOMEM;
ptr = btrfs_file_extent_inline_start(item); ptr = btrfs_file_extent_inline_start(item);
read_extent_buffer(leaf, tmp, ptr, inline_size); 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, ...@@ -6036,7 +6041,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
ret = btrfs_map_block(map_tree, READ, start_sector << 9, ret = btrfs_map_block(map_tree, READ, start_sector << 9,
&map_length, NULL, 0); &map_length, NULL, 0);
if (ret) { if (ret) {
bio_put(bio); bio_put(orig_bio);
return -EIO; return -EIO;
} }
...@@ -7273,9 +7278,10 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, ...@@ -7273,9 +7278,10 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
dentry->d_name.len, dir->i_ino, objectid, dentry->d_name.len, dir->i_ino, objectid,
BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO, BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO,
&index); &index);
if (IS_ERR(inode)) {
err = PTR_ERR(inode); err = PTR_ERR(inode);
if (IS_ERR(inode))
goto out_unlock; goto out_unlock;
}
err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name);
if (err) { if (err) {
......
...@@ -2209,8 +2209,10 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans, ...@@ -2209,8 +2209,10 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
log = root->log_root; log = root->log_root;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) if (!path) {
return -ENOMEM; err = -ENOMEM;
goto out_unlock;
}
di = btrfs_lookup_dir_item(trans, log, path, dir->i_ino, di = btrfs_lookup_dir_item(trans, log, path, dir->i_ino,
name, name_len, -1); name, name_len, -1);
...@@ -2271,6 +2273,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans, ...@@ -2271,6 +2273,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
} }
fail: fail:
btrfs_free_path(path); btrfs_free_path(path);
out_unlock:
mutex_unlock(&BTRFS_I(dir)->log_mutex); mutex_unlock(&BTRFS_I(dir)->log_mutex);
if (ret == -ENOSPC) { if (ret == -ENOSPC) {
root->fs_info->last_trans_log_full_commit = trans->transid; root->fs_info->last_trans_log_full_commit = trans->transid;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment