summaryrefslogtreecommitdiff
path: root/fs/btrfs
AgeCommit message (Collapse)AuthorFilesLines
2008-09-25Simplify btrfs_get_parent(), fix use-after-free bugDavid Woodhouse1-15/+11
Date: Mon, 18 Aug 2008 22:50:22 +0100 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Mask root object ID into f_fsid in btrfs_statfs()David Woodhouse1-0/+4
Date: Mon, 18 Aug 2008 13:10:20 +0100 This means that subvolumes get a different fsid, and NFS exporting them works properly. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Fill f_fsid field in btrfs_statfs()David Woodhouse1-0/+6
Date: Mon, 18 Aug 2008 12:01:52 +0100 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Optimise NFS readdir hack slightly; don't call readdir() again when doneDavid Woodhouse1-4/+7
Date: Sun, 17 Aug 2008 17:12:56 +0100 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Minor cleanup of btrfs_real_readdir()David Woodhouse1-15/+21
Date: Sun, 17 Aug 2008 17:08:36 +0100 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Remove special cases for "." and ".."David Woodhouse1-50/+2
Date: Sun, 17 Aug 2008 15:14:48 +0100 We never get asked by the VFS to lookup either of them, and we can handle the readdir() case a lot more simply, too. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Discard sector data in __free_extent()David Woodhouse1-0/+25
Date: Tue, 12 Aug 2008 14:13:26 +0100 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Implement our own copy of the nfsd readdir hack, for older kernelsDavid Woodhouse1-2/+102
Date: Wed, 6 Aug 2008 19:42:33 +0100 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25NFS support for btrfs - v3Balaji Rao5-1/+247
Date: Mon, 21 Jul 2008 02:01:56 +0530 Here's an implementation of NFS support for btrfs. It relies on the fixes which are going in to 2.6.28 for the NFS readdir/lookup deadlock. This uses the btrfs_iget helper introduced previously. [dwmw2: Tidy up a little, switch to d_obtain_alias() w/compat routine, change fh_type, store parent's root object ID where needed, fix some get_parent() and fs_to_dentry() bugs] Signed-off-by: Balaji Rao <balajirrao@gmail.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Introduce btrfs_iget helperBalaji Rao2-18/+39
Date: Mon, 21 Jul 2008 02:01:04 +0530 This patch introduces a btrfs_iget helper to be used in NFS support. Signed-off-by: Balaji Rao <balajirrao@gmail.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Wait for async bio submissions to make some progress at queue timeChris Mason4-10/+27
Before, the btrfs bdi congestion function was used to test for too many async bios. This keeps that check to throttle pdflush, but also adds a check while queuing bios. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Lookup readpage checksums on bio submission againChris Mason2-60/+6
This optimization had been removed because I thought it was triggering csum errors. The real cause of the errors was elsewhere, and so this optimization is back. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Fix add_extent_mapping to check for duplicates across the whole rangeChris Mason2-4/+24
add_extent_mapping was allowing the insertion of overlapping extents. This never used to happen because it only inserted the extents from disk and those were never overlapping. But, with the data=ordered code, the disk and memory representations of the file are not the same. add_extent_mapping needs to ensure a new extent does not overlap before it inserts. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Remove broken optimisations in end_bio functions.David Woodhouse1-138/+21
These ended up freeing objects while they were still using them. Under guidance from Chris, just rip out the 'clever' bits and do things the simple way. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Lower contention on the csum mutexChris Mason4-8/+22
This takes the csum mutex deeper in the call chain and releases it more often. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Wait for kernel threads to make progress during async submissionChris Mason3-20/+33
Before this change, btrfs would use a bdi congestion function to make sure there weren't too many pending async checksum work items. This change makes the process creating async work items wait instead, leading to fewer congestion returns from the bdi. This improves pdflush background_writeout scanning. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Give all the worker threads descriptive namesChris Mason3-10/+24
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Transaction commit: don't use filemap_fdatawaitChris Mason3-12/+36
After writing out all the remaining btree blocks in the transaction, the commit code would use filemap_fdatawait to make sure it was all on disk. This means it would wait for blocks written by other procs as well. The new code walks the list of blocks for this transaction again and waits only for those required by this transaction. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Count async bios separately from async checksum work itemsChris Mason3-6/+26
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Limit the number of async bio submission kthreads to the number of ↵Chris Mason1-1/+3
devices Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Init address_space->writeback_index properlyChris Mason1-0/+4
The writeback_index field is used by write_cache_pages to pick up where writeback on a given inode left off. But, it is never set to a sane value, so writeback can often start at a random offset in the file. Kernels 2.6.28 and higher will have this fixed, but for everyone else, we also fill in the value in btrfs. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Change TestSetPageLocked() to trylock_page()David Woodhouse2-1/+5
Add backwards compatibility in compat.h Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> --- compat.h | 3 +++ extent_io.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletions(-) Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: fix RHEL test for ClearPageFsMiscEric Sandeen1-1/+1
Newer RHEL5 kernels define both ClearPageFSMisc and ClearPageChecked, so test for both before redefining. Signed-off-by: Eric Sandeen <sandeen@redhat.com> --- Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Update version.sh to v0.16Chris Mason1-1/+1
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Avoid calling into the FS for the final iput on fake root inodesChris Mason2-0/+4
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Fix nodatacow for the new data=ordered modeYan Zheng7-34/+74
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Get rid of BTRFS_I(inode)->index and use local vars insteadChris Mason2-34/+34
rename and link don't always have a lock on the source inode, and our use of a per-inode index variable was racy. This changes things to store the index in a local variable instead. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Fix the multi-bio code to save the original bio for completionChris Mason2-1/+11
The multi-bio code is responsible for duplicating blocks in raid1 and single spindle duplication. It has counters to make sure all of the locations for a given extent are properly written before io completion is returned to the higher layers. But, it didn't always complete the same bio it was given, sometimes a clone was completed instead. This lead to problems with the async work queues because they saved a pointer to the bio in a struct off bi_private. The fix is to remember the original bio and only complete that one. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Update clone file ioctlYan Zheng1-80/+70
This patch updates the file clone ioctl for the tree locking and new data ordered code. --- Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Various small fixes.Yan Zheng5-10/+11
This trivial patch contains two locking fixes and a off by one fix. --- Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25btrfs_lookup_bio_sums seems broken, go back to the readpage_io_hook for nowChris Mason2-7/+56
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Maintain a list of inodes that are delalloc and a way to wait on themChris Mason7-13/+60
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Don't corrupt ram in shrink_extent_tree, leak it insteadChris Mason1-0/+2
Far from the perfect fix, but these structs are small. TODO for the next release. The block group cache structs are referenced in many different places, and it isn't safe to just free them while resizing. A real fix will be a larger change to the allocator so that it doesn't have to carry about the block group cache structs to find good places to search for free blocks. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: fix ioctl-initiated transactions vs wait_current_trans()Sage Weil4-6/+27
Commit 597:466b27332893 (btrfs_start_transaction: wait for commits in progress) breaks the transaction start/stop ioctls by making btrfs_start_transaction conditionally wait for the next transaction to start. If an application artificially is holding a transaction open, things deadlock. This workaround maintains a count of open ioctl-initiated transactions in fs_info, and avoids wait_current_trans() if any are currently open (in start_transaction() and btrfs_throttle()). The start transaction ioctl uses a new btrfs_start_ioctl_transaction() that _does_ call wait_current_trans(), effectively pushing the join/wait decision to the outer ioctl-initiated transaction. This more or less neuters btrfs_throttle() when ioctl-initiated transactions are in use, but that seems like a pretty fundamental consequence of wrapping lots of write()'s in a transaction. Btrfs has no way to tell if the application considers a given operation as part of it's transaction. Obviously, if the transaction start/stop ioctls aren't being used, there is no effect on current behavior. Signed-off-by: Sage Weil <sage@newdream.net> --- ctree.h | 1 + ioctl.c | 12 +++++++++++- transaction.c | 18 +++++++++++++----- transaction.h | 2 ++ 4 files changed, 27 insertions(+), 6 deletions(-) Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Add support for HW assisted crc32cChris Mason1-2/+93
Intel doesn't yet ship hardware to the public with this enabled, but when they do, they will be ready. Original code from: Austin Zhang <austin_zhang@linux.intel.com> It is currently disabled, but edit crc32c.h to turn it on. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Hold csum mutex while reading in sums during readpagesChris Mason2-1/+3
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: More throttle tuningChris Mason3-58/+29
* Make walk_down_tree wake up throttled tasks more often * Make walk_down_tree call cond_resched during long loops * As the size of the ref cache grows, wait longer in throttle * Get rid of the reada code in walk_down_tree, the leaves don't get read anymore, thanks to the ref cache. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25btrfs_search_slot: reduce lock contention by cowing in two stagesChris Mason6-48/+173
A btree block cow has two parts, the first is to allocate a destination block and the second is to copy the old bock over. The first part needs locks in the extent allocation tree, and may need to do IO. This changeset splits that into a separate function that can be called without any tree locks held. btrfs_search_slot is changed to drop its path and start over if it has to COW a contended block. This often means that many writers will pre-alloc a new destination for a the same contended block, but they cache their prealloc for later use on lower levels in the tree. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Throttle less often waiting for snapshots to deleteChris Mason2-16/+5
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Improve and cleanup locking done by walk_down_treeChris Mason3-34/+70
While dropping snapshots, walk_down_tree does most of the work of checking reference counts and limiting tree traversal to just the blocks that we are freeing. It dropped and held the allocation mutex in strange and confusing ways, this commit changes it to only hold the mutex while actually freeing a block. The rest of the checks around reference counts should be safe without the lock because we only allow one process in btrfs_drop_snapshot at a time. Other processes dropping reference counts should not drop it to 1 because their tree roots already have an extra ref on the block. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Hold a reference on bios during submit_bio, add some extra bio checksChris Mason1-1/+9
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Drop some debugging around the extent_map pinned flagChris Mason2-31/+1
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Fix streaming read performance with checksumming onChris Mason5-54/+99
Large streaming reads make for large bios, which means each entry on the list async work queues represents a large amount of data. IO congestion throttling on the device was kicking in before the async worker threads decided a single thread was busy and needed some help. The end result was that a streaming read would result in a single CPU running at 100% instead of balancing the work off to other CPUs. This patch also changes the pre-IO checksum lookup done by reads to work on a per-bio basis instead of a per-page. This results in many extra btree lookups on large streaming reads. Doing the checksum lookup right before bio submit allows us to reuse searches while processing adjacent offsets. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Throttle tuningChris Mason3-12/+31
This avoids waiting for transactions with pages locked by breaking out the code to wait for the current transaction to close into a function called by btrfs_throttle. It also lowers the limits for where we start throttling. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Add missing hunk from Yan Zheng's cache reclaim patchChris Mason1-0/+1
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Add compatibility for kernels >= 2.6.27-rc1Sven Wegener3-2/+37
Add a couple of #if's to follow API changes. Signed-off-by: Sven Wegener <sven.wegener@stealer.net> Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: implement memory reclaim for leaf reference cacheYan15-69/+86
The memory reclaiming issue happens when snapshot exists. In that case, some cache entries may not be used during old snapshot dropping, so they will remain in the cache until umount. The patch adds a field to struct btrfs_leaf_ref to record create time. Besides, the patch makes all dead roots of a given snapshot linked together in order of create time. After a old snapshot was completely dropped, we check the dead root list and remove all cache entries created before the oldest dead root in the list. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Fix verify_parent_transidChris Mason2-2/+5
It was incorrectly clearing the up to date flag on the buffer even when the buffer properly verified. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: Update and fix mount -o nodatacowYan Zheng5-96/+142
To check whether a given file extent is referenced by multiple snapshots, the checker walks down the fs tree through dead root and checks all tree blocks in the path. We can easily detect whether a given tree block is directly referenced by other snapshot. We can also detect any indirect reference from other snapshot by checking reference's generation. The checker can always detect multiple references, but can't reliably detect cases of single reference. So btrfs may do file data cow even there is only one reference. Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25Btrfs: async-thread: fix possible memory leakLi Zefan1-0/+1
When kthread_run() returns failure, this worker hasn't been added to the list, so btrfs_stop_workers() won't free it. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>