summaryrefslogtreecommitdiff
path: root/fs/btrfs/file.c
AgeCommit message (Collapse)AuthorFilesLines
2008-09-25Btrfs: Use the extent map cache to find the logical disk block during data ↵Chris Mason1-1/+46
retries The data read retry code needs to find the logical disk block before it can resubmit new bios. But, finding this block isn't allowed to take the fs_mutex because that will deadlock with a number of different callers. This changes the retry code to use the extent map cache instead, but that requires the extent map cache to have the extent we're looking for. This is a problem because btrfs_drop_extent_cache just drops the entire extent instead of the little tiny part it is invalidating. The bulk of the code in this patch changes btrfs_drop_extent_cache to invalidate only a portion of the extent cache, and changes btrfs_get_extent to deal with the results. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: A few updates for 2.6.18 and versions older than 2.6.25Chris Mason1-1/+7
This includes fixing a missing spinlock init call that caused oops on mount for most kernels other than 2.6.25. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Add O_DIRECT read and write (writes == buffered + cache flush)Chris Mason1-2/+9
This adds basic O_DIRECT read and write support. In the write case, we just do a normal buffered write followed by a cache flush. O_DIRECT + O_SYNC are required to trigger metadata syncs. In the read case, there is a basic btrfs_get_block call for use by the generic O_DIRECT code. This does honor multi-volume mapping rules but it skips all checksumming. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Properly cast before shiftingChris Mason1-1/+1
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Take the extent lock before dropping the delalloc bitsChris Mason1-0/+4
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Properly clear dirty and delalloc extent bits while preparing the ↵Chris Mason1-0/+7
file for write Yan Zheng noticed that we don't clear the extent state tree dirty and delalloc bits when we clear the dirty bits on the page during file write. This leads to csum errors later on. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Fix "no csum found for inode" issue.Yan1-1/+4
A few codes were not properly updated for changes of extent map. This may be the causes of "no csum found for inode" issue. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Fix i_blocks accountingChris Mason1-6/+11
Now that delayed allocation accounting works, i_blocks accounting is changed to only modify i_blocks when extents inserted or removed. The fillattr call is changed to include the delayed allocation byte count in the i_blocks result. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25btrfs_drop_extents: handle BTRFS_INODE_REF_KEY typesYan1-3/+4
It's possible "key.type == BTRFS_INODE_REF_KEY" and "key.offset >= end". Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Fix hole creation in file_writeYan1-4/+2
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25btrfs_drop_extent fixe for inline items > 8KYan1-5/+3
When truncating a inline extent, btrfs_drop_extents doesn't properly handle the case "key.offset > inline_limit". This bug can only happen when max line size is larger than 8K. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: mount -o max_inline=size to control the maximum inline extent sizeChris Mason1-1/+2
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Do delalloc accounting via hooks in the extent_state codeChris Mason1-4/+0
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Split the extent_map code into two partsChris Mason1-14/+15
There is now extent_map for mapping offsets in the file to disk and extent_io for state tracking, IO submission and extent_bufers. The new extent_map code shifts from [start,end] pairs to [start,len], and pushes the locking out into the caller. This allows a few performance optimizations and is easier to use. A number of extent_map usage bugs were fixed, mostly with failing to remove extent_map entries when changing the file. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Fix hole insertion corner casesChris Mason1-1/+77
There were a few places that could cause duplicate extent insertion, this adjusts the code that creates holes to avoid it. lookup_extent_map is changed to correctly return all of the extents in a range, even when there are none matching at the start of the range. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Add some simple throttling to wait for data=ordered and snapshot deletionChris Mason1-0/+1
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Add data=ordered supportChris Mason1-3/+2
This forces file data extents down the disk along with the metadata that references them. The current implementation is fairly simple, and just writes out all of the dirty pages in an inode before the commit. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Lower the max inline size to 8kChris Mason1-1/+1
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Fix lock ordering of the snapshot semaphore against the page lockChris Mason1-2/+4
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Force inlining off in a few places to save stack usageChris Mason1-10/+6
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Implement basic support for -ENOSPCChris Mason1-4/+24
This is intended to prevent accidentally filling the drive. A determined user can still make things oops. It includes some accounting of the current bytes under delayed allocation, but this will change as things get optimized Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Back port to 2.6.18-el kernelsChris Mason1-4/+11
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Fixes for loopback files in btrfsChris Mason1-0/+1
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Off by one fix for btrfs_drop_extentsYan1-1/+2
One of my old patches introduces a new bug to btrfs_drop_extents(changeset 275). Inline extents are not truncated properly when "extent_end == end", it can trigger the BUG_ON at file.c:600. I hope I don't introduce new bug this time. --- Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Add lowest key information to back refs for extent tree blocks as well.Chris Mason1-7/+4
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Add back pointers from extents to the btree or file referencing themChris Mason1-3/+17
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25btrfs_drop_extents: make sure the item is getting smaller before truncateChris Mason1-15/+15
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Fine tune the btree writeback exclusion some moreChris Mason1-1/+2
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Allow large data extents in a single file to span into metadata block ↵Chris Mason1-0/+6
groups Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Fix EXTENT_MAP_INLINE off by one in btrfs_drop_extentsYan1-2/+1
Don't set hint_byte to EXTENT_MAP_INLINE when 'end == extent_end' or 'start == key.offset' . The inline extent will be truncated in these cases. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Fix u32 overflow in dirty_and_release_pages.Yan1-4/+5
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: #dd if=/dev/zero bs=4k count=1 of=test_file #dd if=/dev/zero bs=2k count=1 of=test_file conv=notrunc Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Fix a number of inline extent problems that Yan Zheng reported.Chris Mason1-6/+30
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. 3) btrfs_truncate_in_transaction truncates inline extents 4) extent_map.c fixed to not merge inline extent mappings and hole mappings together Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Fix PAGE_CACHE_SHIFT shifts on 32 bit machinesChris Mason1-1/+2
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Add O_SYNC support to btrfs_file_writeChris Mason1-2/+13
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Fix for insert_inline_extent to handle offset != 0Yan1-9/+12
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>
2008-09-25btrfs: 32-bit type problemsJens Axboe1-1/+1
An assorted set of casts to get rid of the warnings on 32-bit archs. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Default to 8k max packed tailsChris Mason1-1/+1
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Add back file data checksummingChris Mason1-0/+1
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: extent_map optimizations to cut down on CPU usageChris Mason1-1/+0
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Allow tails larger than one pageChris Mason1-36/+116
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Allow tree blocks larger than the page sizeChris Mason1-66/+60
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Create extent_buffer interface for large blocksizesChris Mason1-62/+67
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: factor page private preparations into a helperChristoph Hellwig1-6/+1
Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Use balance_dirty_pages_nr on btree blocksChris Mason1-1/+1
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>
2007-09-14Btrfs: Fix off by one error in dirty_and_release_pagesYan1-1/+1
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2007-09-14Btrfs: use unlocked_ioctlChristoph Hellwig1-2/+2
No reason to grab the BKL before calling into the btrfs ioctl code. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
2007-09-11[PATCH] btrfs: fix printk format warningChristoph Hellwig1-1/+1
Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
2007-09-11Btrfs: Add more synchronization before creating a snapshotChris Mason1-0/+2
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>
2007-08-30Btrfs: remove extra drop_extent_cache callChris Mason1-2/+0
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2007-08-30Btrfs: fsx delalloc fixesChris Mason1-9/+17
Signed-off-by: Chris Mason <chris.mason@oracle.com>