Re: [RFC PATCH 2/2] Btrfs: fix deadlock on umount by umount_prepare interface

2012-03-21 Thread Dave Chinner
On Thu, Mar 22, 2012 at 01:25:26PM +0800, Miao Xie wrote: > On Thu, 22 Mar 2012 15:39:36 +1100, Dave Chinner wrote: > > On Thu, Mar 22, 2012 at 11:13:17AM +0800, Miao Xie wrote: > >> The reason the deadlock is that: > >> Task Btrfs-cleaner > >> umount() > >>

Re: [RFC PATCH 1/2] vfs: add an interface to do some preparation for umount

2012-03-21 Thread Miao Xie
On Thu, 22 Mar 2012 03:41:09 +, Al Viro wrote: > On Thu, Mar 22, 2012 at 11:13:15AM +0800, Miao Xie wrote: >> Some file systems can do some works in the background by kthreads, we'd >> better stop those works before we umount the file system, or it is easy to >> introduce some problems. So we a

Re: [RFC PATCH 2/2] Btrfs: fix deadlock on umount by umount_prepare interface

2012-03-21 Thread Miao Xie
On Thu, 22 Mar 2012 15:39:36 +1100, Dave Chinner wrote: > On Thu, Mar 22, 2012 at 11:13:17AM +0800, Miao Xie wrote: >> The reason the deadlock is that: >> Task Btrfs-cleaner >> umount() >> down_write(&s->s_umount) >> close_ctree() >> wait for

Re: [RFC PATCH 2/2] Btrfs: fix deadlock on umount by umount_prepare interface

2012-03-21 Thread Dave Chinner
On Thu, Mar 22, 2012 at 11:13:17AM +0800, Miao Xie wrote: > The reason the deadlock is that: > TaskBtrfs-cleaner > umount() > down_write(&s->s_umount) > close_ctree() > wait for the end of > btrfs-cleaner >

Re: [RFC PATCH 1/2] vfs: add an interface to do some preparation for umount

2012-03-21 Thread Al Viro
On Thu, Mar 22, 2012 at 11:13:15AM +0800, Miao Xie wrote: > Some file systems can do some works in the background by kthreads, we'd > better stop those works before we umount the file system, or it is easy to > introduce some problems. So we add an interface that is used to do some > preparation fo

[RFC PATCH 2/2] Btrfs: fix deadlock on umount by umount_prepare interface

2012-03-21 Thread Miao Xie
The reason the deadlock is that: Task Btrfs-cleaner umount() down_write(&s->s_umount) close_ctree() wait for the end of btrfs-cleaner start_transaction reserve

[RFC PATCH 1/2] vfs: add an interface to do some preparation for umount

2012-03-21 Thread Miao Xie
Some file systems can do some works in the background by kthreads, we'd better stop those works before we umount the file system, or it is easy to introduce some problems. So we add an interface that is used to do some preparation for umount. Signed-off-by: Miao Xie --- fs/namespace.c |2

Re: [patch 17/35] btrfs: split extent_state ops

2012-03-21 Thread Jeff Mahoney
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 03/21/2012 09:56 PM, Liu Bo wrote: > On 03/22/2012 09:11 AM, Jeff Mahoney wrote: >> 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. >> >

Re: [patch 08/35] btrfs: Remove set bits return from clear_extent_bit

2012-03-21 Thread Jeff Mahoney
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 03/21/2012 10:03 PM, Liu Bo wrote: > On 03/22/2012 09:11 AM, Jeff Mahoney wrote: >> 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 fu

Re: [patch 08/35] btrfs: Remove set bits return from clear_extent_bit

2012-03-21 Thread Liu Bo
On 03/22/2012 09:11 AM, Jeff Mahoney wrote: > 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

Re: [patch 17/35] btrfs: split extent_state ops

2012-03-21 Thread Liu Bo
On 03/22/2012 09:11 AM, Jeff Mahoney wrote: > 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. > Hi Jeff, I have to say this is not a good cleanup, any benefits? thanks, liubo > Signed-off-b

