summary refs log tree commit diff
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2012-03-27 17:09:16 +0300
committerIlya Dryomov <idryomov@gmail.com>2012-03-27 17:09:16 +0300
commit899c81eac890bcfa5f3636f4c43f68e8393ac1f8 (patch)
treef2a202c25edd6a58a4c0018db03617b6b0c46fc8 /fs/btrfs/ctree.h
parente3176ca2769e420f64eba4b093bbddea6d7a89c3 (diff)
downloadlinux-899c81eac890bcfa5f3636f4c43f68e8393ac1f8.tar.gz
Btrfs: add wrappers for working with alloc profiles
Add functions to abstract the conversion between chunk and extended
allocation profile formats and switch everybody to use them.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index c2e17cd299b7..aba7832a2285 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -849,6 +849,21 @@ struct btrfs_csum_item {
  */
 #define BTRFS_AVAIL_ALLOC_BIT_SINGLE	(1ULL << 48)
 
+#define BTRFS_EXTENDED_PROFILE_MASK	(BTRFS_BLOCK_GROUP_PROFILE_MASK | \
+					 BTRFS_AVAIL_ALLOC_BIT_SINGLE)
+
+static inline u64 chunk_to_extended(u64 flags)
+{
+	if ((flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0)
+		flags |= BTRFS_AVAIL_ALLOC_BIT_SINGLE;
+
+	return flags;
+}
+static inline u64 extended_to_chunk(u64 flags)
+{
+	return flags & ~BTRFS_AVAIL_ALLOC_BIT_SINGLE;
+}
+
 struct btrfs_block_group_item {
 	__le64 used;
 	__le64 chunk_objectid;