Re: recursive subvolume delete

2011-10-02 Thread Stephane Chazelas
2011-10-02 16:38:21 +0200, krz...@gmail.com :
> Also I think there are no real tools to find out which
> directories are subvolumes/snapshots
[...]

On my system (debian), there's "mountpoint" command (from the
initscript package from
http://savannah.nongnu.org/projects/sysvinit) that will tell you
that (it compares the st_dev of the given directory with that of
directory/..).

-- 
Stephane
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Regression in btrfs-next: BUG at fs/btrfs/super.c:984!

2011-10-02 Thread Maciej Marcin Piechotka
On Sun, 2011-10-02 at 19:39 +0200, David Sterba wrote:
> On Sat, Oct 01, 2011 at 11:43:10PM +0200, Maciej Marcin Piechotka wrote:
> > PS. It might happened that it was caused by parition mounted read-only
> > on read-only block device.
>   ^^^
> 
> This is the key information!
> 
> super.c: btrfs_calc_avail_data_space()
>  983 nr_devices = fs_info->fs_devices->rw_devices;
>  984 BUG_ON(!nr_devices);
> 
> 
> If there are no writable devices, this BUGON fires, although this case
> in connection with RO mount is handled elsewhere properly.
> 
> This is called through sysfs and just tries to obtain available free
> space information to print it. I think the BUG_ON is not necessary here
> and the function can take a short track returning 0 as available free
> space:
> 
> if (!nr_devices) {
>   *free_bytes = 0;
>   return 0;
> }
> 
> I could be possible to actually read the free space even from a RO
> device (be it RO mount or not), but I don't see much benefit which would
> justify the work.
> 
> Can you please test the fix and let us know if the statfs number look
> reasonable?
> 
> 
> david

Well - it shows size 50G, used 29G and avail 0G in df -h.

Regards


signature.asc
Description: This is a digitally signed message part


Re: Regression in btrfs-next: BUG at fs/btrfs/super.c:984!

2011-10-02 Thread David Sterba
On Sat, Oct 01, 2011 at 11:43:10PM +0200, Maciej Marcin Piechotka wrote:
> PS. It might happened that it was caused by parition mounted read-only
> on read-only block device.
  ^^^

This is the key information!

super.c: btrfs_calc_avail_data_space()
 983 nr_devices = fs_info->fs_devices->rw_devices;
 984 BUG_ON(!nr_devices);


If there are no writable devices, this BUGON fires, although this case
in connection with RO mount is handled elsewhere properly.

This is called through sysfs and just tries to obtain available free
space information to print it. I think the BUG_ON is not necessary here
and the function can take a short track returning 0 as available free
space:

if (!nr_devices) {
*free_bytes = 0;
return 0;
}

I could be possible to actually read the free space even from a RO
device (be it RO mount or not), but I don't see much benefit which would
justify the work.

Can you please test the fix and let us know if the statfs number look
reasonable?


david
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: recursive subvolume delete

2011-10-02 Thread David Sterba
On Sun, Oct 02, 2011 at 04:38:21PM +0200, krz...@gmail.com  wrote:
> Also I think there are no real tools to find out which directories are
> subvolumes/snapshots

Well, there are, but these are the _real_ tools, you know.

subv1 is a subvolume
snap1 is it's snapshot

$ stat subv1 snap1
  File: `subv1'
  Size: 0   Blocks: 0  IO Block: 4096   directory
Device: 1ch/28d Inode: 256 Links: 1
Access: (0700/drwx--)  Uid: (0/root)   Gid: (0/root)
Access: 2011-10-02 19:12:04.493885220 +0200
Modify: 2011-10-02 19:12:04.493885220 +0200
Change: 2011-10-02 19:12:04.493885220 +0200
 Birth: -
  File: `snap1'
  Size: 0   Blocks: 0  IO Block: 4096   directory
Device: b1h/177dInode: 256 Links: 1
Access: (0700/drwx--)  Uid: (0/root)   Gid: (0/root)
Access: 2011-10-02 19:12:04.493885220 +0200
Modify: 2011-10-02 19:12:04.493885220 +0200
Change: 2011-10-02 19:12:04.493885220 +0200
 Birth: -


Common signature is "Inode: 256" and this is acutally the same test which is
performed by 'btrfs subvol ...' to check whether the source dir is a
subvolume, and by the kernel module as well.


david
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: recursive subvolume delete

2011-10-02 Thread Hugo Mills
On Sun, Oct 02, 2011 at 04:38:21PM +0200, krz...@gmail.com  wrote:
> btrfs is missing recursive subvolume delete. You can't delete
> subvolume if there is other subvolumes/snapshots in it. Also I think
> there are no real tools to find out which directories are
> subvolumes/snapshots

$ btrfs sub list /mountpoint

   This will tell you what subvolumes you have on any given filesystem.

   Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
--- There's an infinite number of monkeys outside who want to ---
   talk to us about this new script for Hamlet   
   they've worked out!   


signature.asc
Description: Digital signature


recursive subvolume delete

2011-10-02 Thread krz...@gmail.com
btrfs is missing recursive subvolume delete. You can't delete
subvolume if there is other subvolumes/snapshots in it. Also I think
there are no real tools to find out which directories are
subvolumes/snapshots
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Btrfs: pass the correct root to lookup_free_space_inode()

2011-10-02 Thread Ilya Dryomov
Free space items are located in tree of tree roots, not in the extent
tree.  It didn't pop up because lookup_free_space_inode() grabs the
inode all the time instead of actually searching the tree.

Signed-off-by: Ilya Dryomov 
---
 fs/btrfs/extent-tree.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 25b69d0..b66a0ce 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -7283,7 +7283,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle 
*trans,
goto out;
}
 
-   inode = lookup_free_space_inode(root, block_group, path);
+   inode = lookup_free_space_inode(tree_root, block_group, path);
if (!IS_ERR(inode)) {
ret = btrfs_orphan_add(trans, inode);
BUG_ON(ret);
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html