Yan [Wed, 7 Nov 2007 18:31:09 +0000 (13:31 -0500)]
Properly delete csum item in btrfs_truncate_in_trans.
When 'item_end' is equal to 'inode->i_size', 'found_type' is updated
and current item is skipped. This behavior is correct for extent item,
but incorrect for csum item. For example, there is a csum item with
'offset == 0'. When deleting the inode, 'inode->i_size' is set to 0,
so the csum item isn't deleted.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Yan [Tue, 6 Nov 2007 15:26:26 +0000 (10:26 -0500)]
Btrfs: Fix u32 overflow in dirty_and_release_pages.
When calculating the size of inline extent, inode->i_size should also
be take into consideration, otherwise sys_write may drop some data
silently. You can test this bug by:
Yan [Thu, 1 Nov 2007 15:28:42 +0000 (11:28 -0400)]
Btrfs: small fixes for find_lock_delalloc_range.
There is a 'finish_wait', but no 'prepare_to_wait' . So I think that
the 'prepare_to_wait' is missing. The second change is according to
the name of variable.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Chris Mason [Thu, 1 Nov 2007 15:28:41 +0000 (11:28 -0400)]
Btrfs: Fix a number of inline extent problems that Yan Zheng reported.
The fixes do a number of things:
1) Most btrfs_drop_extent callers will try to leave the inline extents in
place. It can truncate bytes off the beginning of the inline extent if
required.
2) writepage can now update the inline extent, allowing mmap writes to
go directly into the inline extent.
Yan [Mon, 29 Oct 2007 16:01:05 +0000 (12:01 -0400)]
Minor fix for btrfs_csum_file_block.
Execution should goto label 'insert' when 'btrfs_next_leaf' return a
non-zero value, otherwise the parameter 'slot' for
'btrfs_item_key_to_cpu' may be out of bounds. The original codes jump
to label 'insert' only when 'btrfs_next_leaf' return a negative
value.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Yan [Mon, 29 Oct 2007 15:41:07 +0000 (11:41 -0400)]
Fix inline extent handling in btrfs_get_extent
1. Reorder kmap and the test for 'page != NULL'
2. Zero-fill rest area of a block when inline extent isn't big enough.
3. Do not insert extent_map into the map tree when page == NULL.
(If insert the extent_map into the map tree, subsequent read requests
will find it in the map tree directly and the corresponding inline
extent data aren't copied into page by the the get_extent function.
extent_read_full_page can't handle that case)
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Yan [Thu, 25 Oct 2007 19:49:25 +0000 (15:49 -0400)]
Fix ENOTEMPTY check in btrfs_rmdir
The ENOTEMPTY check in btrfs_rmdir isn't reliable. It's possible that
the backward search finds . or .. at first, then some other directory
entry. In that case, btrfs_rmdir delete . or .. improperly. The
patch also fixes a fs_mutex unlock issue in btrfs_rmdir.
--
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Yan [Thu, 25 Oct 2007 19:42:57 +0000 (15:42 -0400)]
Btrfs: Fix for insert_inline_extent to handle offset != 0
This modifies inline extent size calculation, so that
insert_inline_extent can handle the case that parameter 'offset' is
not zero; it also a few codes to zero uninitialized area in inline
extent.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Chris Mason [Thu, 25 Oct 2007 19:42:57 +0000 (15:42 -0400)]
Btrfs: Fix split_leaf to detect when it is extending an item
When making room for a new item, it is ok to create an empty leaf, but
when making room to extend an item, split_leaf needs to make sure it
keeps the item we're extending in the path and make sure we don't end up
with an empty leaf.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Jens Axboe [Fri, 19 Oct 2007 13:23:07 +0000 (09:23 -0400)]
Btrfs: KM_IRQ0 usage in end_io handling
endio handling is typically called with interrupts disabled, but can
also be called with it enabled. So save interrupts before using KM_IRQ0
to be completely safe.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Yan [Mon, 17 Sep 2007 15:13:11 +0000 (11:13 -0400)]
Btrfs: truncate: don't update inode->i_blocks when extent is a hole
I think check whether extent is a hole before update 'inode->i_blocks'
is unconditional required. (original codes check it only when
del_item isn't equal to 0)
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Chris Mason [Mon, 17 Sep 2007 15:00:51 +0000 (11:00 -0400)]
Btrfs: Fix duplicate ENOSPC checks in find_free_extent
find_free_extent would fail to wrap around to the start of the drive because
it was doing the enospc case checking twice in some cases, causing it
to return -ENOSPC early.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Chris Mason [Mon, 17 Sep 2007 14:58:06 +0000 (10:58 -0400)]
Btrfs: Use balance_dirty_pages_nr on btree blocks
btrfs_btree_balance_dirty is changed to pass the number of pages dirtied
for more accurate dirty throttling. This lets the VM make better decisions
about when to force some writeback.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Chris Mason [Tue, 11 Sep 2007 15:15:39 +0000 (11:15 -0400)]
Btrfs: Find and remove dead roots the first time a root is loaded.
Dead roots are trees left over after a crash, and they were either in the
process of being removed or were waiting to be removed when the box crashed.
Before, a search of the entire tree of root pointers was done on mount
looking for dead roots. Now, the search is done the first time we load
a root.
This makes mount faster when there are a large number of snapshots, and it
enables the block accounting code to properly update the block counts on
the latest root as old versions of the root are reaped after a crash.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
XFS updates the ondisk inode size only after the data I/O has finished,
so it needs a hook when the writepage end_bio handler has finished.
Might not be worth applying as-is as the per-page callback is very
ineffcient. What XFS really wants is a callback when writeout of a
whole extent has completed. This delayed i_size updates scheme might
be worthwile for btrfs aswell, btw.
Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
generic_bmap is completely trivial, while the extent to bh mapping in
btrfs is rather complex. So provide a extent_bmap instead that takes
a get_extent callback and can be used by filesystem using the extent_map
code.
Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Btrfs: [PATCH] extent_map: fix locking for bio completion
The bio completion handlers can be run in any context, e.g. when using
the old ide driver they run in hardirq context with irqs disabled so
lockdep rightfully warns about using write_lock_irq useage in these
handlers.
This patch switches clear_extent_bit and set_extent_bit to
write_lock_irqsave to fix this problem.
Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Chris Mason [Tue, 11 Sep 2007 00:00:27 +0000 (20:00 -0400)]
Btrfs: Reorder tests in set_extent_bit to properly find holes
Yan Zheng noticed that set_extent_bit was exiting too early when there
was a hole in the map. The fix is to reorder the tests to check for the
hole first.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Chris Mason [Mon, 10 Sep 2007 23:58:36 +0000 (19:58 -0400)]
Btrfs: Add more synchronization before creating a snapshot
File data checksums are only done during writepage, so we have to make sure
all pages are written when the snapshot is taken. This also adds some
locking so that new writes don't race in and add new dirty pages.
Signed-off-by: Chris Mason <chris.mason@oracle.com>