linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: Don't error on resizing FS to same size
@ 2011-11-17 21:04 Mike Fleetwood
  2011-11-18  4:52 ` Chris Samuel
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Fleetwood @ 2011-11-17 21:04 UTC (permalink / raw)
  To: linux-btrfs

It seems overly harsh to fail a resize of a btrfs file system to the
same size when a shrink or grow would succeed.  User app GParted trips
over this error.  Allow it by bypassing the shrink or grow operation.

Signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
---

Example failed resize:
    # strace -e trace=ioctl btrfs filesystem resize max /mnt/0
    Resize '/mnt/0' of 'max'
    ioctl(3, 0x50009403, 0xbfa5029c)        = -1 EINVAL (Invalid argument)
    ERROR: unable to resize '/mnt/0' - Invalid argument
    # echo $?
    30
    # dmesg | tail -1
    [426094.235018] new size for /dev/loop1 is 1073741824

---
 fs/btrfs/ioctl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index dae5dfe..00b7024 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1251,7 +1251,7 @@ static noinline int btrfs_ioctl_resize(struct btrfs_root *root,
 		}
 		ret = btrfs_grow_device(trans, device, new_size);
 		btrfs_commit_transaction(trans, root);
-	} else {
+	} else if (new_size > old_size) {
 		ret = btrfs_shrink_device(device, new_size);
 	}
 
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Btrfs: Don't error on resizing FS to same size
  2011-11-17 21:04 [PATCH] Btrfs: Don't error on resizing FS to same size Mike Fleetwood
@ 2011-11-18  4:52 ` Chris Samuel
  2011-11-18  8:14   ` Mike Fleetwood
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Samuel @ 2011-11-18  4:52 UTC (permalink / raw)
  To: Mike Fleetwood; +Cc: linux-btrfs

On 18/11/11 08:04, Mike Fleetwood wrote:

> It seems overly harsh to fail a resize of a btrfs file system to the
> same size when a shrink or grow would succeed.  User app GParted trips
> over this error.  Allow it by bypassing the shrink or grow operation.

OK - I'm a newbie with the code (and I'm looking at Linus's current git
rather than any dev tree of Chris's), but...

> Signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
> ---
[...]
> ---
>  fs/btrfs/ioctl.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index dae5dfe..00b7024 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -1251,7 +1251,7 @@ static noinline int btrfs_ioctl_resize(struct btrfs_root *root,
>  		}
>  		ret = btrfs_grow_device(trans, device, new_size);
>  		btrfs_commit_transaction(trans, root);
> -	} else {
> +	} else if (new_size > old_size) {

shouldn't that be:

+	} else if (new_size < old_size) {

otherwise you'll never try and shrink if new_size is < old_size..

>  		ret = btrfs_shrink_device(device, new_size);
>  	}
>  


-- 
 Chris Samuel  :  http://www.csamuel.org/  :  Melbourne, VIC

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Btrfs: Don't error on resizing FS to same size
  2011-11-18  4:52 ` Chris Samuel
@ 2011-11-18  8:14   ` Mike Fleetwood
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Fleetwood @ 2011-11-18  8:14 UTC (permalink / raw)
  To: Chris Samuel; +Cc: linux-btrfs

On Fri, Nov 18, 2011 at 03:52:00PM +1100, Chris Samuel wrote:
> On 18/11/11 08:04, Mike Fleetwood wrote:
> 
> > It seems overly harsh to fail a resize of a btrfs file system to the
> > same size when a shrink or grow would succeed.  User app GParted trips
> > over this error.  Allow it by bypassing the shrink or grow operation.
> 
> OK - I'm a newbie with the code (and I'm looking at Linus's current git
> rather than any dev tree of Chris's), but...
> 
> > Signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
> > ---
> [...]
> > ---
> >  fs/btrfs/ioctl.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> > index dae5dfe..00b7024 100644
> > --- a/fs/btrfs/ioctl.c
> > +++ b/fs/btrfs/ioctl.c
> > @@ -1251,7 +1251,7 @@ static noinline int btrfs_ioctl_resize(struct btrfs_root *root,
> >  		}
> >  		ret = btrfs_grow_device(trans, device, new_size);
> >  		btrfs_commit_transaction(trans, root);
> > -	} else {
> > +	} else if (new_size > old_size) {
> 
> shouldn't that be:
> 
> +	} else if (new_size < old_size) {
> 
> otherwise you'll never try and shrink if new_size is < old_size..
> 
> >  		ret = btrfs_shrink_device(device, new_size);
> >  	}
> >  

Chris, you're correct.  I have messed up a 1 line patch by rushing.
Will send corrected patch after some more testing!

Embarrassed,
Mike

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-11-18  8:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-17 21:04 [PATCH] Btrfs: Don't error on resizing FS to same size Mike Fleetwood
2011-11-18  4:52 ` Chris Samuel
2011-11-18  8:14   ` Mike Fleetwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).