Thread (20 messages) 20 messages, 5 authors, 2022-01-06

Re: [PATCH 1/6] btrfs: add flags to give an hint to the chunk allocator

From: Boris Burkov <hidden>
Date: 2022-01-05 22:11:39

On Fri, Dec 17, 2021 at 07:47:17PM +0100, Goffredo Baroncelli wrote:
From: Goffredo Baroncelli <redacted>

Add the following flags to give an hint about which chunk should be
allocated in which a disk:

- BTRFS_DEV_ALLOCATION_HINT_PREFERRED_DATA
  preferred data chunk, but metadata chunk allowed
- BTRFS_DEV_ALLOCATION_HINT_PREFERRED_METADATA
  preferred metadata chunk, but data chunk allowed
- BTRFS_DEV_ALLOCATION_HINT_METADATA_ONLY
  only metadata chunk allowed
- BTRFS_DEV_ALLOCATION_HINT_DATA_ONLY
  only data chunk allowed
Weighing in on the naming discussion:

I think DATA_ONLY > ONLY_DATA, with my best argument for this subjective
opinion being that it follows the example of read-only.

Therefore, I think you should go with DATA_ONLY, DATA_PREFERRED,
METADATA_ONLY, METADATA_PREFERRED. Definitely put ONLY/PREFERRED on the
same side of DATA/METADATA for all four, regardless of which you choose.

Looks good otherwise.
quoted hunk ↗ jump to hunk
Signed-off-by: Goffredo Baroncelli <redacted>
---
 include/uapi/linux/btrfs_tree.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h
index 5416f1f1a77a..55da906c2eac 100644
--- a/include/uapi/linux/btrfs_tree.h
+++ b/include/uapi/linux/btrfs_tree.h
@@ -386,6 +386,22 @@ struct btrfs_key {
 	__u64 offset;
 } __attribute__ ((__packed__));
 
+/* dev_item.type */
+
+/* btrfs chunk allocation hint */
+#define BTRFS_DEV_ALLOCATION_HINT_BIT_COUNT	2
+/* btrfs chunk allocation hint mask */
+#define BTRFS_DEV_ALLOCATION_HINT_MASK	\
+	((1 << BTRFS_DEV_ALLOCATION_HINT_BIT_COUNT) -1)
+/* preferred data chunk, but metadata chunk allowed */
+#define BTRFS_DEV_ALLOCATION_HINT_PREFERRED_DATA	(0ULL)
+/* preferred metadata chunk, but data chunk allowed */
+#define BTRFS_DEV_ALLOCATION_HINT_PREFERRED_METADATA	(1ULL)
+/* only metadata chunk are allowed */
+#define BTRFS_DEV_ALLOCATION_HINT_METADATA_ONLY		(2ULL)
+/* only data chunk allowed */
+#define BTRFS_DEV_ALLOCATION_HINT_DATA_ONLY		(3ULL)
+
 struct btrfs_dev_item {
 	/* the internal btrfs device id */
 	__le64 devid;
-- 
2.34.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help