Skip to contentSkip to conversation

read_policy type heuristic

RFC PATCH New Anand Jain 1 participant 2 messages Jul 21, 2022 Btrfs file system

lore
Share & tools
lore

Anand Jain

author
#0 lore raw

cover read_policy type heuristic

POC patch proposes a read_policy type Heuristic to solve the problem of poor read performance for the mirrored stripes on mixed device types. Read_policy Heuristic has benefits of both pid and has no dependency on block layer iostats. Instead, it uses statically defined device_type and its latency.

This patch is a POC patch that has no performance analysis yet. I am sending this to get some early feedback.

For the read_policy type Latency, please refer here [1]. The read_policy type Latency works better overall, and it is self-tuning based on the IO.

[1]
https://lore.kernel.org/linux-btrfs/20210120123437.OVx7ybGaVfmOdZxtpp43qcB_ORHQQs5OzPSzr3ZUGbo@z/T/#u

Anand Jain (1):
btrfs: add read_policy heuristic

 fs/btrfs/sysfs.c   |  2 +-
 fs/btrfs/volumes.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++
 fs/btrfs/volumes.h |  2 ++
 3 files changed, 55 insertions(+), 1 deletion(-)
Signature · 1 line
2.33.1
author
#1 lore raw

RFC PATCH 1/1 btrfs: add read_policy heuristic

Read_policy type Heuristic provides the low latency device-type if read_policy type PID fails. The read policy heuristic retains the advantages of the PID-based read_policy and has no dependency on block layer iostats. This policy can be a default policy.

This patch depends on the patches[1], which provides device types in the order of their latency.
[1]
btrfs: create chunk device type aware
btrfs: keep device type in the struct btrfs_device

Usage:

  $ echo heuristic > /sys/fs/btrfs/4b74dc57-526c-42c0-882a-8be30e1b8933/read_policy
---
 fs/btrfs/sysfs.c   |  2 +-
 fs/btrfs/volumes.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++
 fs/btrfs/volumes.h |  2 ++
 3 files changed, 55 insertions(+), 1 deletion(-)
fs/btrfs/sysfs.c +1 -1
index d5d0717fd09a..501c216009fb 100644
@@ -1169,7 +1169,7 @@ static bool strmatch(const char *buffer, const char *string)
 	return false;
 }
 
-static const char * const btrfs_read_policy_name[] = { "pid" };
+static const char * const btrfs_read_policy_name[] = { "pid", "heuristic" };
 
 static ssize_t btrfs_read_policy_show(struct kobject *kobj,
 				      struct kobj_attribute *a, char *buf)
fs/btrfs/volumes.c +52 -0

64 lines not on this page · raw message

fs/btrfs/volumes.h +2 -0
index 0fe20eb4087a..c8a73722bf60 100644
@@ -277,6 +277,8 @@ enum btrfs_chunk_allocation_policy {
 enum btrfs_read_policy {
 	/* Use process PID to choose the stripe */
 	BTRFS_READ_POLICY_PID,
+	/* Find and use device with the lowest latency */
+	BTRFS_READ_POLICY_HEURISTIC,
 	BTRFS_NR_READ_POLICY,
 };
 
Signature · 1 line
2.33.1