Reclaim space.
Hi,
I assume this has something to do with using updated btrfs and old btrfs utils, but it's only the presentation that is wrong.
btrfs-show gives:
Label: none uuid: 2332476e-ed10-44b4-844b-c85cc7388a61
Total devices 1 FS bytes used 266.53GB devid 1 size 145.00GB used 145.00GB path /dev/mapper/root
But df -h gives:/dev/mapper/root 145G -64Z -122G 100% /
Also, following your guides i tried to do a rm -rf ext2_saved, which didn't quite work...
rm -rf ext2_saved/
rm: cannot remove directory `ext2_saved': Directory not empty
ls -la ext2_saved/
total 4
drwxr-xr-x 1 root root 0 9 feb 13.41 .
drwxr-xr-x 1 root root 170 2 dec 21.54 ..
Any clues, ideas, suggestions?
(Remember the CC)
PS. Beyond that i really like my experiences with btrfs so far (this was my first root filesystem migration though)
DS.
Signature · 1 line
Ian Kumlien <pomac () vapor ! com> -- http://pomac.netswarm.net
Hi,
Quoted 3 lines
Hi, I assume this has something to do with using updated btrfs and old btrfs utils, but it's only the presentation that is wrong.
Yes, this wouldn't happen with latest btrfs-progs.
Quoted 2 lines
But df -h gives:
/dev/mapper/root145G -64Z -122G 100% /
Here's a patch to btrfsck from Josef that should fix this:
--- btrfsck.c | 30 ++++++++++++++++++++++++++++++ ctree.h | 1 + extent-tree.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 0 deletions(-)
btrfsck.c +30 -0
@@ -2805,6 +2805,34 @@ static int check_extents(struct btrfs_root *root)return ret; } +static void check_space_used (struct btrfs_root *root) +{ +struct btrfs_fs_info *info = root->fs_info; +u64 total; +u64 super_total; + + total =btrfs_total_used (root); + super_total =btrfs_super_bytes_used (&info->super_copy); + +if (total != super_total) { +struct btrfs_trans_handle *trans; + + trans =btrfs_start_transaction (root,1 ); +if (!trans) +return ; +printf ("Super total bytes used (%llu) doesn't match actual " +"bytes used (%llu). Fixing.\n" , + (unsigned long long )super_total, + (unsigned long long )total); +btrfs_set_super_bytes_used (&info->super_copy, total); +btrfs_commit_transaction (trans, root); + }else { +printf ("Super total bytes used (%llu) matches actual (%llu)\n" , + (unsigned long long )super_total, + (unsigned long long )total); + } +} +static void print_usage (void ) {fprintf (stderr,"usage: btrfsck dev\n" );
@@ -2836,6 +2864,8 @@ int main(int ac, char **av) goto out; ret =check_root_refs (root, &root_cache); +if (!ret) +check_space_used (root); out:free_root_recs (&root_cache);close_ctree (root);
ctree.h +1 -0
@@ -1699,6 +1699,7 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 bytes_used, u64 type, u64 chunk_objectid, u64 chunk_offset, u64 size); +u64 btrfs_total_used (struct btrfs_root *root);int btrfs_make_block_groups (struct btrfs_trans_handle *trans,struct btrfs_root *root); int btrfs_update_block_group(struct btrfs_trans_handle *trans,
extent-tree.c +32 -0
@@ -3135,6 +3135,38 @@ error:return ret; } +u64 btrfs_total_used (struct btrfs_root *root) +{ +struct btrfs_block_group_cache *cache; +struct extent_io_tree *block_group_cache; +int ret; +u64 ptr; +u64 start; +u64 end; +u64 total =0 ; + + block_group_cache = &root->fs_info->block_group_cache; + start =BTRFS_SUPER_INFO_OFFSET +BTRFS_SUPER_INFO_SIZE ; +while (1 ) { + ret =find_first_extent_bit (block_group_cache, + start, &start, &end, +BLOCK_GROUP_DATA | +BLOCK_GROUP_METADATA | +BLOCK_GROUP_SYSTEM ); +if (ret) +break ; + ret =get_state_private (block_group_cache, start, &ptr); +if (ret) +break ; + + cache = (struct btrfs_block_group_cache *)(unsigned long )ptr; + total +=btrfs_block_group_used (&cache->item); + start = end +1 ; + } + +return total; +} + int btrfs_make_block_group(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 bytes_used, u64 type, u64 chunk_objectid, u64 chunk_offset,
Signature · 5 lines
1.5.4.3 -- Chris Ball <[email protected]> One Laptop Per Child
Hi,
Quoted 1 line
Here's a patch to btrfsck from Josef that should fix this:
Sorry, that was an older patch. This is the working one:
From: Josef Bacik <[email protected]>
Date: Wed, 14 Oct 2009 14:39:26 -0400
Subject: [PATCH] patch fix-space-accounting.patch
--- btrfsck.c | 32 +++++++++++++++++++++++++++++ ctree.h | 2 + disk-io.c | 47 +++++++++++++++++++++++++++++++++++++++++++ disk-io.h | 2 + extent-tree.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 145 insertions(+), 0 deletions(-)
btrfsck.c +32 -0
@@ -2805,6 +2805,36 @@ static int check_extents(struct btrfs_root *root)return ret; } +static void check_space_used (struct btrfs_root *root) +{ +struct btrfs_fs_info *info = root->fs_info; +u64 total; +u64 super_total; + + total =btrfs_total_used (root); + super_total =btrfs_super_bytes_used (&info->super_copy); + +if (total != super_total) { +struct btrfs_trans_handle *trans; + +btrfs_make_readwrite (info); + trans =btrfs_start_transaction (root,1 ); +if (!trans) +return ; +printf ("Super total bytes used (%llu) doesn't match actual " +"bytes used (%llu). Fixing.\n" , + (unsigned long long )super_total, + (unsigned long long )total); +btrfs_set_super_bytes_used (&info->super_copy, total); +btrfs_commit_transaction (trans, root); +btrfs_make_readonly (info); + }else { +printf ("Super total bytes used (%llu) matches actual (%llu)\n" , + (unsigned long long )super_total, + (unsigned long long )total); + } +} +static void print_usage (void ) {fprintf (stderr,"usage: btrfsck dev\n" );
@@ -2836,6 +2866,8 @@ int main(int ac, char **av) goto out; ret =check_root_refs (root, &root_cache); +if (!ret) +check_space_used (root); out:free_root_recs (&root_cache);close_ctree (root);
ctree.h +2 -0
@@ -1699,6 +1699,8 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 bytes_used, u64 type, u64 chunk_objectid, u64 chunk_offset, u64 size); +u64 btrfs_total_used (struct btrfs_root *root); +void btrfs_update_block_groups_readonly (struct btrfs_fs_info *info);int btrfs_make_block_groups (struct btrfs_trans_handle *trans,struct btrfs_root *root); int btrfs_update_block_group(struct btrfs_trans_handle *trans,
disk-io.c +47 -0
53 lines not on this page · raw message
disk-io.h +2 -0
@@ -75,4 +75,6 @@ int csum_tree_block_size(struct extent_buffer *buf, u16 csum_sectorsize,int csum_tree_block (struct btrfs_root *root,struct extent_buffer *buf,int verify);int btrfs_read_buffer (struct extent_buffer *buf,u64 parent_transid); +int btrfs_make_readwrite (struct btrfs_fs_info *fs_info); +int btrfs_make_readonly (struct btrfs_fs_info *fs_info);#endif
extent-tree.c +62 -0
68 lines not on this page · raw message
Signature · 5 lines
1.5.4.3 -- Chris Ball <[email protected]> One Laptop Per Child
Quoted 5 lines · Chris Ball
Hi,
Quoted 1 line
Here's a patch to btrfsck from Josef that should fix this:
Sorry, that was an older patch. This is the working one:
Will test soon!
Will this also fix the directory that i can't delete?
Signature · 1 line
Ian Kumlien <pomac () vapor ! com> -- http://pomac.netswarm.net
Hi,
Quoted 1 line
Will this also fix the directory that i can't delete?
No, I think you need "btrfsctl -D" for that.
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> One Laptop Per Child
Quoted 5 lines · Chris Ball
Hi,
Quoted 1 line
Will this also fix the directory that i can't delete?
No, I think you need "btrfsctl -D" for that.
btrfsctl -D ext2_saved/
ioctl:: Invalid argument
uname -r
2.6.33-rc7
So i assume it's not merged yet?
Quoted 1 line
- Chris.
Signature · 1 line
Ian Kumlien <pomac () vapor ! com> -- http://pomac.netswarm.net
Hi,
Quoted 2 lines
btrfsctl -D ext2_saved/
ioctl:: Invalid argument
It's merged (during 2.6.32) -- I think you just have the wrong syntax. See http://btrfs.wiki.kernel.org/index.php/Btrfsctl.
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> One Laptop Per Child
Quoted 7 lines · Chris Ball
Hi,
Quoted 2 lines
btrfsctl -D ext2_saved/
ioctl:: Invalid argumentIt's merged (during 2.6.32) -- I think you just have the wrong syntax. See http://btrfs.wiki.kernel.org/index.php/Btrfsctl.
Ahh, now i get it, thanks =)
Quoted 1 line
- Chris.
Signature · 1 line
Ian Kumlien <pomac () vapor ! com> -- http://pomac.netswarm.net
Quoted 5 lines · Chris Ball
Hi,
Quoted 1 line
Here's a patch to btrfsck from Josef that should fix this:
Sorry, that was an older patch. This is the working one:
It didn't apply cleanly to latest git, so i remerged the patch... The new output sure looks better in my eyes:
/dev/mapper/root 145G 135G 11G 93% /
=)
Thanks, I do wonder btw, btrfsck always seems to segfault when you check a filesystem in real use - ie loged in users and daemons running - but not on a normal 'single' user boot. Anything that could be done with this? (It doesn't inspire confidence ;))
Signature · 1 line
Ian Kumlien <pomac () vapor ! com> -- http://pomac.netswarm.net
* [Ian Kumlien]=20
Quoted 1 line
Thanks, I do wonder btw, btrfsck always seems to segfault when you ch=
eck
Quoted 1 line
a filesystem in real use - ie loged in users and daemons running - bu=
t
Quoted 2 lines
not on a normal 'single' user boot. Anything that could be done with this? (It doesn't inspire confidence ;))
Online filesystem check isn't yet implemented. What you're seeing is btrfsck not actually checking to see if the fs is mounted before running. Make sure to always umount before running btrfsck.
(I remember reading something about such a check being added to btrfsck= ,
so it might be better with newer btrfs-tools).
=D8ystein
--=20
Outgoing mail is certified Virus Free.
=2E.of course, the virus would tell you the same thing..
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html