bdev: Fix max write_zeroes calculation for fallback case
ZERO_BUFFER_SIZE is in bytes but it is easier to calculate max write_zeroes in blocks first and then get the minimum between max write_zeroes in blocks and remaining_num_blocks rather than converting remaining_num_blocks to num_bytes. This is helpful to store the result into bdev->max_write_zeroes for fallback case. We have one small fix in this patch. As we recently fixed bdev_io_get_max_buf_len(), to get aligned length, spdk_bdev_get_buf_align() - 1 is correct. Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Change-Id: I104bc837c9eee1303664bfdb3559b0e840d6f0e5 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17910 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
parent
0c1df53e7a
commit
2dcaa3851f
@ -8583,15 +8583,17 @@ static void
|
|||||||
bdev_write_zero_buffer_next(void *_bdev_io)
|
bdev_write_zero_buffer_next(void *_bdev_io)
|
||||||
{
|
{
|
||||||
struct spdk_bdev_io *bdev_io = _bdev_io;
|
struct spdk_bdev_io *bdev_io = _bdev_io;
|
||||||
uint64_t num_bytes, num_blocks;
|
uint64_t aligned_length, max_write_zeroes_blocks;
|
||||||
|
uint64_t num_blocks;
|
||||||
void *md_buf = NULL;
|
void *md_buf = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
num_bytes = spdk_min(_bdev_get_block_size_with_md(bdev_io->bdev) *
|
aligned_length = ZERO_BUFFER_SIZE - (spdk_bdev_get_buf_align(bdev_io->bdev) - 1);
|
||||||
bdev_io->u.bdev.split_remaining_num_blocks,
|
max_write_zeroes_blocks = aligned_length / _bdev_get_block_size_with_md(bdev_io->bdev);
|
||||||
ZERO_BUFFER_SIZE);
|
max_write_zeroes_blocks -= max_write_zeroes_blocks % bdev_io->bdev->write_unit_size;
|
||||||
num_blocks = num_bytes / _bdev_get_block_size_with_md(bdev_io->bdev);
|
|
||||||
num_blocks -= num_blocks % bdev_io->bdev->write_unit_size;
|
num_blocks = spdk_min(bdev_io->u.bdev.split_remaining_num_blocks,
|
||||||
|
max_write_zeroes_blocks);
|
||||||
|
|
||||||
if (spdk_bdev_is_md_separate(bdev_io->bdev)) {
|
if (spdk_bdev_is_md_separate(bdev_io->bdev)) {
|
||||||
md_buf = (char *)g_bdev_mgr.zero_buffer +
|
md_buf = (char *)g_bdev_mgr.zero_buffer +
|
||||||
|
Loading…
Reference in New Issue
Block a user