Skip to content

Commit

Permalink
bdev/nvme: set max_num_segments based on controller limit
Browse files Browse the repository at this point in the history
Fixes issue spdk#3269.

Signed-off-by: Jim Harris <[email protected]>
Change-Id: I48f8ef47841123c451421c53ad68714eff26722c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21952
Tested-by: SPDK CI Jenkins <[email protected]>
Reviewed-by: Konrad Sztyber <[email protected]>
Reviewed-by: Shuhei Matsumoto <[email protected]>
Community-CI: Mellanox Build Bot
  • Loading branch information
jimharris authored and ksztyber committed Feb 26, 2024
1 parent 6f3e277 commit e3367a2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions module/bdev/nvme/bdev_nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -4046,6 +4046,21 @@ nvme_disk_create(struct spdk_bdev *disk, const char *base_name,
if (opts && opts->io_queue_requests) {
disk->max_num_segments = opts->io_queue_requests / 2;
}
if (spdk_nvme_ctrlr_get_flags(ctrlr) & SPDK_NVME_CTRLR_SGL_SUPPORTED) {
/* The nvme driver will try to split I/O that have too many
* SGEs, but it doesn't work if that last SGE doesn't end on
* an aggregate total that is block aligned. The bdev layer has
* a more robust splitting framework, so use that instead for
* this case. (See issue #3269.)
*/
uint16_t max_sges = spdk_nvme_ctrlr_get_max_sges(ctrlr);

if (disk->max_num_segments == 0) {
disk->max_num_segments = max_sges;
} else {
disk->max_num_segments = spdk_min(disk->max_num_segments, max_sges);
}
}
disk->optimal_io_boundary = spdk_nvme_ns_get_optimal_io_boundary(ns);

nguid = spdk_nvme_ns_get_nguid(ns);
Expand Down
1 change: 1 addition & 0 deletions test/unit/lib/bdev/nvme/bdev_nvme.c/bdev_nvme_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ DEFINE_STUB_V(spdk_nvme_ctrlr_set_remove_cb, (struct spdk_nvme_ctrlr *ctrlr,
spdk_nvme_remove_cb remove_cb, void *remove_ctx));

DEFINE_STUB(spdk_nvme_ctrlr_get_flags, uint64_t, (struct spdk_nvme_ctrlr *ctrlr), 0);
DEFINE_STUB(spdk_nvme_ctrlr_get_max_sges, uint16_t, (const struct spdk_nvme_ctrlr *ctrlr), 0);

DEFINE_STUB(accel_channel_create, int, (void *io_device, void *ctx_buf), 0);
DEFINE_STUB_V(accel_channel_destroy, (void *io_device, void *ctx_buf));
Expand Down

0 comments on commit e3367a2

Please sign in to comment.