[patch 21/35] btrfs: Dont BUG_ON kzalloc error in btrfs_lookup_csums_range()

2012-03-21 Thread Jeff Mahoney
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-loc

[patch 07/35] btrfs: avoid NULL deref in btrfs_reserve_extent with DEBUG_ENOSPC

2012-03-21 Thread Jeff Mahoney
__find_space_info can return NULL but we don't check it before calling dump_space_info(). Signed-off-by: Jeff Mahoney --- fs/btrfs/extent-tree.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 37e0a80..c32a9bf 100

[patch 03/35] btrfs: Panic on bad rbtree operations

2012-03-21 Thread Jeff Mahoney
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 --- fs/btrfs/ordered-data.c | 12 ++-- fs/btrfs/relocation.c | 36

[patch 01/35] btrfs: Add btrfs_panic()

2012-03-21 Thread Jeff Mahoney
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 ad

[patch 25/35] btrfs: Go readonly on tree errors in balance_level

2012-03-21 Thread Jeff Mahoney
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 --- fs/btrfs/ctree.c | 13 +++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fs

[patch 22/35] btrfs: Dont BUG_ON errors in __finish_chunk_alloc()

2012-03-21 Thread Jeff Mahoney
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 --- fs/btrfs/volumes.c | 10 ++ 1 files changed, 6 insertions(+), 4 deletions(-) diff --gi

[patch 17/35] btrfs: split extent_state ops

2012-03-21 Thread Jeff Mahoney
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 --- fs/btrfs/extent_io.c | 36 +++- fs/btrfs/extent_io.h |2 +- fs/btrfs/inode.c

[patch 24/35] btrfs: Dont BUG_ON errors from update_ref_for_cow()

2012-03-21 Thread Jeff Mahoney
__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 --- fs/btrfs/ctree.c |5 - 1 fi

[patch 26/35] btrfs: Dont BUG_ON insert errors in btrfs_alloc_dev_extent()

2012-03-21 Thread Jeff Mahoney
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 --- fs/btrfs/volumes.c |4 +++- 1 files

[patch 32/35] btrfs: Fix busyloop in transaction_kthread()

2012-03-21 Thread Jeff Mahoney
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 --- fs/btrfs/disk-io.c |9 ++

[patch 33/35] btrfs: handle errors when excluding super extents

2012-03-21 Thread Jeff Mahoney
Some images produced by btrfs-image cause a mount crash in rmap block when excluding superblock extents. Handle the errors gracefully. Signed-off-by: David Sterba --- fs/btrfs/extent-tree.c | 19 --- fs/btrfs/volumes.c | 20 +--- 2 files changed, 33 insert

[patch 27/35] btrfs: Remove BUG_ON from __btrfs_alloc_chunk()

2012-03-21 Thread Jeff Mahoney
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 --- fs/btrfs/volumes.c |3 ++- 1 files changed, 2 insertions(+), 1 dele

[patch 28/35] btrfs: Remove BUG_ON from __finish_chunk_alloc()

2012-03-21 Thread Jeff Mahoney
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 --- fs/btrfs/volumes.c |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --

[patch 29/35] btrfs: add varargs to btrfs_error

2012-03-21 Thread Jeff Mahoney
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 ou

[patch 35/35] btrfs: disallow unequal data/metadata blocksize for mixed block groups

2012-03-21 Thread Jeff Mahoney
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 --- fs/btrfs/disk-io.c |8 1 files changed, 8 insertions(+), 0 deletions(-) dif

[patch 30/35] btrfs: enhance transaction abort infrastructure

2012-03-21 Thread Jeff Mahoney
Signed-off-by: Jeff Mahoney --- fs/btrfs/ctree.h | 13 +++- fs/btrfs/disk-io.c | 50 - fs/btrfs/disk-io.h |4 + fs/btrfs/relocation.c | 14 ++-- fs/btrfs/scrub.c |8 ++- fs/btrfs/super.c | 74 +-- fs/btrfs/transaction.c | 190

