diff mbox series

[RFC,1/7] block: export part_stat_read_all

Message ID 047fe87c52b64caf1bd09eee4b1ca5130062a885.1603751876.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series [RFC,1/7] block: export part_stat_read_all | expand

Commit Message

Anand Jain Oct. 26, 2020, 11:55 p.m. UTC
For mirrored raid profiles such as raid1, raid1c3, raid1c4, and raid10,
currently, btrfs use the PID method to determine which one of the
mirrored devices to use to read the block. However, the PID method is
not the best choice if the devices are heterogeneous in terms of type,
speed, and size, as we may end up reading from the slower device.

Export the function part_stat_read_all() so that the btrfs can determine
the device with the least average wait time to use.

Cc: linux-block@vger.kernel.org
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 block/genhd.c         | 3 ++-
 include/linux/genhd.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Josef Bacik Oct. 27, 2020, 6:09 p.m. UTC | #1
On 10/26/20 7:55 PM, Anand Jain wrote:
> For mirrored raid profiles such as raid1, raid1c3, raid1c4, and raid10,
> currently, btrfs use the PID method to determine which one of the
> mirrored devices to use to read the block. However, the PID method is
> not the best choice if the devices are heterogeneous in terms of type,
> speed, and size, as we may end up reading from the slower device.
> 
> Export the function part_stat_read_all() so that the btrfs can determine
> the device with the least average wait time to use.
> 
> Cc: linux-block@vger.kernel.org
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

You don't need this, it can be accomplished with part_stat_read, or any variety 
of the helpers in part_stat.h.  Thanks,

Josef
Anand Jain Oct. 28, 2020, 8:26 a.m. UTC | #2
On 28/10/20 2:09 am, Josef Bacik wrote:
> On 10/26/20 7:55 PM, Anand Jain wrote:
>> For mirrored raid profiles such as raid1, raid1c3, raid1c4, and raid10,
>> currently, btrfs use the PID method to determine which one of the
>> mirrored devices to use to read the block. However, the PID method is
>> not the best choice if the devices are heterogeneous in terms of type,
>> speed, and size, as we may end up reading from the slower device.
>>
>> Export the function part_stat_read_all() so that the btrfs can determine
>> the device with the least average wait time to use.
>>
>> Cc: linux-block@vger.kernel.org
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> 
> You don't need this, it can be accomplished with part_stat_read, or any 
> variety of the helpers in part_stat.h.  Thanks,

Oh. I have missed #define part_stat_read. It works for now.
We don't have to export part_stat_read_all() as in this patch.

Sorry for the noise.

Thanks, Anand

> 
> Josef
diff mbox series

Patch

diff --git a/block/genhd.c b/block/genhd.c
index 0a273211fec2..81b10b90de71 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -89,7 +89,7 @@  const char *bdevname(struct block_device *bdev, char *buf)
 }
 EXPORT_SYMBOL(bdevname);
 
-static void part_stat_read_all(struct hd_struct *part, struct disk_stats *stat)
+void part_stat_read_all(struct hd_struct *part, struct disk_stats *stat)
 {
 	int cpu;
 
@@ -108,6 +108,7 @@  static void part_stat_read_all(struct hd_struct *part, struct disk_stats *stat)
 		stat->io_ticks += ptr->io_ticks;
 	}
 }
+EXPORT_SYMBOL_GPL(part_stat_read_all);
 
 static unsigned int part_in_flight(struct hd_struct *part)
 {
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 38f23d757013..eb77e0ac8a82 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -281,6 +281,7 @@  struct disk_part_iter {
 	unsigned int		flags;
 };
 
+extern void part_stat_read_all(struct hd_struct *part, struct disk_stats *stat);
 extern void disk_part_iter_init(struct disk_part_iter *piter,
 				 struct gendisk *disk, unsigned int flags);
 extern struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter);