[PATCH 4/7] btrfs: iterate over unused chunk space in FITRIM

2015-06-15 Thread jeffm
From: Jeff Mahoney je...@suse.com Since we now clean up block groups automatically as they become empty, iterating over block groups is no longer sufficient to discard unused space. This patch iterates over the unused chunk space and discards any regions that are unallocated, regardless of

[PATCH 4/4] btrfs: add missing discards when unpinning extents with -o discard

2015-06-11 Thread jeffm
From: Jeff Mahoney je...@suse.com When we clear the dirty bits in btrfs_delete_unused_bgs for extents in the empty block group, it results in btrfs_finish_extent_commit being unable to discard the freed extents. The block group removal patch added an alternate path to forget extents other than

[PATCH 1/4] btrfs: skip superblocks during discard

2015-06-11 Thread jeffm
From: Jeff Mahoney je...@suse.com Btrfs doesn't track superblocks with extent records so there is nothing persistent on-disk to indicate that those blocks are in use. We track the superblocks in memory to ensure they don't get used by removing them from the free space cache when we load a block

[PATCH 2/4] btrfs: iterate over unused chunk space in FITRIM

2015-06-11 Thread jeffm
From: Jeff Mahoney je...@suse.com Since we now clean up block groups automatically as they become empty, iterating over block groups is no longer sufficient to discard unused space. This patch iterates over the unused chunk space and discards any regions that are unallocated, regardless of

[PATCH v4] btrfs: fix automatic blockgroup remove + discard

2015-06-11 Thread jeffm
The automatic block group removal patch introduced some regressions in how discards are handled. 1/ FITRIM only iterates over block groups on disk - removed block groups won't be trimmed. 2/ Clearing the dirty bit from extents in removed block groups means that those extents won't be

[PATCH] btrfs: cleanup, stop casting for extent_map-lookup everywhere

2015-06-03 Thread jeffm
From: Jeff Mahoney je...@suse.com Overloading extent_map-bdev to struct map_lookup * might have started out as a means to an end, but it's a pattern that's used all over the place now. Let's get rid of the casting and just add a union instead. Signed-off-by: Jeff Mahoney je...@suse.com ---

[PATCH 3/3] btrfs: add missing discards when unpinning extents with -o discard

2015-06-03 Thread jeffm
From: Jeff Mahoney je...@suse.com When we clear the dirty bits in btrfs_delete_unused_bgs for extents in the empty block group, it results in btrfs_finish_extent_commit being unable to discard the freed extents. The block group removal patch added an alternate path to forget extents other than

[PATCH v3] btrfs: fix automatic blockgroup remove + discard

2015-06-03 Thread jeffm
The automatic block group removal patch introduced some regressions in how discards are handled. 1/ FITRIM only iterates over block groups on disk - removed block groups won't be trimmed. 2/ Clearing the dirty bit from extents in removed block groups means that those extents won't be

[PATCH 2/3] btrfs: explictly delete unused block groups in close_ctree and ro-remount

2015-06-03 Thread jeffm
From: Jeff Mahoney je...@suse.com The cleaner thread may already be sleeping by the time we enter close_ctree. If that's the case, we'll skip removing any unused block groups queued for removal, even during a normal umount. They'll be cleaned up automatically at next mount, but users expect a

[patch v3 17/23] btrfs: Make btrfs_invalidate_inodes return void

2011-09-08 Thread jeffm
btrfs_invalidate_inodes has no error conditions and should return void. Signed-off-by: Jeff Mahoney je...@suse.com --- fs/btrfs/ctree.h |2 +- fs/btrfs/inode.c |3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2590,7 +2590,7 @@

[patch v3 21/23] btrfs: simplify btrfs_submit_bio_hook

2011-09-08 Thread jeffm
btrfs_submit_bio_hook currently calls btrfs_bio_wq_end_io in either case of an if statement that determines one of the arguments. This patch moves the function call outside of the if statement and uses it to only determine the different argument. This allows us to catch an error in one place

[patch v3 10/23] btrfs: Push up non-looped btrfs_start_transaction failures

2011-09-08 Thread jeffm
This patch handles btrfs_start_transaction failures that don't occur in a loop and are obvious to simply push up. In all cases except the mark_garbage_root case, the error is already handled by BUG_ON in the caller. Update v2: This version also checks the returns from btrfs_drop_snapshot.

