summaryrefslogtreecommitdiffstats
path: root/fs
Commit message (Collapse)AuthorAgeFilesLines
* Btrfs: drop WARN_ON from btrfs_add_leaf_refChris Mason2008-09-291-1/+0
| | | | | | | | | | | | btrfs_add_leaf_ref was doing checks on the objects it found in the rbtree to make sure they were properly linked into the tree. But, the field it was checking can be safely changed outside of the tree spin lock. The WARN_ON was for debugging the initial implementation and can be safely removed. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Wait for IO on the block device inodes of newly added devicesChris Mason2008-09-294-4/+22
| | | | | | | | | | | | | | | | | | | btrfs-vol -a /dev/xxx will zero the first and last two MB of the device. The kernel code needs to wait for this IO to finish before it adds the device. btrfs metadata IO does not happen through the block device inode. A separate address space is used, allowing the zero filled buffer heads in the block device inode to be written to disk after FS metadata starts going down to the disk via the btrfs metadata inode. The end result is zero filled metadata blocks after adding new devices into the filesystem. The fix is a simple filemap_write_and_wait on the block device inode before actually inserting it into the pool of available devices. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: update space balancing codeZheng Yan2008-09-267-425/+1828
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch updates the space balancing code to utilize the new backref format. Before, btrfs-vol -b would break any COW links on data blocks or metadata. This was slow and caused the amount of space used to explode if a large number of snapshots were present. The new code can keeps the sharing of all data extents and most of the tree blocks. To maintain the sharing of data extents, the space balance code uses a seperate inode hold data extent pointers, then updates the references to point to the new location. To maintain the sharing of tree blocks, the space balance code uses reloc trees to relocate tree blocks in reference counted roots. There is one reloc tree for each subvol, and all reloc trees share same root key objectid. Reloc trees are snapshots of the latest committed roots of subvols (root->commit_root). To relocate a tree block referenced by a subvol, there are two steps. COW the block through subvol's reloc tree, then update block pointer in the subvol to point to the new block. Since all reloc trees share same root key objectid, doing special handing for tree blocks owned by them is easy. Once a tree block has been COWed in one reloc tree, we can use the resulting new block directly when the same block is required to COW again through other reloc trees. In this way, relocated tree blocks are shared between reloc trees, so they are also shared between subvols. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: extent_map and data=ordered fixes for space balancingZheng Yan2008-09-2610-49/+108
| | | | | | | | | | | | | | | | | | | | | * Add an EXTENT_BOUNDARY state bit to keep the writepage code from merging data extents that are in the process of being relocated. This allows us to do accounting for them properly. * The balancing code relocates data extents indepdent of the underlying inode. The extent_map code was modified to properly account for things moving around (invalidating extent_map caches in the inode). * Don't take the drop_mutex in the create_subvol ioctl. It isn't required. * Fix walking of the ordered extent list to avoid races with sys_unlink * Change the lock ordering rules. Transaction start goes outside the drop_mutex. This allows btrfs_commit_transaction to directly drop the relocation trees. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Add shared reference cacheZheng Yan2008-09-266-34/+71
| | | | | | | | | | | | | Btrfs has a cache of reference counts in leaves, allowing it to avoid reading tree leaves while deleting snapshots. To reduce contention with multiple subvolumes, this cache is private to each subvolume. This patch adds shared reference cache support. The new space balancing code plays with multiple subvols at the same time, So the old per-subvol reference cache is not well suited. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: allocator fixes for space balancing updateZheng Yan2008-09-262-71/+67
| | | | | | | | | | | | | * Reserved extent accounting: reserved extents have been allocated in the rbtrees that track free space but have not been allocated on disk. They were never properly accounted for in the past, making it hard to know how much space was really free. * btrfs_find_block_group used to return NULL for block groups that had been removed by the space balancing code. This made it hard to account for space during the final stages of a balance run. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Raise thresholds for metadata writebackChris Mason2008-09-251-2/+2
| | | | | | | | | | | | | Btrfs metadata writeback is fairly expensive. Once a tree block is written it must be cowed before it can be changed again. The btree writepages code has a threshold based on a count of dirty btree bytes which is updated as IO is sent out. This changes btree_writepages to skip the writeout if there are less than 32MB of dirty bytes from the btrees, improving performance across many workloads. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: fix sleep with spinlock held during unmountChris Mason2008-09-251-0/+4
| | | | | | | | | | The code to free block groups needs to drop the space info spin lock before calling btrfs_remove_free_space_cache (which can schedule). This is safe because at unmount time, nobody else is going to play with the block groups. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Remove Btrfs compat code for older kernelsChris Mason2008-09-2512-368/+10
| | | | | | | | Btrfs had compatibility code for kernels back to 2.6.18. These have been removed, and will be maintained in a separate backport git tree from now on. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Fix allocation completions in tree log replayChris Mason2008-09-251-0/+34
| | | | | | | | | | | | After a crash, the tree log code uses btrfs_alloc_logged_extent to record allocations of data extents that it finds in the log tree. These come in basically random order, which does not fit how btrfs_remove_free_space() expects to be called. btrfs_remove_free_space was changed to support recording an extent allocation in the middle of a region of free space. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Add Btrfs to fs/Kconfig and fs/MakefileChris Mason2008-09-252-0/+18
| | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Update Btrfs files for in-kernel usageChris Mason2008-09-252-6/+5
| | | | | | | | btrfs had magic to put the chagneset id into a printk on module load. This removes that from the Makefile and hardcodes the printk to print "Btrfs" Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Merge Btrfs into fs/btrfsChris Mason2008-09-2556-0/+34936
|\
| * Btrfs: Fix race against disk_i_size updatesChris Mason2008-09-251-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The code to update the on disk i_size happens before the ordered_extent record is removed. So, it is possible for multiple ordered_extent completion routines to run at the same time, and to find each other in the ordered tree. The end result is they both decide not to update disk_i_size, leaving it too small. This temporary fix just puts the updates inside the extent_mutex. A real solution would be stronger ordering of disk_i_size updates against removing the ordered extent from the tree. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Full back reference supportZheng Yan2008-09-2510-722/+1066
| | | | | | | | | | | | | | | | | | | | This patch makes the back reference system to explicit record the location of parent node for all types of extents. The location of parent node is placed into the offset field of backref key. Every time a tree block is balanced, the back references for the affected lower level extents are updated. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Add check for tree-log roots in btrfs_alloc_reserved_extentsChris Mason2008-09-251-0/+3
| | | | | | | | | | | | | | | | Tree log blocks are only reserved, and should not ever get fully allocated on disk. This check makes sure they stay out of the extent tree. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Checksum tree blocks in the backgroundChris Mason2008-09-251-9/+17
| | | | | | | | | | | | | | | | Tree blocks were using async bio submission, but the sum was still being done directly during writepage. This moves the checksumming into the worker thread. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: free space accounting redoJosef Bacik2008-09-259-435/+925
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1) replace the per fs_info extent_io_tree that tracked free space with two rb-trees per block group to track free space areas via offset and size. The reason to do this is because most allocations come with a hint byte where to start, so we can usually find a chunk of free space at that hint byte to satisfy the allocation and get good space packing. If we cannot find free space at or after the given offset we fall back on looking for a chunk of the given size as close to that given offset as possible. When we fall back on the size search we also try to find a slot as close to the size we want as possible, to avoid breaking small chunks off of huge areas if possible. 2) remove the extent_io_tree that tracked the block group cache from fs_info and replaced it with an rb-tree thats tracks block group cache via offset. also added a per space_info list that tracks the block group cache for the particular space so we can lookup related block groups easily. 3) cleaned up the allocation code to make it a little easier to read and a little less complicated. Basically there are 3 steps, first look from our provided hint. If we couldn't find from that given hint, start back at our original search start and look for space from there. If that fails try to allocate space if we can and start looking again. If not we're screwed and need to start over again. 4) small fixes. there were some issues in volumes.c where we wouldn't allocate the rest of the disk. fixed cow_file_range to actually pass the alloc_hint, which has helped a good bit in making the fs_mark test I run have semi-normal results as we run out of space. Generally with data allocations we don't track where we last allocated from, so everytime we did a data allocation we'd search through every block group that we have looking for free space. Now searching a block group with no free space isn't terribly time consuming, it was causing a slight degradation as we got more data block groups. The alloc_hint has fixed this slight degredation and made things semi-normal. There is still one nagging problem I'm working on where we will get ENOSPC when there is definitely plenty of space. This only happens with metadata allocations, and only when we are almost full. So you generally hit the 85% mark first, but sometimes you'll hit the BUG before you hit the 85% wall. I'm still tracking it down, but until then this seems to be pretty stable and make a significant performance gain. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: fix cache_block_group error handlingJosef Bacik2008-09-251-4/+5
| | | | | | | | | | | | | | | | cache block group had a few bugs in the error handling code, this makes sure paths get properly released and the correct return value goes out. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Fix leaf overflow check in btrfs_insert_empty_itemsChris Mason2008-09-251-2/+1
| | | | | | | | | | | | | | It was incorrectly adding an extra sizeof(struct btrfs_item) and causing false positives (oops) Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Fix mismerge in block header checksChris Mason2008-09-251-1/+1
| | | | | | | | | | | | | | I had incorrectly disabled the check for the block number being correct in the header block. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Disable the dir fsync optimization to skip logging the dir sometimesChris Mason2008-09-251-2/+1
| | | | | | | | | | | | More testing has turned up a bug, disable this for now. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Record dirty pages tree-log pages in an extent_io treeChris Mason2008-09-256-24/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the same way the transaction code makes sure that all the other tree blocks are safely on disk. There's an extent_io tree for each root, and any blocks allocated to the tree logs are recorded in that tree. At tree-log sync, the extent_io tree is walked to flush down the dirty pages and wait for them. The main benefit is less time spent walking the tree log and skipping clean pages, and getting sequential IO down to the drive. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Copy into the log tree in big batchesChris Mason2008-09-251-61/+122
| | | | | | | | | | | | | | This changes the log tree copy code to use btrfs_insert_items and to work in larger batches where possible. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Optimize tree log block allocationsChris Mason2008-09-253-21/+23
| | | | | | | | | | | | | | | | Since tree log blocks get freed every transaction, they never really need to be written to disk. This skips the step where we update metadata to record they were allocated. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Optimize btree walking while logging inodesChris Mason2008-09-252-7/+20
| | | | | | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Dir fsync optimizationsChris Mason2008-09-254-6/+29
| | | | | | | | | | | | | | | | | | | | | | Drop i_mutex during the commit Don't bother doing the fsync at all unless the dir is marked as dirtied and needing fsync in this transaction. For directories, this means that someone has unlinked a file from the dir without fsyncing the file. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Fix releasepage to properly keep dirty and writeback pagesChris Mason2008-09-252-1/+6
| | | | | | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Update the highest objectid in a root after log replay is doneChris Mason2008-09-252-1/+9
| | | | | | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Tree logging fixesChris Mason2008-09-257-24/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Pin down data blocks to prevent them from being reallocated like so: trans 1: allocate file extent trans 2: free file extent trans 3: free file extent during old snapshot deletion trans 3: allocate file extent to new file trans 3: fsync new file Before the tree logging code, this was legal because the fsync would commit the transation that did the final data extent free and the transaction that allocated the extent to the new file at the same time. With the tree logging code, the tree log subtransaction can commit before the transaction that freed the extent. If we crash, we're left with two different files using the extent. * Don't wait in start_transaction if log replay is going on. This avoids deadlocks from iput while we're cleaning up link counts in the replay code. * Don't deadlock in replay_one_name by trying to read an inode off the disk while holding paths for the directory * Hold the buffer lock while we mark a buffer as written. This closes a race where someone is changing a buffer while we write it. They are supposed to mark it dirty again after they change it, but this violates the cow rules. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: properly set blocksize when adding new device.Zheng Yan2008-09-251-0/+2
| | | | | | | | | | | | --- Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Update find free objectid function for orphan cleanup codeZheng Yan2008-09-252-8/+10
| | | | | | | | | | | | | | | | | | | | Orphan items use BTRFS_ORPHAN_OBJECTID (-5UUL) as key objectid. This affects the find free objectid functions, inode objectid can easily overflow after orphan file cleanup. --- Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: trivial sparse fixesChristoph Hellwig2008-09-254-11/+7
| | | | | | | | | | | | | | Fix a bunch of trivial sparse complaints. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * remove unused function btrfs_ilookupChristoph Hellwig2008-09-252-15/+0
| | | | | | | | | | | | | | | | btrfs_ilookup is unused, which is good because a normal filesystem should never have to use ilookup anyway. Remove it. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: missing endianess conversion in insert_new_rootChristoph Hellwig2008-09-251-4/+5
| | | | | | | | | | | | | | Add two missing endianess conversions in this function, found by sparse. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: cleanup d_obtain_alias useageChristoph Hellwig2008-09-251-15/+2
| | | | | | | | | | | | | | | | | | d_obtain_alias is intended as a tailcall that can pass in errors encoded in the inode pointer if needed, so use it that way instead of duplicating the error handling. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Rev the disk formatChris Mason2008-09-251-1/+1
| | | | | | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Add a write ahead tree log to optimize synchronous operationsChris Mason2008-09-2517-205/+3408
| | | | | | | | | | | | | | | | | | | | | | File syncs and directory syncs are optimized by copying their items into a special (copy-on-write) log tree. There is one log tree per subvolume and the btrfs super block points to a tree of log tree roots. After a crash, items are copied out of the log tree and back into the subvolume. See tree-log.c for all the details. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Add debugging checks to track down corrupted metadataChris Mason2008-09-254-34/+49
| | | | | | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: optimize btrget/set/removexattrChristoph Hellwig2008-09-254-170/+104
| | | | | | | | | | | | | | | | | | | | | | | | btrfs actually stores the whole xattr name, including the prefix ondisk, so using the generic resolver that strips off the prefix is not very helpful. Instead do the real ondisk xattrs manually and only use the generic resolver for synthetic xattrs like ACLs. (Sorry Josef for guiding you towards the wrong direction here intially) Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * btrfs: optmize listxattrChristoph Hellwig2008-09-253-81/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | The ->list handler is really not useful at all, because we always call btrfs_xattr_generic_list anyway. After this is done find_btrfs_xattr_handler becomes unused, and it becomes obvious that the temporary name buffer allocation isn't needed but we can directly copy into the supplied buffer. Tested with various getfattr -d calls on varying xattr lists. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: compile when posix acl's are disabledJosef Bacik2008-09-252-2/+22
| | | | | | | | | | | | | | This patch makes btrfs so it will compile properly when acls are disabled. I tested this and it worked with CONFIG_FS_POSIX_ACL off and on. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Fix variable init during csum creationChris Mason2008-09-251-0/+1
| | | | | | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Throttle for async bio submits higher up the chainChris Mason2008-09-252-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current code waits for the count of async bio submits to get below a given threshold if it is too high right after adding the latest bio to the work queue. This isn't optimal because the caller may have sequential adjacent bios pending they are waiting to send down the pipe. This changeset requires the caller to wait on the async bio count, and changes the async checksumming submits to wait for async bios any time they self throttle. The end result is much higher sequential throughput. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Rev the disk formatChris Mason2008-09-251-1/+1
| | | | | | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Clean up btrfs_get_parent() a little more, fix a free-after-free bugDavid Woodhouse2008-09-251-13/+18
| | | | | | | | | | | | Date: Tue, 19 Aug 2008 22:33:04 +0100 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Fix NFS exporting of subvol roots.David Woodhouse2008-09-251-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | Date: Tue, 19 Aug 2008 22:20:17 +0100 btrfs_lookup_fs_root() only finds subvol roots which have already been seen and put into the cache. For btrfs_get_dentry() we actually have to go to the medium -- so use btrfs_read_fs_root_no_name() instead. In btrfs_get_parent(), notice when we've hit the root of the subvolume and return the real root instead. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Switch btrfs_name_hash() to crc32cDavid Woodhouse2008-09-253-114/+7
| | | | | | | | | | | | | | | | | | Date: Tue, 19 Aug 2008 19:21:57 +0100 Using a 64-bit hash as the readdir cookie is just asking for trouble. And gets it, when we try to export the file system by NFS. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Reinstate '-osubvol=.' option to mount entire treeDavid Woodhouse2008-09-251-15/+19
| | | | | | | | | | | | | | | | Date: Tue, 19 Aug 2008 16:49:35 +0100 This disappeared when I removed the special case for '.' in btrfs_lookup() Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Simplify btrfs_get_parent(), fix use-after-free bugDavid Woodhouse2008-09-251-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>
OpenPOWER on IntegriCloud