[patch 34/35] btrfs: enhance superblock sanity checks

2012-03-21 Thread Jeff Mahoney
Validate checksum algorithm during mount and prevent BUG_ON later in btrfs_super_csum_size. Signed-off-by: David Sterba --- fs/btrfs/disk-io.c | 23 ++- 1 files changed, 18 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 438993e..38

[patch 20/35] btrfs: Dont BUG_ON() errors in update_ref_for_cow()

2012-03-21 Thread Jeff Mahoney
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

[patch 23/35] btrfs: Go readonly on bad extent refs in update_ref_for_cow()

2012-03-21 Thread Jeff Mahoney
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 --- fs/btrfs/ctree.c |6 +- 1 fil

[patch 16/35] btrfs: drop gfp_t from lock_extent

2012-03-21 Thread Jeff Mahoney
lock_extent and unlock_extent are always called with GFP_NOFS, drop the argument and use GFP_NOFS consistently. Signed-off-by: Jeff Mahoney --- fs/btrfs/compression.c |6 +++--- fs/btrfs/disk-io.c |2 +- fs/btrfs/extent_io.c| 41 +++--

[patch 06/35] btrfs: clean_tree_block should panic on observed memory corruption and return void

2012-03-21 Thread Jeff Mahoney
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 Mah

[patch 08/35] btrfs: Remove set bits return from clear_extent_bit

2012-03-21 Thread Jeff Mahoney
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 --- fs/btrfs/extent

[patch 10/35] btrfs: btrfs_update_root error push-up

2012-03-21 Thread Jeff Mahoney
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 --- fs/btrfs/ctree.h |7 --- fs/btrfs/root-tree.c |4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fs

[patch 18/35] btrfs: btrfs_drop_snapshot should return int

2012-03-21 Thread Jeff Mahoney
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

[patch 05/35] btrfs: Simplify btrfs_insert_root

2012-03-21 Thread Jeff Mahoney
btrfs_insert_root is just a wrapper for btrfs_insert_item. Just return the error directly. Signed-off-by: Jeff Mahoney --- fs/btrfs/root-tree.c |9 +++-- 1 files changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c index f409990..1fd93d6 1006

[patch 09/35] btrfs: find_and_setup_root error push-up

