From be440c01c9ecd99a8885a0da71af8e1200ae887b Mon Sep 17 00:00:00 2001 From: Alexey Marchuk Date: Thu, 21 Oct 2021 10:28:48 +0300 Subject: [PATCH] raid: Report memory domains Use spdk_bdev_readv/writev_block_ext even when there is no ext opts passed by bdev layer Signed-off-by: Alexey Marchuk Change-Id: I0b9f17150cdba1a1023478bae745ab4438ea99bb Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10070 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki --- module/bdev/raid/bdev_raid.c | 37 +++++++++++++++++++ .../lib/bdev/raid/bdev_raid.c/bdev_raid_ut.c | 3 ++ 2 files changed, 40 insertions(+) diff --git a/module/bdev/raid/bdev_raid.c b/module/bdev/raid/bdev_raid.c index 10c1c1391..60607595b 100644 --- a/module/bdev/raid/bdev_raid.c +++ b/module/bdev/raid/bdev_raid.c @@ -3,6 +3,7 @@ * * Copyright (c) Intel Corporation. * All rights reserved. + * Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -679,6 +680,41 @@ raid_bdev_write_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx * spdk_json_write_object_end(w); } +static int +raid_bdev_get_memory_domains(void *ctx, struct spdk_memory_domain **domains, int array_size) +{ + struct raid_bdev *raid_bdev = ctx; + struct spdk_bdev *base_bdev; + uint32_t i; + int domains_count = 0, rc; + + /* First loop to get the number of memory domains */ + for (i = 0; i < raid_bdev->num_base_bdevs; i++) { + base_bdev = raid_bdev->base_bdev_info[i].bdev; + rc = spdk_bdev_get_memory_domains(base_bdev, NULL, 0); + if (rc < 0) { + return rc; + } + domains_count += rc; + } + + if (!domains || array_size < domains_count) { + return domains_count; + } + + for (i = 0; i < raid_bdev->num_base_bdevs; i++) { + base_bdev = raid_bdev->base_bdev_info[i].bdev; + rc = spdk_bdev_get_memory_domains(base_bdev, domains, array_size); + if (rc < 0) { + return rc; + } + domains += rc; + array_size -= rc; + } + + return domains_count; +} + /* g_raid_bdev_fn_table is the function table for raid bdev */ static const struct spdk_bdev_fn_table g_raid_bdev_fn_table = { .destruct = raid_bdev_destruct, @@ -687,6 +723,7 @@ static const struct spdk_bdev_fn_table g_raid_bdev_fn_table = { .get_io_channel = raid_bdev_get_io_channel, .dump_info_json = raid_bdev_dump_info_json, .write_config_json = raid_bdev_write_config_json, + .get_memory_domains = raid_bdev_get_memory_domains, }; /* diff --git a/test/unit/lib/bdev/raid/bdev_raid.c/bdev_raid_ut.c b/test/unit/lib/bdev/raid/bdev_raid.c/bdev_raid_ut.c index 8177f8dec..b9d6a1cba 100644 --- a/test/unit/lib/bdev/raid/bdev_raid.c/bdev_raid_ut.c +++ b/test/unit/lib/bdev/raid/bdev_raid.c/bdev_raid_ut.c @@ -139,6 +139,9 @@ DEFINE_STUB(spdk_json_write_null, int, (struct spdk_json_write_ctx *w), 0); DEFINE_STUB(spdk_strerror, const char *, (int errnum), NULL); DEFINE_STUB(spdk_bdev_queue_io_wait, int, (struct spdk_bdev *bdev, struct spdk_io_channel *ch, struct spdk_bdev_io_wait_entry *entry), 0); +DEFINE_STUB(spdk_bdev_get_memory_domains, int, (struct spdk_bdev *bdev, + struct spdk_memory_domain **domains, int array_size), 0); +DEFINE_STUB(spdk_bdev_get_name, const char *, (const struct spdk_bdev *bdev), "test_bdev"); struct spdk_io_channel * spdk_bdev_get_io_channel(struct spdk_bdev_desc *desc)