linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Provide a better free space estimate on RAID1
@ 2014-02-05 20:15 Roman Mamedov
  2014-02-06  7:38 ` Brendan Hide
  2014-02-06 20:21 ` Josef Bacik
  0 siblings, 2 replies; 36+ messages in thread
From: Roman Mamedov @ 2014-02-05 20:15 UTC (permalink / raw)
  To: linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 1394 bytes --]

Hello,

On a freshly-created RAID1 filesystem of two 1TB disks:

# df -h /mnt/p2/
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       1.8T  1.1M  1.8T   1% /mnt/p2

I cannot write 2TB of user data to that RAID1, so this estimate is clearly
misleading. I got tired of looking at the bogus disk free space on all my
RAID1 btrfs systems, so today I decided to do something about this:

--- fs/btrfs/super.c.orig	2014-02-06 01:28:36.636164982 +0600
+++ fs/btrfs/super.c	2014-02-06 01:28:58.304164370 +0600
@@ -1481,6 +1481,11 @@
 	}
 
 	kfree(devices_info);
+
+	if (type & BTRFS_BLOCK_GROUP_RAID1) {
+		do_div(avail_space, min_stripes);
+	}
+  
 	*free_bytes = avail_space;
 	return 0;
 }


After:

# df -h /mnt/p2/
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       1.8T  1.1M  912G   1% /mnt/p2

Until per-subvolume RAID profiles are implemented, this estimate will be
correct, and even after, it should be closer to the truth than assuming the
user will fill their RAID1 FS only with subvolumes of single or raid0 profiles.

If anyone likes feel free to reimplement my PoC patch in a better way, e.g.
integrate this into the calculation 'while' block of that function immediately
before it (logic of which I couldn't yet grasp due to it lacking comments),
and not just tacked onto the tail of it.

-- 
With respect,
Roman

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

end of thread, other threads:[~2014-02-10  9:14 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-05 20:15 Provide a better free space estimate on RAID1 Roman Mamedov
2014-02-06  7:38 ` Brendan Hide
2014-02-06 12:45   ` Roman Mamedov
2014-02-06 19:54     ` Goffredo Baroncelli
2014-02-07  4:40       ` Roman Mamedov
2014-02-07  5:30         ` Chris Murphy
2014-02-07  6:08           ` Roman Mamedov
2014-02-07 18:44             ` Chris Murphy
2014-02-08 21:46               ` Kai Krakow
2014-02-08 11:21             ` Roman Mamedov
2014-02-07 10:02           ` Martin Steigerwald
2014-02-08 21:50             ` Kai Krakow
2014-02-08 15:46         ` Goffredo Baroncelli
2014-02-08 16:36         ` [PATCH][V2] " Goffredo Baroncelli
2014-02-09 17:20         ` [PATCH][V3] Provide a better free space estimate [was]Re: " Goffredo Baroncelli
2014-02-07 14:05       ` Frank Kingswood
2014-02-06 20:21 ` Josef Bacik
2014-02-07 20:32   ` Kai Krakow
2014-02-08 11:33     ` Roman Mamedov
2014-02-08 11:46       ` Hugo Mills
2014-02-08 21:35         ` Kai Krakow
2014-02-08 22:10           ` Roman Mamedov
2014-02-08 22:45             ` cwillu
2014-02-08 23:27               ` Kai Krakow
2014-02-08 23:32             ` Kai Krakow
2014-02-09  1:08               ` Roman Mamedov
2014-02-09  9:39                 ` Kai Krakow
2014-02-09  6:38             ` Duncan
2014-02-09  9:20               ` Roman Mamedov
2014-02-10  0:02                 ` Duncan
2014-02-10  9:14                   ` Roman Mamedov
2014-02-09  9:37               ` Kai Krakow
2014-02-08 23:17       ` Kai Krakow
2014-02-09  1:55         ` Roman Mamedov
2014-02-09  2:21           ` Chris Murphy
2014-02-09  2:29             ` Chris Murphy

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).