aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
Commit message (Collapse)AuthorAge
* Btrfs: Fix checkpatch.pl warningsChris Mason2009-01-05
| | | | | | | There were many, most are fixed now. struct-funcs.c generates some warnings but these are bogus. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Fix free block discard calls down to the block layerLiu Hui2009-01-05
| | | | | | | | | | | | | | | | | | | | | | | | | This is a patch to fix discard semantic to make Btrfs work with FTL and SSD. We can improve FTL's performance by telling it which sectors are freed by file system. But if we don't tell FTL the information of free sectors in proper time, the transaction mechanism of Btrfs will be destroyed and Btrfs could not roll back the previous transaction under the power loss condition. There are some problems in the old implementation: 1, In __free_extent(), the pinned down extents should not be discarded. 2, In free_extents(), the free extents are all pinned, so they need to be discarded in transaction committing time instead of free_extents(). 3, The reserved extent used by log tree should be discard too. This patch change discard behavior as follows: 1, For the extents which need to be free at once, we discard them in update_block_group(). 2, Delay discarding the pinned extent in btrfs_finish_extent_commit() when committing transaction. 3, Remove discarding from free_extents() and __free_extent() 4, Add discard interface into btrfs_free_reserved_extent() 5, Discard sectors before updating the free space cache, otherwise, FTL will destroy file system data.
* Btrfs: avoid orphan inode caused by log replayYan Zheng2009-01-05
| | | | | | | | | | | | | | | | drop_one_dir_item does not properly update inode's link count. It can be reproduced by executing following commands: #touch test #sync #rm -f test #dd if=/dev/zero bs=4k count=1 of=test conv=fsync #echo b > /proc/sysrq-trigger This fixes it by adding an BTRFS_ORPHAN_ITEM_KEY for the inode Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Btrfs: avoid potential super block corruptionYan Zheng2009-01-05
| | | | | | | | | | | | | The data in fs_info->super_for_commit are zeros before the first transaction commit. If tree log sync and system crash both occur before the first transaction commit, super block will get corrupted. This fixes it by properly filling in the super_for_commit field at open time. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Btrfs: do not call kfree if kmalloc failed in btrfs_sysfs_add_superShen Feng2009-01-05
| | | | | Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
* Btrfs: fix a memory leak in btrfs_get_sbShen Feng2009-01-05
| | | | | | | subvol_name should be freed if error occurs. Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
* Btrfs: Fix typo in clear_state_cbLiu Hui2009-01-05
| | | | | | | | In clear_state_cb, we should check 'tree->ops->clear_bit_hook' instead of 'tree->ops->set_bit_hook'. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Fix memset length in btrfs_file_writeyanhai zhu2009-01-05
| | | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: update directory's size when creating subvol/snapshotYan Zheng2009-01-05
| | | | | | | | Make sure directory's size properly updated when creating subvol/snapshot. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Btrfs: add permission checks to the ioctlsChris Mason2009-01-05
| | | | | | | | | Only root can add/remove devices Only root can defrag subtrees Only files open for writing can be defragged Only files open for writing can be the destination for a clone Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Fix compile warning around num_online_cpus() in a min statementChris Mason2008-12-19
| | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: set EXTENT_BOUNDARY bit before marking extent delalloc.Yan Zheng2008-12-19
| | | | | | | | | There is a race in relocate_inode_pages, it happens when find_delalloc_range finds the delalloc extent before the boundary bit is set. Thank you, Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Btrfs: properly update block accounting for metadataYan Zheng2008-12-19
| | | | | | | | This adds the missing block accounting code to finish_current_insert and makes block accounting for root item properly protected by the delalloc spin lock. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Btrfs: Add missing mnt_drop_write in ioctl.cYan Zheng2008-12-19
| | | | | | | | This patch adds the missing mnt_drop_write to match mnt_want_write in btrfs_ioctl_defrag and btrfs_ioctl_clone Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Btrfs: fix return value from btrfs_listxattr when buffer size is too smallYehuda Sadeh Weinraub2008-12-17
| | | | | | | The return value was being overwritten. Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
* Btrfs: shift all end_io work to thread poolsChris Mason2008-12-17
| | | | | | | | | | | | | | | | | | bio_end_io for reads without checksumming on and btree writes were happening without using async thread pools. This means the extent_io.c code had to use spin_lock_irq and friends on the rb tree locks for extent state. There were some irq safe vs unsafe lock inversions between the delallock lock and the extent state locks. This patch gets rid of them by moving all end_io code into the thread pools. To avoid contention and deadlocks between the data end_io processing and the metadata end_io processing yet another thread pool is added to finish off metadata writes. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: properly check free space for tree balancingYan Zheng2008-12-17
| | | | | | | | | | | | btrfs_insert_empty_items takes the space needed by the btrfs_item structure into account when calculating the required free space. So the tree balancing code shouldn't add sizeof(struct btrfs_item) to the size when checking the free space. This patch removes these superfluous additions. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Btrfs: delete checksum items before marking blocks freeChris Mason2008-12-16
| | | | | | | | | | | | | | Btrfs maintains a cache of blocks available for allocation in ram. The code that frees extents was marking the extents free and then deleting the checksum items. This meant it was possible the extent would be reallocated before the checksum item was actually deleted, leading to races and other problems as the checksums were updated for the newly allocated extent. The fix is to delete the checksum before marking the extent free. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Don't use spin*lock_irq for the delalloc lockChris Mason2008-12-15
| | | | | | | The delalloc lock doesn't need to have irqs disabled, nobody that changes the number of delalloc bytes in the FS is running with irqs off. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Fix compressed writes on truncated pagesChris Mason2008-12-15
| | | | | | | | | | | The compression code was using isize to limit the amount of data it sent through zlib. But, it wasn't properly limiting the looping to just the pages inside i_size. The end result was trying to compress too many pages, including those that had not been setup and properly locked down. This made the compression code oops while trying find_get_page on a page that didn't exist. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: fix nodatasum handling in balancing codeYan Zheng2008-12-12
| | | | | | | | | | | | | | | | | | | | | | Checksums on data can be disabled by mount option, so it's possible some data extents don't have checksums or have invalid checksums. This causes trouble for data relocation. This patch contains following things to make data relocation work. 1) make nodatasum/nodatacow mount option only affects new files. Checksums and COW on data are only controlled by the inode flags. 2) check the existence of checksum in the nodatacow checker. If checksums exist, force COW the data extent. This ensure that checksum for a given block is either valid or does not exist. 3) update data relocation code to properly handle the case of checksum missing. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Btrfs: shared seed deviceYan Zheng2008-12-12
| | | | | | | | | | This patch makes seed device possible to be shared by multiple mounted file systems. The sharing is achieved by cloning seed device's btrfs_fs_devices structure. Thanks you, Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Btrfs: fix leaking block group on balanceYan Zheng2008-12-11
| | | | | | | | | | | | | The block group structs are referenced in many different places, and it's not safe to free while balancing. So, those block group structs were simply leaked instead. This patch replaces the block group pointer in the inode with the starting byte offset of the block group and adds reference counting to the block group struct. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Btrfs: mnt_drop_write in ioctl_trans_endSage Weil2008-12-11
| | | | | | | | Add missing mnt_drop_write to match the mnt_want_write in btrfs_ioctl_trans_start. Signed-off-by: Sage Weil <sage@newdream.net>
* Btrfs: Add checking of csum tree in balancing codeYan Zheng2008-12-10
| | | | | | | | This updates the space balancing code for the new checksum format. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Btrfs: Delete csum items when freeing extentsChris Mason2008-12-10
| | | | | | | | | | | | | | | | This finishes off the new checksumming code by removing csum items for extents that are no longer in use. The trick is doing it without racing because a single csum item may hold csums for more than one extent. Extra checks are added to btrfs_csum_file_blocks to make sure that we are using the correct csum item after dropping locks. A new btrfs_split_item is added to split a single csum item so it can be split without dropping the leaf lock. This is used to remove csum bytes from the middle of an item. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Fix compressed checksum fsync log copiesChris Mason2008-12-08
| | | | | | | | | | | The fsync logging code makes sure to onl copy the relevant checksum for each extent based on the file extent pointers it finds. But for compressed extents, it needs to copy the checksum for the entire extent. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Add inode sequence number for NFS and reserved space in a few structsChris Mason2008-12-08
| | | | | | | | | | | | | | | | | | | This adds a sequence number to the btrfs inode that is increased on every update. NFS will be able to use that to detect when an inode has changed, without relying on inaccurate time fields. While we're here, this also: Puts reserved space into the super block and inode Adds a log root transid to the super so we can pick the newest super based on the fsync log as well as the main transaction ID. For now the log root transid is always zero, but that'll get fixed. Adds a starting offset to the dev_item. This will let us do better alignment calculations if we know the start of a partition on the disk. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Use map_private_extent_buffer during generic_bin_searchChris Mason2008-12-08
| | | | | | | | | | | | | It is possible that generic_bin_search will be called on a tree block that has not been locked. This happens because cache_block_block skips locking on the tree blocks. Since the tree block isn't locked, we aren't allowed to change the extent_buffer->map_token field. Using map_private_extent_buffer avoids any changes to the internal extent buffer fields. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: superblock duplicationYan Zheng2008-12-08
| | | | | | | | | | | This patch implements superblock duplication. Superblocks are stored at offset 16K, 64M and 256G on every devices. Spaces used by superblocks are preserved by the allocator, which uses a reverse mapping function to find the logical addresses that correspond to superblocks. Thank you, Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Btrfs: move data checksumming into a dedicated treeChris Mason2008-12-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-02
| | | | | | | | | 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-02
| | | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: delete unused function: btrfs_invalidate_dcache_rootChris Mason2008-12-02
| | | | | | | 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-02
| | | | | | | | | 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-02
| | | | | | | | | | | 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-02
| | | | | | | | | | | | | | | | 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-02
| | | | | | | | 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-02
| | | | | | | | 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-02
| | | | | | | | 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-02
| | | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: make things static and include the right headersChristoph Hellwig2008-12-02
| | | | | | | | 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-02
| | | | | | | It is called by btrfs_sync_fs. Signed-off-by: Sage Weil <sage@newdream.net>
* Btrfs: remove unneeded total_transSage Weil2008-12-02
| | | | | | | | | 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-02
| | | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: Fix cow semantic in run_delalloc_nocow()Liu Hui2008-12-01
| | | | | | 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-20
| | | | | | | | 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-20
| | | | | | | | | 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: Drop dirty roots created by log replay immediately whenYan Zheng2008-11-20
| | | | | | | | | | 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-20
| | | | | | | | 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>