2012-03-21 Thread Jeff Mahoney
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 --- fs/btrfs/disk-io.c | 11 ++- 1 files changed, 6 insertions(

[patch 14/35] btrfs: __add_reloc_root error push-up

2012-03-21 Thread Jeff Mahoney
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 --- fs/btrfs/relocation.c | 22 -- 1 files changed, 16 insertions(+), 6 d

[patch 12/35] btrfs: Factor out tree->ops->merge_bio_hook call

2012-03-21 Thread Jeff Mahoney
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

[patch 19/35] btrfs: Dont BUG_ON errors from btrfs_create_subvol_root()

2012-03-21 Thread Jeff Mahoney
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 error

[patch 11/35] btrfs: Simplify btrfs_submit_bio_hook

2012-03-21 Thread Jeff Mahoney
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

[patch 13/35] btrfs: ->submit_bio_hook error push-up

2012-03-21 Thread Jeff Mahoney
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 er

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

2012-03-21 Thread Jeff Mahoney
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 --- fs/btrfs/extent_io.c | 58

[patch 04/35] btrfs: Fix kfree of member instead of structure

2012-03-21 Thread Jeff Mahoney
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-b

[patch 00/35] btrfs: Error Handling Patchset

2012-03-21 Thread Jeff Mahoney
This is the error handling patchset for btrfs. The series is comprised of several groups of patches: - Adding new btrfs_panic and btrfs_error routines - Adding the ability to abort transactions - Converting functions that don't have error conditions to return void - Eliminating the

Re: [RFC PATCH 0/5] apply rwlock for extent state

2012-03-21 Thread Liu Bo
On 03/22/2012 09:04 AM, Chris Samuel wrote: > On 21/03/12 23:34, Andrea Gelmini wrote: > >> No comment, but I'm using this patches without problem since you >> published it (compressed /home with hourly snapshot delete/creation). > > Well worth sending a Tested-By: tag then, it's useful informati

Re: [RFC PATCH 0/5] apply rwlock for extent state

2012-03-21 Thread Chris Samuel
On 21/03/12 23:34, Andrea Gelmini wrote: > No comment, but I'm using this patches without problem since you > published it (compressed /home with hourly snapshot delete/creation). Well worth sending a Tested-By: tag then, it's useful information. cheers, Chris -- Chris Samuel : http://www.cs

[PATCH] Btrfs: fix return value check of read_tree_block

2012-03-21 Thread Tsutomu Itoh
read_tree_block() has the possibility of returning NULL. So, the code in which it is checked whether the return value is NULL is added. Signed-off-by: Tsutomu Itoh --- fs/btrfs/print-tree.c |1 + fs/btrfs/relocation.c |2 +- 2 files changed, 2 insertions(+), 1 deletions(-) diff --git a/

Re: looking for non existent devices

2012-03-21 Thread Helmut Hullen
Hallo, Ilya, Du meintest am 21.03.12: >>> I think this has been fixed in recent btrfs-progs, commit 32eff711. >> It is fixed in some (or many) places, it is not fixed everywhere. I >> had used kernel 3.2.9 > 32eff711 is supposed to fix it in more places, filesystem label and > scrub status incl

Re: looking for non existent devices

2012-03-21 Thread Ilya Dryomov
On Wed, Mar 21, 2012 at 07:24:00PM +0100, Helmut Hullen wrote: > Hallo, Ilya, > > Du meintest am 21.03.12: > > >> When I run > >> > >> btrfs filesystem label > >> > >> or > >> > >> btrfs scrub status /dev/sdxn > >> > >> then I get a lot of error messages with (p.e.) > >> > >> fa

Re: looking for non existent devices

2012-03-21 Thread Helmut Hullen
Hallo, Ilya, Du meintest am 21.03.12: >> When I run >> >> btrfs filesystem label >> >> or >> >> btrfs scrub status /dev/sdxn >> >> then I get a lot of error messages with (p.e.) >> >> failed to read /dev/hda6: No such device or address >> failed to read /dev/sdm7: No such devi

Re: looking for non existent devices

2012-03-21 Thread Ilya Dryomov
On Sat, Mar 17, 2012 at 10:32:00AM +0100, Helmut Hullen wrote: > Hallo, linux-btrfs, > > some commands still look for non existent devices. > > I don't use "udev". > When I run > > btrfs filesystem show > > only the existent devices are shown - fine. > > When I run > > btrfs f

Re: [RFC PATCH 0/5] apply rwlock for extent state

2012-03-21 Thread Andrea Gelmini
2012/3/21 Liu Bo : > Any comments? No comment, but I'm using this patches without problem since you published it (compressed /home with hourly snapshot delete/creation). Thanks a lot for your work, Andrea -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a m

Re: Synchronous snapshot delete

2012-03-21 Thread Arne Jansen
Hi Anand, On 21.03.2012 05:03, Anand Jain wrote: > > Hi Team, > > Could you let me know if you are working on.. > >Synchronous snapshot delete (or similar) > > few requested for this feature, just wanted > to know if anyone has picked up this and is > working on it. I'm not working d

Re: 'bad tree block start' mount failure...

2012-03-21 Thread Daniel J Blueman
On 21 March 2012 00:16, Andrea Gelmini wrote: > 2012/3/20 Daniel J Blueman : >> mkfs.btrfs -m raid0 -d raid0 /dev/sdb1 /dev/sdc1 >> mount /dev/sdb1 /mnt >> umount /mnt >> mount /dev/sdb1 /mnt -o compress >> umount /mnt >> mount /dev/sdb1 /mnt -o ssd >> umount /mnt >> mount /dev/sdb1 /mnt -o discar