bdev: Fix spdk_bdev_get_max_copy() for fallback case
As we recently fixed bdev_io_get_max_buf_len(), to get aligned length, spdk_bdev_get_buf_align() - 1 is correct. _bdev_get_block_size_with_md() considers both interleaved metadata and separate metadata cases. It is simpler to use _bdev_get_block_size_with_md(). The copy command fallback uses write command. As the write zeroes fallback does, bdev->write_unit_size should be considered. Fix all in this patch. Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Change-Id: I88fe1b250289f2bab7b541523e8be931eeb8150c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17899 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
c9f3613fcd
commit
5bced73616
@ -4707,20 +4707,18 @@ spdk_bdev_is_dif_check_enabled(const struct spdk_bdev *bdev,
|
|||||||
uint32_t
|
uint32_t
|
||||||
spdk_bdev_get_max_copy(const struct spdk_bdev *bdev)
|
spdk_bdev_get_max_copy(const struct spdk_bdev *bdev)
|
||||||
{
|
{
|
||||||
uint64_t alighed_length;
|
uint64_t aligned_length;
|
||||||
uint64_t max_copy_blocks;
|
uint64_t max_copy_blocks;
|
||||||
uint64_t temp_max_copy_blocks;
|
|
||||||
struct spdk_iobuf_opts opts;
|
struct spdk_iobuf_opts opts;
|
||||||
|
|
||||||
if (spdk_bdev_io_type_supported((struct spdk_bdev *)bdev, SPDK_BDEV_IO_TYPE_COPY)) {
|
if (spdk_bdev_io_type_supported((struct spdk_bdev *)bdev, SPDK_BDEV_IO_TYPE_COPY)) {
|
||||||
return bdev->max_copy;
|
return bdev->max_copy;
|
||||||
} else {
|
} else {
|
||||||
spdk_iobuf_get_opts(&opts);
|
spdk_iobuf_get_opts(&opts);
|
||||||
alighed_length = opts.large_bufsize - spdk_bdev_get_buf_align(bdev);
|
aligned_length = opts.large_bufsize - (spdk_bdev_get_buf_align(bdev) - 1);
|
||||||
temp_max_copy_blocks = spdk_bdev_is_md_separate(bdev) ?
|
max_copy_blocks = aligned_length / _bdev_get_block_size_with_md(bdev);
|
||||||
alighed_length / (bdev->blocklen + bdev->md_len) :
|
max_copy_blocks -= max_copy_blocks % bdev->write_unit_size;
|
||||||
alighed_length / bdev->blocklen;
|
|
||||||
max_copy_blocks = 1 << spdk_u64log2(temp_max_copy_blocks);
|
|
||||||
return max_copy_blocks;
|
return max_copy_blocks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user