[patch v3 23/23] btrfs: Push up -submit_bio_hook failures

2011-09-08 Thread jeffm
This pushes failures from the submit_bio_hook callbacks, btrfs_submit_bio_hook and btree_submit_bio_hook into the callers, including callers of submit_one_bio where it catches the failures with BUG_ON. It also pushes up through the -readpage_io_failed_hook to end_bio_extent_writepage where

[patch v3 16/23] btrfs: Make btrfs_init_compress return void

2011-09-08 Thread jeffm
btrfs_init_compress doesn't have any failure conditions, so return void. Signed-off-by: Jeff Mahoney je...@suse.com --- fs/btrfs/compression.h |2 +- fs/btrfs/super.c |5 + 2 files changed, 2 insertions(+), 5 deletions(-) --- a/fs/btrfs/compression.c +++

[patch v3 04/23] btrfs: Push up lock_extent errors to callers

2011-09-08 Thread jeffm
lock_extent, try_lock_extent, and lock_extent_bits can't currently fail because errors are caught via BUG_ON. This patch pushes the error handling up to callers, which currently only handle them via BUG_ON themselves. Signed-off-by: Jeff Mahoney je...@suse.com --- fs/btrfs/compression.c

[patch v3 06/23] btrfs: Push up unlock_extent errors to callers

2011-09-08 Thread jeffm
The previous patch pushed the clear_extent_bit error handling up a level, which included unlock_extent and unlock_extent_cache. This patch pushes the BUG_ON up into the callers of those functions. Signed-off-by: Jeff Mahoney je...@suse.com --- fs/btrfs/compression.c |9 ++--

[patch v3 19/23] btrfs: extent-tree.c: Make functions with no error conditions return void

2011-09-08 Thread jeffm
btrfs_prepare_extent_commit, btrfs_set_block_group_rw, and setup_inline_extent_backref have no error conditions and should return void. Signed-off-by: Jeff Mahoney je...@suse.com --- fs/btrfs/ctree.h |8 fs/btrfs/extent-tree.c | 20 +--- 2 files changed, 13

[patch v3 12/23] btrfs: extent_io.c: Make functions with no error conditions return void

2011-09-08 Thread jeffm
wait_on_state, wait_extent_bit, __unlock_for_delalloc, check_page_uptodate, check_page_locked, check_page_writeback, and clear_extent_buffer_dirty have no error conditions and should return void. Signed-off-by: Jeff Mahoney je...@suse.com --- fs/btrfs/extent_io.c | 29

[patch v3 03/23] btrfs: Push up set_extent_bit errors to callers

