summaryrefslogtreecommitdiff
path: root/fs/btrfs
Commit message (Collapse)AuthorAge
...
| * btrfs: use GFP_KERNEL in btrfs_quota_enableDavid Sterba2017-02-17
| | | | | | | | | | | | | | | | We don't need to use GFP_NOFS here as this is called from ioctls an the only lock held is the subvol_sem, which is of a high level and protects creation/renames/deletion and is never held in the writeout paths. Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: use GFP_KERNEL in btrfs_read_qgroup_configDavid Sterba2017-02-17
| | | | | | | | | | | | The qgroup config is read during mount, we do not have to use NOFS. Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: use GFP_KERNEL in create_snapshotDavid Sterba2017-02-17
| | | | | | | | | | | | | | | | We don't need to use GFP_NOFS here as this is called from ioctls an the only lock held is the subvol_sem, which is of a high level and protects creation/renames/deletion and is never held in the writeout paths. Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: specify a new ordered extent type for create_io_emLiu Bo2017-02-17
| | | | | | | | | | | | | | | | | | As 0 refers to an existing type BTRFS_ORDERED_IO_DONE, this specifies a new type 'REGULAR' for regular IO. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: create a helper to create em for IOLiu Bo2017-02-17
| | | | | | | | | | | | | | | | | | We have similar codes to create and insert extent mapping around IO path, this merges them into a single helper. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: use helper to get used bytes of space_infoLiu Bo2017-02-17
| | | | | | | | | | | | | | | | | | This uses a helper instead of open code around used byte of space_info everywhere. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: try to avoid acquiring free space ctl's lockLiu Bo2017-02-17
| | | | | | | | | | | | | | | | We don't need to take the lock if the block group has not been cached. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Better csum error message for data csum mismatchQu Wenruo2017-02-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original csum error message only outputs inode number, offset, check sum and expected check sum. However no root objectid is outputted, which sometimes makes debugging quite painful under multi-subvolume case (including relocation). Also the checksum output is decimal, which seldom makes sense for users/developers and is hard to read in most time. This patch will add root objectid, which will be %lld for rootid larger than LAST_FREE_OBJECTID, and hex csum output for better readability. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: add another missing end_page_writeback on submit_extent_page failureTakafumi Kubota2017-02-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If btrfs_bio_alloc fails in submit_extent_page, submit_extent_page returns without clearing the writeback bit of the failed page. __extent_writepage_io, that is a caller of submit_extent_page, does not clear the remaining writeback bit anywhere. As a result, this will cause the hang at filemap_fdatawait_range, because it waits the writeback bit to be cleared from the failed page. So, we have to call end_page_writeback to clear the writeback bit. For reproducing the hang, we inject a fault like if (should_failtest()) { // I define should_failtest() bio = NULL; } else { bio = btrfs_bio_alloc(...); } in submit_extent_page. We should also check whether page has the bit before end_page_writeback, to avoid the conflict against the other end_page_writeback in bio_endio. Thus, we add PageWriteback checks not only in __extent_writepage_io, but also in write_one_eb too, because it misses the check. Signed-off-by: Takafumi Kubota <takafumi.kubota1012@sslab.ics.keio.ac.jp> Reviewed-by: Liu Bo <bo.li.liu@oracle.com> Cc: David Sterba <dsterba@suse.cz> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: remove unused ulist membersDavid Sterba2017-02-17
| | | | | | | | | | | | | | | | | | Commit "btrfs: ulist: Add ulist_del() function" (d4b804045924d7f8) removed some debugging code but left the structure defintions. Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: use helper to simplify lock/unlock pagesLiu Bo2017-02-17
| | | | | | | | | | | | | | | | | | Since we have a helper to set page bits, let lock_delalloc_pages and __unlock_for_delalloc use it. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: teach __process_pages_contig about PAGE_LOCK operationLiu Bo2017-02-17
| | | | | | | | | | | | | | Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> [ changes to the helper separated from the following patch ] Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: create helper for processing bits on contiguous pagesLiu Bo2017-02-14
| | | | | | | | | | | | | | | | This introduces a new helper which can be used to process pages bits. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: kill trans in run_delalloc_nocow and btrfs_cross_ref_existLiu Bo2017-02-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | run_delalloc_nocow has used trans in two places where they don't actually need @trans. For btrfs_lookup_file_extent, we search for file extents without COWing anything, and for btrfs_cross_ref_exist, the only place where we need @trans is deferencing it in order to get running_transaction which we could easily get from the global fs_info. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: pass delayed_refs directly to btrfs_find_delayed_ref_headLiu Bo2017-02-14
| | | | | | | | | | | | | | | | | | | | All we need is @delayed_refs, all callers have get it ahead of calling btrfs_find_delayed_ref_head since lock needs to be acquired firstly, there is no reason to deference it again inside the function. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: remove unused trans in read_block_for_searchLiu Bo2017-02-14
| | | | | | | | | | | | | | | | @trans is not used at all, this removes it. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: cleanup unused cached_state in __extent_writepage_ioLiu Bo2017-02-14
| | | | | | | | | | | | | | | | @cached_state is no more required in __extent_writepage_io, also remove the goto label. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: allow unlink to exceed subvolume quotaJeff Mahoney2017-02-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Once a qgroup limit is exceeded, it's impossible to restore normal operation to the subvolume without modifying the limit or removing the subvolume. This is a surprising situation for many users used to the typical workflow with quotas on other file systems where it's possible to remove files until the used space is back under the limit. When we go to unlink a file and start the transaction, we'll hit the qgroup limit while trying to reserve space for the items we'll modify while removing the file. We discussed last month how best to handle this situation and agreed that there is no perfect solution. The best principle-of-least-surprise solution is to handle it similarly to how we already handle ENOSPC when unlinking, which is to allow the operation to succeed with the expectation that it will ultimately release space under most circumstances. This patch modifies the transaction start path to select whether to honor the qgroups limits. btrfs_start_transaction_fallback_global_rsv is the only caller that skips enforcement. The reservation and tracking still happens normally -- it just skips the enforcement step. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: fix wrong argument for btrfs_lookup_ordered_rangeLiu Bo2017-02-14
| | | | | | | | | | | | | | | | | | | | Commit Btrfs: btrfs_page_mkwrite: Reserve space in sectorsized units" (d0b7da88) did this, but btrfs_lookup_ordered_range expects a 'length' rather than a 'page_end'. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: Chandan Rajendra <chandan@linux.vnet.ibm.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: raid56: Remove unused variable in lock_stripe_addQu Wenruo2017-02-14
| | | | | | | | | | | | | | Variable 'walk' in lock_stripe_add() is not used. Remove it. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: refactor btrfs_extent_same() slightlyOmar Sandoval2017-02-14
| | | | | | | | | | | | | | | | | | | | | | This was originally a prep patch for changing the behavior on len=0, but we went another direction with that. This still makes the function slightly easier to follow. Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: Omar Sandoval <osandov@fb.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: constify struct btrfs_{,disk_}key wherever possibleOmar Sandoval2017-02-14
| | | | | | | | | | | | | | | | | | | | In a lot of places, it's unclear when it's safe to reuse a struct btrfs_key after it has been passed to a helper function. Constify these arguments wherever possible to make it obvious. Signed-off-by: Omar Sandoval <osandov@fb.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: fix another race between truncate and lockless dio writeLiu Bo2017-02-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Dio writes can update i_size in btrfs_get_blocks_direct when it writes to offset beyond EOF so that endio can update disk_i_size correctly (because we don't udpate disk_i_size beyond i_size). However, when truncating down a file, we firstly update i_size and then wait for in-flight lockless dio reads/writes, according to the above, i_size may have been changed in dio writes, and file extents don't get truncated. For lockless dio writes are always overwrites, i_size is not supposed to be changed, so this adds a check to filter out this case. The race could be reproduced by fstests/generic/299 with patch "Btrfs: fix btrfs_ordered_update_i_size to update disk_i_size properly" applied. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: clean up btrfs_ordered_update_i_sizeLiu Bo2017-02-14
| | | | | | | | | | | | | | | | | | Since we have a good helper entry_end, use it for ordered extent. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> [ whitespace reformatting ] Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: fix comment in btrfs_page_mkwriteLiu Bo2017-02-14
| | | | | | | | | | | | | | | | | | | | | | | | | | The comment about "page_mkwrite gets called every time the page is dirtied" in btrfs_page_mkwrite is not correct, it only gets called the first time the page gets dirtied after the page faults in. However, we don't need to touch the code because it works well, although the proper logic is to check if delalloc bits has been set and if so, go free reserved space, if not, set the delalloc bits for dirty page range. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: fix btrfs_ordered_update_i_size to update disk_i_size properlyLiu Bo2017-02-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | btrfs_ordered_update_i_size can be called by truncate and endio, but only endio takes ordered_extent which contains the completed IO. while truncating down a file, if there are some in-flight IOs, btrfs_ordered_update_i_size in endio will set disk_i_size to @orig_offset that is zero. If truncating-down fails somehow, we try to recover in memory isize with this zero'd disk_i_size. Fix it by only updating disk_i_size with @orig_offset when btrfs_ordered_update_i_size is not called from endio while truncating down and waiting for in-flight IOs completing their work before recover in-memory size. Besides fixing the above issue, add an assertion for last_size to double check we truncate down to the desired size. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: fix over-80 lines introduced by previous cleanupsDavid Sterba2017-02-14
| | | | | | | | | | | | | | This goes as a separate patch because fixing that inside the patches caused too many many conflicts. Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make count_inode_refs take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make count_inode_extrefs take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make btrfs_log_inode take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make log_inode_item take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make __add_inode_ref take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make drop_one_dir_item take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make btrfs_unlink_inode take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make log_new_dir_dentries take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make log_directory_changes take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make log_dir_items take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make btrfs_log_changed_extents take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make btrfs_get_logged_extents take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make btrfs_log_trailing_hole take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make btrfs_log_all_xattrs take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make copy_items take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make btrfs_check_ref_name_override take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make logged_inode_size take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make btrfs_del_inode_ref take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make btrfs_del_dir_entries_in_log take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make btrfs_log_new_name take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make btrfs_inode_in_log take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make btrfs_record_snapshot_destroy take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Make btrfs_record_unlink_dir take btrfs_inodeNikolay Borisov2017-02-14
| | | | | | | | | | Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>