summaryrefslogtreecommitdiffstats
path: root/fs
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'error-handling' into for-linusChris Mason2012-03-2837-1018/+1973
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: fs/btrfs/ctree.c fs/btrfs/disk-io.c fs/btrfs/extent-tree.c fs/btrfs/extent_io.c fs/btrfs/extent_io.h fs/btrfs/inode.c fs/btrfs/scrub.c Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * btrfs: disallow unequal data/metadata blocksize for mixed block groupsDavid Sterba2012-03-281-0/+8
| | | | | | | | | | | | | | | | With support for bigger metadata blocks, we must avoid mounting a filesystem with different block size for mixed block groups, this causes corruption (found by xfstests/083). Signed-off-by: David Sterba <dsterba@suse.cz>
| * Btrfs: enhance superblock sanity checksDavid Sterba2012-03-281-5/+18
| | | | | | | | | | | | | | Validate checksum algorithm during mount and prevent BUG_ON later in btrfs_super_csum_size. Signed-off-by: David Sterba <dsterba@suse.cz>
| * btrfs: Fix busyloop in transaction_kthread()Jan Kara2012-03-221-2/+7
| | | | | | | | | | | | | | | | | | When a filesystem got aborted due do error, transaction_kthread() will busyloop. Fix it by going to sleep in that case as well. Maybe we should just stop transaction_kthread() when filesystem is aborted but that would be more complex. Signed-off-by: Jan Kara <jack@suse.cz>
| * btrfs: replace many BUG_ONs with proper error handlingJeff Mahoney2012-03-2223-385/+980
| | | | | | | | | | | | | | | | | | | | | | btrfs currently handles most errors with BUG_ON. This patch is a work-in- progress but aims to handle most errors other than internal logic errors and ENOMEM more gracefully. This iteration prevents most crashes but can run into lockups with the page lock on occasion when the timing "works out." Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: enhance transaction abort infrastructureJeff Mahoney2012-03-228-56/+300
| | | | | | | | Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: add varargs to btrfs_errorJeff Mahoney2012-03-222-9/+66
| | | | | | | | | | | | | | | | | | | | | | btrfs currently handles most errors with BUG_ON. This patch is a work-in- progress but aims to handle most errors other than internal logic errors and ENOMEM more gracefully. This iteration prevents most crashes but can run into lockups with the page lock on occasion when the timing "works out." Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: Remove BUG_ON from __finish_chunk_alloc()Mark Fasheh2012-03-221-1/+3
| | | | | | | | | | | | | | | | btrfs_alloc_chunk() unconditionally BUGs on any error returned from __finish_chunk_alloc() so there's no need for two BUG_ON lines. Remove the one from __finish_chunk_alloc(). Signed-off-by: Mark Fasheh <mfasheh@suse.de>
| * btrfs: Remove BUG_ON from __btrfs_alloc_chunk()Mark Fasheh2012-03-221-1/+2
| | | | | | | | | | | | | | | | We BUG_ON() error from add_extent_mapping(), but that error looks pretty easy to bubble back up - as far as I can tell there have not been any permanent modifications to fs state at that point. Signed-off-by: Mark Fasheh <mfasheh@suse.de>
| * btrfs: Don't BUG_ON insert errors in btrfs_alloc_dev_extent()Mark Fasheh2012-03-221-1/+3
| | | | | | | | | | | | | | | | | | The only caller of btrfs_alloc_dev_extent() is __btrfs_alloc_chunk() which already bugs on any error returned. We can remove the BUG_ON's in btrfs_alloc_dev_extent() then since __btrfs_alloc_chunk() will "catch" them anyway. Signed-off-by: Mark Fasheh <mfasheh@suse.de>
| * btrfs: Go readonly on tree errors in balance_levelMark Fasheh2012-03-221-2/+11
| | | | | | | | | | | | | | | | balace_level() seems to deal with missing tree nodes by BUG_ON(). Instead, we can easily just set the file system readonly and bubble -EROFS back up the stack. Signed-off-by: Mark Fasheh <mfasheh@suse.com>
| * btrfs: Don't BUG_ON errors from update_ref_for_cow()Mark Fasheh2012-03-221-1/+4
| | | | | | | | | | | | | | | | | | __btrfs_cow_block(), the only caller of update_ref_for_cow() will BUG_ON() any error return. Instead, we can go read-only fs as update_ref_for_cow() manipulates disk data in a way which doesn't look like it's easily rolled back. Signed-off-by: Mark Fasheh <mfasheh@suse.de>
| * btrfs: Go readonly on bad extent refs in update_ref_for_cow()Mark Fasheh2012-03-221-1/+5
| | | | | | | | | | | | | | | | | | update_ref_for_cow() will BUG_ON() after it's call to btrfs_lookup_extent_info() if no existing references are found. Since refs are computed directly from disk, this should be treated as a corruption instead of a logic error. Signed-off-by: Mark Fasheh <mfasheh@suse.de>
| * btrfs: Don't BUG_ON errors in __finish_chunk_alloc()Mark Fasheh2012-03-221-4/+6
| | | | | | | | | | | | | | | | All callers of __finish_chunk_alloc() BUG_ON() return value, so it's trivial for us to always bubble up any errors caught in __finish_chunk_alloc() to be caught there. Signed-off-by: Mark Fasheh <mfasheh@suse.de>
| * btrfs: Don't BUG_ON kzalloc error in btrfs_lookup_csums_range()Mark Fasheh2012-03-221-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unfortunately it isn't enough to just exit here - the kzalloc() happens in a loop and the allocated items are added to a linked list whose head is passed in from the caller. To fix the BUG_ON() and also provide the semantic that the list passed in is only modified on success, I create function-local temporary list that we add items too. If no error is met, that list is spliced to the callers at the end of the function. Otherwise the list will be walked and all items freed before the error value is returned. I did a simple test on this patch by forcing an error at the kzalloc() point and verifying that when this hits (git clone seemed to exercise this), the function throws the proper error. Unfortunately but predictably, we later hit a BUG_ON(ret) type line that still hasn't been fixed up ;) Signed-off-by: Mark Fasheh <mfasheh@suse.com>
| * btrfs: Don't BUG_ON() errors in update_ref_for_cow()Mark Fasheh2012-03-221-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The only caller of update_ref_for_cow() is __btrfs_cow_block() which was originally ignoring any return values. update_ref_for_cow() however doesn't look like a candidate to become a void function - there are a few places where errors can occur. So instead I changed update_ref_for_cow() to bubble all errors up (instead of BUG_ON). __btrfs_cow_block() was then updated to catch and BUG_ON() any errors from update_ref_for_cow(). The end effect is that we have no change in behavior, but about 8 different places where a BUG_ON(ret) was removed. Obviously a future patch will have to address the BUG_ON() in __btrfs_cow_block(). Signed-off-by: Mark Fasheh <mfasheh@suse.de>
| * btrfs: Don't BUG_ON errors from btrfs_create_subvol_root()Mark Fasheh2012-03-222-2/+6
| | | | | | | | | | | | | | | | | | | | | | This is called from only one place - create_subvol() which passes errors safely back out to it's caller, btrfs_mksubvol where they are handled. Additionally, btrfs_create_subvol_root() itself bug's needlessly from error return of btrfs_update_inode(). Since create_subvol() was fixed to catch errors we can bubble this one up too. Signed-off-by: Mark Fasheh <mfasheh@suse.com>
| * btrfs: btrfs_drop_snapshot should return intJeff Mahoney2012-03-224-8/+12
| | | | | | | | | | | | | | | | | | | | 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 as if nothing went wrong. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: split extent_state opsJeff Mahoney2012-03-223-15/+25
| | | | | | | | | | | | | | | | set_extent_bit can do exclusive locking but only when called by lock_extent*, Drop the exclusive bits argument except when called by lock_extent. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: drop gfp_t from lock_extentJeff Mahoney2012-03-229-76/+63
| | | | | | | | | | | | | | lock_extent and unlock_extent are always called with GFP_NOFS, drop the argument and use GFP_NOFS consistently. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: return void in functions without error conditionsJeff Mahoney2012-03-2228-410/+249
| | | | | | | | Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: __add_reloc_root error push-upJeff Mahoney2012-03-221-6/+16
| | | | | | | | | | | | | | | | | | This patch pushes kmalloc errors up to the caller and BUGs in the caller. The BUG_ON for duplicate reloc tree root insertion is replaced with a panic explaining the issue. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: ->submit_bio_hook error push-upJeff Mahoney2012-03-223-15/+31
| | | | | | | | | | | | | | | | | | | | | | 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 the error is already caught with BUG_ON. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: Factor out tree->ops->merge_bio_hook callJeff Mahoney2012-03-222-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 it. It's considered a routine "1" return value instead of a failure. This patch factors out the dependency check into a new local merge_bio routine and BUG's on an error. The if statement is less noisy as a side- effect. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: Simplify btrfs_submit_bio_hookJeff Mahoney2012-03-221-3/+4
| | | | | | | | | | | | | | | | | | | | | | 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 in a more visually obvious way. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: btrfs_update_root error push-upJeff Mahoney2012-03-222-4/+7
| | | | | | | | | | | | | | btrfs_update_root BUG's when it can't alloc a path, yet it can recover from a search error. This patch returns -ENOMEM instead. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: find_and_setup_root error push-upJeff Mahoney2012-03-221-5/+6
| | | | | | | | | | | | | | | | | | find_and_setup_root BUGs when it encounters an error from btrfs_find_last_root, which can occur if a path can't be allocated. This patch pushes it up to its callers where it is already handled. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: Remove set bits return from clear_extent_bitJeff Mahoney2012-03-221-7/+5
| | | | | | | | | | | | | | | | | | There is only one caller of clear_extent_bit that checks the return value and it only checks if it's negative. Since there are no users of the returned bits functionality of clear_extent_bit, stop returning it and avoid complicating error handling. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: avoid NULL deref in btrfs_reserve_extent with DEBUG_ENOSPCJeff Mahoney2012-03-221-1/+2
| | | | | | | | | | | | | | __find_space_info can return NULL but we don't check it before calling dump_space_info(). Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: clean_tree_block should panic on observed memory corruption and ↵Jeff Mahoney2012-03-222-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | return void The only error condition in clean_tree_block is an accounting bug. Returning without modifying dirty_metadata_bytes and as if the cleaning as been performed may cause problems later so it should panic instead. It should probably be a BUG_ON but we have btrfs_panic now. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: Simplify btrfs_insert_rootJeff Mahoney2012-03-221-6/+3
| | | | | | | | | | | | | | btrfs_insert_root is just a wrapper for btrfs_insert_item. Just return the error directly. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: Fix kfree of member instead of structureJeff Mahoney2012-03-221-3/+3
| | | | | | | | | | | | | | | | | | | | Correctness fix: The kfree calls in the add_delayed_* functions free the node that's passed into it, but the node is a member of another structure. It works because it's always the first member of the containing structure, but it should really be using the containing structure itself. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: Panic on bad rbtree operationsJeff Mahoney2012-03-222-9/+39
| | | | | | | | | | | | | | | | | | The ordered data and relocation trees have BUG_ONs to protect against bad tree operations. This patch replaces them with a panic that will report the problem. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: Catch locking failures in {set,clear,convert}_extent_bitJeff Mahoney2012-03-221-20/+38
| | | | | | | | | | | | | | | | The *_state functions can only return 0 or -EEXIST. This patch addresses the cases where those functions returning -EEXIST represent a locking failure. It handles them by panicking with an appropriate error message. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: Add btrfs_panic()Jeff Mahoney2012-03-222-1/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 patch adds a btrfs_panic() routine that will either panic or BUG depending on the new -ofatal_errors={panic,bug} mount option. Since there are still so many BUG_ONs, it defaults to BUG for now but I expect that to change once the error handling effort has made significant progress. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
* | Btrfs: change scrub to support big blocksStefan Behrens2012-03-271-340/+1013
| | | | | | | | | | | | | | | | | | Scrub used to be coded for nodesize == leafsize == sectorsize == PAGE_SIZE. This is now changed to support sizes for nodesize and leafsize which are N * PAGE_SIZE. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
* | Btrfs: minor cleanup in scrubStefan Behrens2012-03-271-36/+25
| | | | | | | | | | | | | | Just a minor cleanup commit in preparation for the big block changes. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
* | Btrfs: introduce common define for max number of mirrorsStefan Behrens2012-03-272-5/+7
| | | | | | | | | | | | | | | | | | | | Readahead already has a define for the max number of mirrors. Scrub needs such a define now, the rest of the code will need something like this soon. Therefore the define was added to ctree.h and removed from the readahead code. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
* | Btrfs: deal with read errors on extent buffers differentlyJosef Bacik2012-03-263-27/+66
| | | | | | | | | | | | | | | | | | | | | | | | Since we need to read and write extent buffers in their entirety we can't use the normal bio_readpage_error stuff since it only works on a per page basis. So instead make it so that if we see an io error in endio we just mark the eb as having an IO error and then in btree_read_extent_buffer_pages we will manually try other mirrors and then overwrite the bad mirror if we find a good copy. This works with larger than page size blocks. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
* | Btrfs: don't use threaded IO completion helpers for metadata writesChris Mason2012-03-261-4/+4
| | | | | | | | | | | | | | The metadata write IO completion code is now simple enough that we don't need the threaded helpers anymore. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* | Btrfs: adjust the write_lock_level as we unlockChris Mason2012-03-261-6/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | btrfs_search_slot sometimes needs write locks on high levels of the tree. It remembers the highest level that needs a write lock and will use that for all future searches through the tree in a given call. But, very often we'll just cow the top level or the level below and we won't really need write locks on the root again after that. This patch changes things to adjust the write lock requirement as it unlocks levels. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* | Btrfs: loop waiting on writebackChris Mason2012-03-261-5/+5
| | | | | | | | | | | | | | lock_extent_buffer_for_io needs to loop around and make sure the writeback bits are not set. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* | Btrfs: add the ability to cache a pointer into the ebChris Mason2012-03-263-30/+116
| | | | | | | | | | | | This cuts down on the CPU time used by map_private_extent_buffer Signed-off-by: Chris Mason <chris.mason@oracle.com>
* | Btrfs: ensure an entire eb is written at onceJosef Bacik2012-03-264-209/+390
| | | | | | | | | | | | | | | | | | | | | | | | This patch simplifies how we track our extent buffers. Previously we could exit writepages with only having written half of an extent buffer, which meant we had to track the state of the pages and the state of the extent buffers differently. Now we only read in entire extent buffers and write out entire extent buffers, this allows us to simply set bits in our bflags to indicate the state of the eb and we no longer have to do things like track uptodate with our iotree. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
* | Btrfs: introduce mark_extent_buffer_accessedJosef Bacik2012-03-261-2/+15
| | | | | | | | | | | | | | | | | | Because an eb can have multiple pages we need to make sure that all pages within the eb are markes as accessed, since releasepage can be called against any page in the eb. This will keep us from possibly evicting hot eb's when we're doing larger than pagesize eb's. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
* | Btrfs: introduce free_extent_buffer_staleJosef Bacik2012-03-265-60/+201
| | | | | | | | | | | | | | | | | | | | | | | | Because btrfs cow's we can end up with extent buffers that are no longer necessary just sitting around in memory. So instead of evicting these pages, we could end up evicting things we actually care about. Thus we have free_extent_buffer_stale for use when we are freeing tree blocks. This will make it so that the ref for the eb being in the radix tree is dropped as soon as possible and then is freed when the refcount hits 0 instead of waiting to be released by releasepage. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
* | Btrfs: only use the existing eb if it's count isn't 0Josef Bacik2012-03-261-2/+8
| | | | | | | | | | | | | | | | | | | | | | We can run into a problem where we find an eb for our existing page already on the radix tree but it has a ref count of 0. It hasn't yet been removed by RCU yet so this can cause issues where we will use the EB after free. So do atomic_inc_not_zero on the exists->refs and if it is zero just do synchronize_rcu() and try again. We won't have to worry about new allocators coming in since they will block on the page lock at this point. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
* | Btrfs: set page->private to the ebJosef Bacik2012-03-263-93/+91
| | | | | | | | | | | | | | | | | | We spend a lot of time looking up extent buffers from pages when we could just store the pointer to the eb the page is associated with in page->private. This patch does just that, and it makes things a little simpler and reduces a bit of CPU overhead involved with doing metadata IO. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
* | Btrfs: allow metadata blocks larger than the page sizeChris Mason2012-03-266-189/+190
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A few years ago the btrfs code to support blocks lager than the page size was disabled to fix a few corner cases in the page cache handling. This fixes the code to properly support large metadata blocks again. Since current kernels will crash early and often with larger metadata blocks, this adds an incompat bit so that older kernels can't mount it. This also does away with different blocksizes for nodes and leaves. You get a single block size for all tree blocks. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* | Btrfs: remove search_start and search_end from find_free_extent and callersJosef Bacik2012-03-263-19/+9
| | | | | | | | | | | | | | | | | | We have been passing nothing but (u64)-1 to find_free_extent for search_end in all of the callers, so it's completely useless, and we've always been passing 0 in as search_start, so just remove them as function arguments and move search_start into find_free_extent. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
OpenPOWER on IntegriCloud