2011-09-08 Thread jeffm
In the locking case, set_extent_bit can return -EEXIST but callers already handle that. In the non-locking case, it can't fail. Memory allocation failures are handled by BUG_ON. This patch pushes up the BUG_ONs from set_extent_bit to callers, except where -ENOMEM can't occur (e.g.

[patch v3 05/23] btrfs: Push up clear_extent_bit errors to callers

2011-09-08 Thread jeffm
clear_extent_bit can fail with -ENOMEM for a specific case but will BUG on other memory allocation failures. This patch returns -ENOMEM for memory allocation failures and handles them with BUG_ON in callers which don't handle it already. Signed-off-by: Jeff Mahoney je...@suse.com ---

[patch v3 09/23] btrfs: btrfs_drop_snapshot should return int

2011-09-08 Thread jeffm
Commit cb1b69f4 (Btrfs: forced readonly when btrfs_drop_snapshot() fails) made btrfs_drop_snapshot return void because there were no callers checking the return value. That is the wrong order to handle error propogation since the caller will have no idea that an error has occured and continue on

[patch v3 18/23] btrfs: disk-io.c: Make functions with no error conditions return void

2011-09-08 Thread jeffm
btrfs_destroy_delalloc_inodes and __setup_root have no error conditions and should return void. Signed-off-by: Jeff Mahoney je...@suse.com --- fs/btrfs/disk-io.c | 14 +- 1 file changed, 5 insertions(+), 9 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -54,7

[patch v3 20/23] btrfs: file.c: Make functions with no error conditions return void

2011-09-08 Thread jeffm
btrfs_run_defrag_inodes contains no error conditions and should return void. Signed-off-by: Jeff Mahoney je...@suse.com --- fs/btrfs/ctree.h |2 +- fs/btrfs/file.c |3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2612,7

[patch v3 11/23] btrfs: Make set_range_writeback return void

2011-09-08 Thread jeffm
set_range_writeback has no error conditions that aren't fatal logic errors. This patch makes it return void to eliminate an error site. Signed-off-by: Jeff Mahoney je...@suse.com --- fs/btrfs/extent_io.c |8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) ---

[patch v3 08/23] btrfs: Push up btrfs_pin_extent failures

2011-09-08 Thread jeffm
btrfs_pin_extent looks up a block group and then calls pin_down_extent with it. If the lookup fails, it should return -ENOENT to allow callers to handle the error condition. For the three existing callers, it is a logic error if the lookup fails and a panic will occur. Signed-off-by: Jeff

[patch v3 07/23] btrfs: Make pin_down_extent return void

2011-09-08 Thread jeffm
pin_down_extent performs some operations which can't fail and then calls set_extent_dirty, which has two failure cases via set_extent_bit: 1) Return -EEXIST if exclusive bits are set - Since it doesn't use any exclusive bits, this failure case can't occur. 2) Return -ENOMEM if

[patch v3 13/23] btrfs: volumes.c: Make functions with no error conditions return void

2011-09-08 Thread jeffm
btrfs_cleanup_fs_uuids, run_scheduled_bios, btrfs_close_extra_devices, schedule_bio, and fill_device_from_item have no error conditions and should return void. Signed-off-by: Jeff Mahoney je...@suse.com --- fs/btrfs/volumes.c | 25 + fs/btrfs/volumes.h |4 ++-- 2

[patch v3 00/23] More error handling fixes

2011-09-08 Thread jeffm
Hi all - The following 23 patches add more error handling to the btrfs code: - Add btrfs_panic - Catch locking failures in {set,clear}_extent_bit - Push up set_extent_bit errors to callers - Push up lock_extent errors to callers - Push up clear_extent_bit errors to callers - Push up

[patch v3 14/23] btrfs: async-thread.c: Make functions with no error conditions return void

2011-09-08 Thread jeffm
run_ordered_completions, btrfs_stop_workers, btrfs_requeue_work, and btrfs_queue_worker don't have any error conditions and should return void. Signed-off-by: Jeff Mahoney je...@suse.com --- fs/btrfs/async-thread.c | 31 ++- fs/btrfs/async-thread.h |7 ---

[patch v3 15/23] btrfs: tree-log.c: Make functions with no error conditions return void

2011-09-08 Thread jeffm
btrfs_end_log_trans and wait_for_writer have no error conditions and should return void. Signed-off-by: Jeff Mahoney je...@suse.com --- fs/btrfs/tree-log.c |6 ++ fs/btrfs/tree-log.h |2 +- 2 files changed, 3 insertions(+), 5 deletions(-) --- a/fs/btrfs/tree-log.c +++

[patch v3 02/23] btrfs: Catch locking failures in {set,clear}_extent_bit

2011-09-08 Thread jeffm
The *_state functions can only return 0 or -EEXIST. This patch addresses the cases where those functions return -EEXIST, representing a locking failure. It handles them by panicking with an appropriate error message. Signed-off-by: Jeff Mahoney je...@suse.com --- fs/btrfs/extent_io.c | 42

[patch v3 22/23] btrfs: Factor out tree-ops-merge_bio_hook call

2011-09-08 Thread jeffm
In submit_extent_page, there's a visually noisy if statement that, in the midst of other conditions, does the tree dependency for tree-ops and tree-ops-merge_bio_hook before calling it, and then another condition afterwards. If an error is returned from merge_bio_hook, there's no way to catch

[patch v3 01/23] btrfs: Add btrfs_panic()

2011-09-08 Thread jeffm
As part of the effort to eliminate BUG_ON as an error handling technique, we need to determine which errors are actual logic errors, which are on-disk corruption, and which are normal runtime errors e.g. -ENOMEM. Annotating these error cases is helpful to understand and report them. This

<    1   2   3