Commit 8c2383c3 authored by Chris Mason's avatar Chris Mason Committed by David Woodhouse

Subject: Rework btrfs_file_write to only allocate while page locks are held

Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 9ebefb18
...@@ -541,6 +541,8 @@ int write_ctree_super(struct btrfs_trans_handle *trans, struct btrfs_root ...@@ -541,6 +541,8 @@ int write_ctree_super(struct btrfs_trans_handle *trans, struct btrfs_root
else else
ret = submit_bh(WRITE, bh); ret = submit_bh(WRITE, bh);
if (ret == -EOPNOTSUPP) { if (ret == -EOPNOTSUPP) {
get_bh(bh);
lock_buffer(bh);
set_buffer_uptodate(bh); set_buffer_uptodate(bh);
root->fs_info->do_barriers = 0; root->fs_info->do_barriers = 0;
ret = submit_bh(WRITE, bh); ret = submit_bh(WRITE, bh);
......
...@@ -1477,7 +1477,6 @@ int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root ...@@ -1477,7 +1477,6 @@ int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root
break; break;
if (wret < 0) if (wret < 0)
ret = wret; ret = wret;
btrfs_btree_balance_dirty(root);
} }
for (i = 0; i <= orig_level; i++) { for (i = 0; i <= orig_level; i++) {
if (path->nodes[i]) { if (path->nodes[i]) {
......
...@@ -228,7 +228,6 @@ int btrfs_csum_file_block(struct btrfs_trans_handle *trans, ...@@ -228,7 +228,6 @@ int btrfs_csum_file_block(struct btrfs_trans_handle *trans,
path->nodes[0]->b_data, path->nodes[0]->b_data,
root->fs_info->sb->s_blocksize); root->fs_info->sb->s_blocksize);
ret = btrfs_csum_data(root, data, len, &item->csum); ret = btrfs_csum_data(root, data, len, &item->csum);
// printk("file %lu offset %llu csum %X\n", objectid, (unsigned long long)offset, *(int *)(&item->csum));
btrfs_mark_buffer_dirty(path->nodes[0]); btrfs_mark_buffer_dirty(path->nodes[0]);
fail: fail:
btrfs_release_path(root, path); btrfs_release_path(root, path);
......
This diff is collapsed.
...@@ -962,7 +962,6 @@ void btrfs_dirty_inode(struct inode *inode) ...@@ -962,7 +962,6 @@ void btrfs_dirty_inode(struct inode *inode)
btrfs_update_inode(trans, root, inode); btrfs_update_inode(trans, root, inode);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
mutex_unlock(&root->fs_info->fs_mutex); mutex_unlock(&root->fs_info->fs_mutex);
btrfs_btree_balance_dirty(root);
} }
static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
...@@ -1402,7 +1401,6 @@ int btrfs_get_block_csum(struct inode *inode, sector_t iblock, ...@@ -1402,7 +1401,6 @@ int btrfs_get_block_csum(struct inode *inode, sector_t iblock,
goto out; goto out;
} }
memcpy((char *)&result->b_private, &item->csum, BTRFS_CRC32_SIZE); memcpy((char *)&result->b_private, &item->csum, BTRFS_CRC32_SIZE);
printk("get_block_sum file %lu offset %llu csum %X\n", inode->i_ino, (unsigned long long)offset, *(int *)(&item->csum));
out: out:
if (path) if (path)
btrfs_free_path(path); btrfs_free_path(path);
...@@ -1476,7 +1474,6 @@ static void btrfs_end_buffer_async_read(struct buffer_head *bh, int uptodate) ...@@ -1476,7 +1474,6 @@ static void btrfs_end_buffer_async_read(struct buffer_head *bh, int uptodate)
(unsigned long long)offset); (unsigned long long)offset);
memset(kaddr + bh_offset(bh), 1, bh->b_size); memset(kaddr + bh_offset(bh), 1, bh->b_size);
flush_dcache_page(page); flush_dcache_page(page);
printk("bad verify file %lu offset %llu bh_private %lX csum %X\n", inode->i_ino, (unsigned long long)offset, (unsigned long)(bh->b_private), *(int *)csum);
} }
kunmap_atomic(kaddr, KM_IRQ0); kunmap_atomic(kaddr, KM_IRQ0);
} }
...@@ -1655,6 +1652,13 @@ static int __btrfs_write_full_page(struct inode *inode, struct page *page, ...@@ -1655,6 +1652,13 @@ static int __btrfs_write_full_page(struct inode *inode, struct page *page,
last_block = (i_size_read(inode) - 1) >> inode->i_blkbits; last_block = (i_size_read(inode) - 1) >> inode->i_blkbits;
/* no csumming allowed when from PF_MEMALLOC */
if (current->flags & PF_MEMALLOC) {
redirty_page_for_writepage(wbc, page);
unlock_page(page);
return 0;
}
if (!page_has_buffers(page)) { if (!page_has_buffers(page)) {
create_empty_buffers(page, blocksize, create_empty_buffers(page, blocksize,
(1 << BH_Dirty)|(1 << BH_Uptodate)); (1 << BH_Dirty)|(1 << BH_Uptodate));
...@@ -1885,7 +1889,6 @@ int btrfs_page_mkwrite(struct vm_area_struct *vma, struct page *page) ...@@ -1885,7 +1889,6 @@ int btrfs_page_mkwrite(struct vm_area_struct *vma, struct page *page)
lock_page(page); lock_page(page);
wait_on_page_writeback(page); wait_on_page_writeback(page);
printk("btrfs_page_mkwrite %lu %lu\n", page->mapping->host->i_ino, page->index);
size = i_size_read(inode); size = i_size_read(inode);
if ((page->mapping != inode->i_mapping) || if ((page->mapping != inode->i_mapping) ||
((page->index << PAGE_CACHE_SHIFT) > size)) { ((page->index << PAGE_CACHE_SHIFT) > size)) {
......
...@@ -31,6 +31,7 @@ void btrfs_print_leaf(struct btrfs_root *root, struct btrfs_leaf *l) ...@@ -31,6 +31,7 @@ void btrfs_print_leaf(struct btrfs_root *root, struct btrfs_leaf *l)
struct btrfs_dir_item *di; struct btrfs_dir_item *di;
struct btrfs_inode_item *ii; struct btrfs_inode_item *ii;
struct btrfs_block_group_item *bi; struct btrfs_block_group_item *bi;
struct btrfs_file_extent_item *fi;
u32 type; u32 type;
printk("leaf %llu total ptrs %d free space %d\n", printk("leaf %llu total ptrs %d free space %d\n",
...@@ -75,6 +76,23 @@ void btrfs_print_leaf(struct btrfs_root *root, struct btrfs_leaf *l) ...@@ -75,6 +76,23 @@ void btrfs_print_leaf(struct btrfs_root *root, struct btrfs_leaf *l)
printk("\t\textent data refs %u\n", printk("\t\textent data refs %u\n",
btrfs_extent_refs(ei)); btrfs_extent_refs(ei));
break; break;
case BTRFS_EXTENT_DATA_KEY:
fi = btrfs_item_ptr(l, i,
struct btrfs_file_extent_item);
if (btrfs_file_extent_type(fi) ==
BTRFS_FILE_EXTENT_INLINE) {
printk("\t\tinline extent data size %u\n",
btrfs_file_extent_inline_len(l->items + i));
break;
}
printk("\t\textent data disk block %llu nr %llu\n",
(unsigned long long)btrfs_file_extent_disk_blocknr(fi),
(unsigned long long)btrfs_file_extent_disk_num_blocks(fi));
printk("\t\textent data offset %llu nr %llu\n",
(unsigned long long)btrfs_file_extent_offset(fi),
(unsigned long long)btrfs_file_extent_num_blocks(fi));
break;
case BTRFS_BLOCK_GROUP_ITEM_KEY: case BTRFS_BLOCK_GROUP_ITEM_KEY:
bi = btrfs_item_ptr(l, i, bi = btrfs_item_ptr(l, i,
struct btrfs_block_group_item); struct btrfs_block_group_item);
......
...@@ -279,6 +279,7 @@ static int drop_dirty_roots(struct btrfs_root *tree_root, ...@@ -279,6 +279,7 @@ static int drop_dirty_roots(struct btrfs_root *tree_root,
BUG_ON(ret); BUG_ON(ret);
kfree(dirty); kfree(dirty);
mutex_unlock(&tree_root->fs_info->fs_mutex); mutex_unlock(&tree_root->fs_info->fs_mutex);
btrfs_btree_balance_dirty(tree_root);
} }
return 0; return 0;
} }
......
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