diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-06 23:03:41 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-06 23:03:41 -0500 |
commit | 6a6662ced4153f6dbcfc40d7225c3cc45416039c (patch) | |
tree | 77ad5d577333f02cd854e44827a407dd0388d4eb /fs/btrfs/file.c | |
parent | 32aaeffbd4a7457bf2f7448b33b5946ff2a960eb (diff) | |
parent | 7c7e82a77fe3d89ae50824aa7c897454675eb4c4 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: (114 commits)
Btrfs: check for a null fs root when writing to the backup root log
Btrfs: fix race during transaction joins
Btrfs: fix a potential btrfs_bio leak on scrub fixups
Btrfs: rename btrfs_bio multi -> bbio for consistency
Btrfs: stop leaking btrfs_bios on readahead
Btrfs: stop the readahead threads on failed mount
Btrfs: fix extent_buffer leak in the metadata IO error handling
Btrfs: fix the new inspection ioctls for 32 bit compat
Btrfs: fix delayed insertion reservation
Btrfs: ClearPageError during writepage and clean_tree_block
Btrfs: be smarter about committing the transaction in reserve_metadata_bytes
Btrfs: make a delayed_block_rsv for the delayed item insertion
Btrfs: add a log of past tree roots
btrfs: separate superblock items out of fs_info
Btrfs: use the global reserve when truncating the free space cache inode
Btrfs: release metadata from global reserve if we have to fallback for unlink
Btrfs: make sure to flush queued bios if write_cache_pages waits
Btrfs: fix extent pinning bugs in the tree log
Btrfs: make sure btrfs_remove_free_space doesn't leak EAGAIN
Btrfs: don't wait as long for more batches during SSD log commit
...
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r-- | fs/btrfs/file.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 1266f6e9cdb2..dafdfa059bf6 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -1069,6 +1069,7 @@ static noinline int prepare_pages(struct btrfs_root *root, struct file *file, | |||
1069 | int i; | 1069 | int i; |
1070 | unsigned long index = pos >> PAGE_CACHE_SHIFT; | 1070 | unsigned long index = pos >> PAGE_CACHE_SHIFT; |
1071 | struct inode *inode = fdentry(file)->d_inode; | 1071 | struct inode *inode = fdentry(file)->d_inode; |
1072 | gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping); | ||
1072 | int err = 0; | 1073 | int err = 0; |
1073 | int faili = 0; | 1074 | int faili = 0; |
1074 | u64 start_pos; | 1075 | u64 start_pos; |
@@ -1080,7 +1081,7 @@ static noinline int prepare_pages(struct btrfs_root *root, struct file *file, | |||
1080 | again: | 1081 | again: |
1081 | for (i = 0; i < num_pages; i++) { | 1082 | for (i = 0; i < num_pages; i++) { |
1082 | pages[i] = find_or_create_page(inode->i_mapping, index + i, | 1083 | pages[i] = find_or_create_page(inode->i_mapping, index + i, |
1083 | GFP_NOFS); | 1084 | mask); |
1084 | if (!pages[i]) { | 1085 | if (!pages[i]) { |
1085 | faili = i - 1; | 1086 | faili = i - 1; |
1086 | err = -ENOMEM; | 1087 | err = -ENOMEM; |
@@ -1615,10 +1616,6 @@ static long btrfs_fallocate(struct file *file, int mode, | |||
1615 | goto out; | 1616 | goto out; |
1616 | } | 1617 | } |
1617 | 1618 | ||
1618 | ret = btrfs_check_data_free_space(inode, alloc_end - alloc_start); | ||
1619 | if (ret) | ||
1620 | goto out; | ||
1621 | |||
1622 | locked_end = alloc_end - 1; | 1619 | locked_end = alloc_end - 1; |
1623 | while (1) { | 1620 | while (1) { |
1624 | struct btrfs_ordered_extent *ordered; | 1621 | struct btrfs_ordered_extent *ordered; |
@@ -1664,11 +1661,27 @@ static long btrfs_fallocate(struct file *file, int mode, | |||
1664 | if (em->block_start == EXTENT_MAP_HOLE || | 1661 | if (em->block_start == EXTENT_MAP_HOLE || |
1665 | (cur_offset >= inode->i_size && | 1662 | (cur_offset >= inode->i_size && |
1666 | !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) { | 1663 | !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) { |
1664 | |||
1665 | /* | ||
1666 | * Make sure we have enough space before we do the | ||
1667 | * allocation. | ||
1668 | */ | ||
1669 | ret = btrfs_check_data_free_space(inode, last_byte - | ||
1670 | cur_offset); | ||
1671 | if (ret) { | ||
1672 | free_extent_map(em); | ||
1673 | break; | ||
1674 | } | ||
1675 | |||
1667 | ret = btrfs_prealloc_file_range(inode, mode, cur_offset, | 1676 | ret = btrfs_prealloc_file_range(inode, mode, cur_offset, |
1668 | last_byte - cur_offset, | 1677 | last_byte - cur_offset, |
1669 | 1 << inode->i_blkbits, | 1678 | 1 << inode->i_blkbits, |
1670 | offset + len, | 1679 | offset + len, |
1671 | &alloc_hint); | 1680 | &alloc_hint); |
1681 | |||
1682 | /* Let go of our reservation. */ | ||
1683 | btrfs_free_reserved_data_space(inode, last_byte - | ||
1684 | cur_offset); | ||
1672 | if (ret < 0) { | 1685 | if (ret < 0) { |
1673 | free_extent_map(em); | 1686 | free_extent_map(em); |
1674 | break; | 1687 | break; |
@@ -1694,8 +1707,6 @@ static long btrfs_fallocate(struct file *file, int mode, | |||
1694 | } | 1707 | } |
1695 | unlock_extent_cached(&BTRFS_I(inode)->io_tree, alloc_start, locked_end, | 1708 | unlock_extent_cached(&BTRFS_I(inode)->io_tree, alloc_start, locked_end, |
1696 | &cached_state, GFP_NOFS); | 1709 | &cached_state, GFP_NOFS); |
1697 | |||
1698 | btrfs_free_reserved_data_space(inode, alloc_end - alloc_start); | ||
1699 | out: | 1710 | out: |
1700 | mutex_unlock(&inode->i_mutex); | 1711 | mutex_unlock(&inode->i_mutex); |
1701 | return ret; | 1712 | return ret; |