summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Btrfs: move data checksumming into a dedicated treeChris Mason2008-12-0811-241/+387
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Btrfs stores checksums for each data block. Until now, they have been stored in the subvolume trees, indexed by the inode that is referencing the data block. This means that when we read the inode, we've probably read in at least some checksums as well. But, this has a few problems: * The checksums are indexed by logical offset in the file. When compression is on, this means we have to do the expensive checksumming on the uncompressed data. It would be faster if we could checksum the compressed data instead. * If we implement encryption, we'll be checksumming the plain text and storing that on disk. This is significantly less secure. * For either compression or encryption, we have to get the plain text back before we can verify the checksum as correct. This makes the raid layer balancing and extent moving much more expensive. * It makes the front end caching code more complex, as we have touch the subvolume and inodes as we cache extents. * There is potentitally one copy of the checksum in each subvolume referencing an extent. The solution used here is to store the extent checksums in a dedicated tree. This allows us to index the checksums by phyiscal extent start and length. It means: * The checksum is against the data stored on disk, after any compression or encryption is done. * The checksum is stored in a central location, and can be verified without following back references, or reading inodes. This makes compression significantly faster by reducing the amount of data that needs to be checksummed. It will also allow much faster raid management code in general. The checksums are indexed by a key with a fixed objectid (a magic value in ctree.h) and offset set to the starting byte of the extent. This allows us to copy the checksum items into the fsync log tree directly (or any other tree), without having to invent a second format for them. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Fix sparse endian warnings in struct-funcs.cChris Mason2008-12-021-5/+12
| | | | | | | | | The btrfs macros to access individual struct members on disk were sending the same variable to functions that expected different types of endianness. This fix explicitly creates a variable of the correct type instead of abusing a single variable for mixed purposes. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: rev the disk format for the inode compat and csum selection changesChris Mason2008-12-021-1/+1
| | | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: delete unused function: btrfs_invalidate_dcache_rootChris Mason2008-12-021-25/+0
| | | | | | | Snapshot and subvolume creation no longer need this helper. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: add support for multiple csum algorithmsJosef Bacik2008-12-025-38/+81
| | | | | | | | | This patch gives us the space we will need in order to have different csum algorithims at some point in the future. We save the csum algorithim type in the superblock, and use those instead of define's. Signed-off-by: Josef Bacik <jbacik@redhat.com>
* Btrfs: fix panic on error during mountJosef Bacik2008-12-021-4/+4
| | | | | | | | | | | This needs to be applied on top of my previous patches, but is needed for more than just my new stuff. We're going to the wrong label when we have an error, we try to stop the workers, but they are started below all of this code. This fixes it so we go to the right error label and not panic when we fail one of these cases. Signed-off-by: Josef Bacik <jbacik@redhat.com>
* Btrfs: add support for compat flags to btrfsJosef Bacik2008-12-022-7/+42
| | | | | | | | | | | | | | | | This adds the necessary disk format for handling compatibility flags in the future to handle disk format changes. We have a compat_flags, compat_ro_flags and incompat_flags set for the super block. Compat flags will be to hold the features that are compatible with older versions of btrfs, compat_ro flags have features that are compatible with older versions of btrfs if the fs is mounted read only, and incompat_flags has features that are incompatible with older versions of btrfs. This also axes the compat_flags field for the inode and just makes the flags field a 64bit field, and changes the root item flags field to 64bit. Signed-off-by: Josef Bacik <jbacik@redhat.com>
* Btrfs: btrfs: pass void __user * to btrfs_ioctl_clone_rangeChristoph Hellwig2008-12-021-3/+3
| | | | | | | | Cleans the code up a little and also avoids a sparse warning due to the incorrect cast in the current version of the code. Signed-off-by: Christoph Hellwig <hch@lst.de>
* Btrfs: clean up btrfs_ioctl a little bitChristoph Hellwig2008-12-021-5/+6
| | | | | | | | Provide a void __user *argp pointer so that we can avoid duplicating the cast for various sub-command calls. Signed-off-by: Christoph Hellwig <hch@lst.de>
* Btrfs: corret fmode_t annotationsChristoph Hellwig2008-12-023-16/+20
| | | | | | | | Make sure to propagate fmode_t properly and use the right constants for it. Signed-off-by: Christoph Hellwig <hch@lst.de>
* Btrfs: fix shadowed variable declarationsChristoph Hellwig2008-12-022-5/+4
| | | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: make things static and include the right headersChristoph Hellwig2008-12-0213-67/+68
| | | | | | | | Shut up various sparse warnings about symbols that should be either static or have their declarations in scope. Signed-off-by: Christoph Hellwig <hch@lst.de>
* Btrfs: remove unneeded btrfs_start_delalloc_inodes callSage Weil2008-12-021-1/+0
| | | | | | | It is called by btrfs_sync_fs. Signed-off-by: Sage Weil <sage@newdream.net>
* Btrfs: remove unneeded total_transSage Weil2008-12-021-4/+0
| | | | | | | | | Remove unneeded debugging sanity check. It gets corrupted anyway when multiple btrfs file systems are mounted, throwing bad warnings along the way. Signed-off-by: Sage Weil <sage@newdream.net>
* Btrfs: sparse lock verification annotations for wait_on_stateChristoph Hellwig2008-12-021-0/+2
| | | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Fix cow semantic in run_delalloc_nocow()Liu Hui2008-12-011-2/+2
| | | | | | The file preallocation code reversed the logic to force nodatacow. This fixes it.
* Btrfs: Fix for lockdep warnings with alloc_mutex and pinned_mutexJosef Bacik2008-11-202-14/+19
| | | | | | | | This the lockdep complaint by having a different mutex to gaurd caching the block group, so you don't end up with this backwards dependancy. Thank you, Signed-off-by: Josef Bacik <jbacik@redhat.com>
* Btrfs: only flush down bios for writeback pagesChris Mason2008-11-201-1/+2
| | | | | | | | | The btrfs write_cache_pages call has a flush function so that it submits the bio it has been building before it waits on any writeback pages. This adds a check so that flush only happens on writeback pages. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Fix cow semantic in run_delalloc_nocow()Liu Hui2008-11-200-0/+0
| | | | | | The file preallocation code reversed the logic to force nodatacow. This fixes it.
* Btrfs: Drop dirty roots created by log replay immediately whenYan Zheng2008-11-201-0/+5
| | | | | | | | | | The log replay produces dirty roots. These dirty roots should be dropped immediately if the fs is mounted as ro. Otherwise they can be added to the dirty root list again when remounting the fs as rw. Thank you, Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Btrfs: compat code fixesChris Mason2008-11-208-4/+14
| | | | | | | | The btrfs git kernel trees is used to build a standalone tree for compiling against older kernels. This commit makes the standalone tree work with 2.6.27 Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Use current_fsuid/gidChris Mason2008-11-191-2/+2
| | | | | | This fixes compile problems with linux-next Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Fixes for 2.6.28-rc API changesChris Mason2008-11-197-46/+74
| | | | | | | | * open/close_bdev_excl -> open/close_bdev_exclusive * blkdev_issue_discard takes a GFP mask now * Fix blkdev_issue_discard usage now that it is enabled Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Merge branch 'master' of ↵Chris Mason2008-11-1959-0/+42196
|\ | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable
| * Btrfs: fix free space accounting when unpinning extentsJosef Bacik2008-11-191-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes what I hope is the last early ENOSPC bug left. I did not know that pinned extents would merge into one big extent when inserted on to the pinned extent tree, so I was adding free space to a block group that could possibly span multiple block groups. This is a big issue because first that space doesn't exist in that block group, and second we won't actually use that space because there are a bunch of other checks to make sure we're allocating within the constraints of the block group. This patch fixes the problem by adding the btrfs_add_free_space to btrfs_update_pinned_extents which makes sure we are adding the appropriate amount of free space to the appropriate block group. Thanks much to Lee Trager for running my myriad of debug patches to help me track this problem down. Thank you, Signed-off-by: Josef Bacik <jbacik@redhat.com>
| * Btrfs: Do fsync log replay when mount -o ro, except when on readonly mediaChris Mason2008-11-191-8/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | fsync log replay can change the filesystem, so it cannot be delayed until mount -o rw,remount, and it can't be forgotten entirely. So, this patch changes btrfs to do with reiserfs, ext3 and xfs do, which is to do the log replay even when mounted readonly. On a readonly device if log replay is required, the mount is aborted. Getting all of this right had required fixing up some of the error handling in open_ctree. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Avoid writeback stallsChris Mason2008-11-193-20/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While building large bios in writepages, btrfs may end up waiting for other page writeback to finish if WB_SYNC_ALL is used. While it is waiting, the bio it is building has a number of pages with the writeback bit set and they aren't getting to the disk any time soon. This lowers the latencies of writeback in general by sending down the bio being built before waiting for other pages. The bio submission code tries to limit the total number of async bios in flight by waiting when we're over a certain number of async bios. But, the waits are happening while writepages is building bios, and this can easily lead to stalls and other problems for people calling wait_on_page_writeback. The current fix is to let the congestion tests take care of waiting. sync() and others make sure to drain the current async requests to make sure that everything that was pending when the sync was started really get to disk. The code would drain pending requests both before and after submitting a new request. But, if one of the requests is waiting for page writeback to finish, the draining waits might block that page writeback. This changes the draining code to only wait after submitting the bio being processed. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: switch back to wait_on_page_writeback to wait on metadata writesChris Mason2008-11-181-28/+1
| | | | | | | | | | | | | | | | The extent based waiting was using more CPU, and other fixes have helped with the unplug storm problems. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Update the disk format for the seed device and new root codeChris Mason2008-11-181-1/+1
| | | | | | | | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: unplug all devices in the unplug call backChris Mason2008-11-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | For larger multi-device filesystems, there was logic to limit the number of devices unplugged to just the page that was sent to our sync_page function. But, the code wasn't always unplugging the right device. Since this was just an optimization, disable it for now. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Some fixes for batching extent insert.Liu Hui2008-11-182-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In insert_extents(), when ret==1 and last is not zero, it should check if the current inserted item is the last item in this batching inserts. If so, it should just break from loop. If not, 'cur = insert_list->next' will make no sense because the list is empty now, and 'op' will point to an unexpectable place. There are also some trivial fixs in this patch including one comment typo error and deleting two redundant lines. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: prevent loops in the directory tree when creating snapshotsChris Mason2008-11-174-1/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For a directory tree: /mnt/subvolA/subvolB btrfsctl -s /mnt/subvolA/subvolB /mnt Will create a directory loop with subvolA under subvolB. This commit uses the forward refs for each subvol and snapshot to error out before creating the loop. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Add backrefs and forward refs for subvols and snapshotsChris Mason2008-11-175-32/+172
| | | | | | | | | | | | | | | | | | | | | | | | | | Subvols and snapshots can now be referenced from any point in the directory tree. We need to maintain back refs for them so we can find lost subvols. Forward refs are added so that we know all of the subvols and snapshots referenced anywhere in the directory tree of a single subvol. This can be used to do recursive snapshotting (but they aren't yet) and it is also used to detect and prevent directory loops when creating new snapshots. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Give each subvol and snapshot their own anonymous devidChris Mason2008-11-175-6/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Each subvolume has its own private inode number space, and so we need to fill in different device numbers for each subvolume to avoid confusing applications. This commit puts a struct super_block into struct btrfs_root so it can call set_anon_super() and get a different device number generated for each root. btrfs_rename is changed to prevent renames across subvols. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Allow subvolumes and snapshots anywhere in the directory treeChris Mason2008-11-178-65/+162
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before, all snapshots and subvolumes lived in a single flat directory. This was awkward and confusing because the single flat directory was only writable with the ioctls. This commit changes the ioctls to create subvols and snapshots at any point in the directory tree. This requires making separate ioctls for snapshot and subvol creation instead of a combining them into one. The subvol ioctl does: btrfsctl -S subvol_name parent_dir After the ioctl is done subvol_name lives inside parent_dir. The snapshot ioctl does: btrfsctl -s path_for_snapshot root_to_snapshot path_for_snapshot can be an absolute or relative path. btrfsctl breaks it up into directory and basename components. root_to_snapshot can be any file or directory in the FS. The snapshot is taken of the entire root where that file lives. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Add some debugging around the ENOSPC bugsJosef Bacik2008-11-171-0/+3
| | | | | | | | | | | | | | | | Some people are still reporting problems with early enospc. This will help narrown down the cause. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: fix free space leakJosef Bacik2008-11-171-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In my batch delete/update/insert patch I introduced a free space leak. The extent that we do the original search on in free_extents is never pinned, so we always update the block saying that it has free space, but the free space never actually gets added to the free space tree, since op->del will always be 0 and it's never actually added to the pinned extents tree. This patch fixes this problem by making sure we call pin_down_bytes on the pending extent op and set op->del to the return value of pin_down_bytes so update_block_group is called with the right value. This seems to fix the case where we were getting ENOSPC when there was plenty of space available. Signed-off-by: Josef Bacik <jbacik@redhat.com>
| * Btrfs: Add a missing return pointer checkyanhai zhu2008-11-121-0/+2
| | | | | | | | | | | | | | Add a missing kzalloc() return pointer check in add_missing_dev(). Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Check kthread_should_stop() before schedule() in worker_loopyanhai zhu2008-11-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | In worker_loop(), the func should check whether it has been requested to stop before it decides to schedule out. Otherwise if the stop request(also the last wake_up()) sent by btrfs_stop_workers() happens when worker_loop() running after the "while" judgement and before schedule(), woker_loop() will schedule away and never be woken up, which will also cause btrfs_stop_workers() wait forever. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Fix race in btrfs_mark_extent_writtenYan Zheng2008-11-121-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | When extent needs to be split, btrfs_mark_extent_written truncates the extent first, then inserts a new extent and increases the reference count. The race happens if someone else deletes the old extent before the new extent is inserted. The fix here is increase the reference count in advance. This race is similar to the race in btrfs_drop_extents that was recently fixed. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
| * Btrfs: Seed device supportYan Zheng2008-11-178-315/+932
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Seed device is a special btrfs with SEEDING super flag set and can only be mounted in read-only mode. Seed devices allow people to create new btrfs on top of it. The new FS contains the same contents as the seed device, but it can be mounted in read-write mode. This patch does the following: 1) split code in btrfs_alloc_chunk into two parts. The first part does makes the newly allocated chunk usable, but does not do any operation that modifies the chunk tree. The second part does the the chunk tree modifications. This division is for the bootstrap step of adding storage to the seed device. 2) Update device management code to handle seed device. The basic idea is: For an FS grown from seed devices, its seed devices are put into a list. Seed devices are opened on demand at mounting time. If any seed device is missing or has been changed, btrfs kernel module will refuse to mount the FS. 3) make btrfs_find_block_group not return NULL when all block groups are read-only. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
| * Btrfs: mount ro and remount supportYan Zheng2008-11-127-58/+163
| | | | | | | | | | | | | | | | | | | | | | This patch adds mount ro and remount support. The main changes in patch are: adding btrfs_remount and related helper function; splitting the transaction related code out of close_ctree into btrfs_commit_super; updating allocator to properly handle read only block group. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
| * Btrfs: batch extent inserts/updates/deletions on the extent rootJosef Bacik2008-11-123-93/+909
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While profiling the allocator I noticed a good amount of time was being spent in finish_current_insert and del_pending_extents, and as the filesystem filled up more and more time was being spent in those functions. This patch aims to try and reduce that problem. This happens two ways 1) track if we tried to delete an extent that we are going to update or insert. Once we get into finish_current_insert we discard any of the extents that were marked for deletion. This saves us from doing unnecessary work almost every time finish_current_insert runs. 2) Batch insertion/updates/deletions. Instead of doing a btrfs_search_slot for each individual extent and doing the needed operation, we instead keep the leaf around and see if there is anything else we can do on that leaf. On the insert case I introduced a btrfs_insert_some_items, which will take an array of keys with an array of data_sizes and try and squeeze in as many of those keys as possible, and then return how many keys it was able to insert. In the update case we search for an extent ref, update the ref and then loop through the leaf to see if any of the other refs we are looking to update are on that leaf, and then once we are done we release the path and search for the next ref we need to update. And finally for the deletion we try and delete the extent+ref in pairs, so we will try to find extent+ref pairs next to the extent we are trying to free and free them in bulk if possible. This along with the other cluster fix that Chris pushed out a bit ago helps make the allocator preform more uniformly as it fills up the disk. There is still a slight drop as we fill up the disk since we start having to stick new blocks in odd places which results in more COW's than on a empty fs, but the drop is not nearly as severe as it was before. Signed-off-by: Josef Bacik <jbacik@redhat.com>
| * Btrfs: allow clone of an arbitrary file rangeSage Weil2008-11-122-41/+221
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds an additional CLONE_RANGE ioctl to clone an arbitrary (block-aligned) file range to another file. The original CLONE ioctl becomes a special case of cloning the entire file range. The logic is a bit more complex now since ranges may be cloned to different offsets, and because we may only be cloning the beginning or end of a particular extent or checksum item. An additional sanity check ensures the source and destination files aren't the same (which would previously deadlock), although eventually this could be extended to allow the duplication of file data at a different offset within the same file. Any extents within the destination range in the target file are dropped. We currently do not cope with the case where a compressed inline extent needs to be split. This will probably require decompressing the extent into a temporary address_space, and inserting just the cloned portion as a new compressed inline extent. For now, just return -EINVAL in this case. Note that this never comes up in the more common case of cloning an entire file. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Fix handling of space info full during allocationsChris Mason2008-11-131-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | When we fail to allocate a new block group, we should still do the checks to make sure allocations try again with the minimum requested allocation size. This also fixes a deadlock that come from a missed down_read in the chunk allocation failure handling. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Improve metadata read latenciesChris Mason2008-11-132-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | This fixes latency problems on metadata reads by making sure they don't go through the async submit queue, and by tuning down the amount of readahead done during btree searches. Also, the btrfs bdi congestion function is tuned to ignore the number of pending async bios and checksums pending. There is additional code that throttles new async bios now and the congestion function doesn't need to worry about it anymore. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Fix compile warnings on 32 bit machinesChris Mason2008-11-114-8/+12
| | | | | | | | | | | | | | Simple casting here and there to fix things up. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: Fix starting search offset inside btrfs_drop_extentsYan Zheng2008-11-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | btrfs_drop_extents will drop paths and search again when it needs to force COW of higher nodes. It was using the key it found during the last search as the offset for the next search. But, this wasn't always correct. The key could be from before our desired range, and because we're dropping the path, it is possible for file's items to change while we do the search again. The fix here is to make sure we don't search for something smaller than the offset btrfs_drop_extents was called with. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: empty_size allocation fixes againChris Mason2008-11-101-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | The allocator wasn't catching all of the cases where it needed to do extra loops because the check to enforce them wasn't happening early enough. When the allocator decided to increase the size of the allocation for metadata clustering, it wasn't always setting the empty_size to include the extra (optional) bytes. This also fixes the empty_size field to be correct. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: tune btrfs unplug functions for a small number of devicesChris Mason2008-11-101-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | When btrfs unplugs, it tries to find the correct device to unplug via search through the extent_map tree. This avoids unplugging a device that doesn't need it, but is a waste of time for filesystems with a small number of devices. This patch checks the total number of devices before doing the search. Signed-off-by: Chris Mason <chris.mason@oracle.com>
OpenPOWER on IntegriCloud