Commit 9e647c1f authored by Konrad Sztyber's avatar Konrad Sztyber
Browse files

bdev: disallow get_buf() calls from other threads



This is unsafe, because we touch need_buf_* queues, which aren't
thread-safe.  Also, documented this requirement in
spdk_bdev_io_get_buf()'s description.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Iabc141e051c543fdd51f079ae212f69e980d8148
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15668


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent 533470b2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -968,7 +968,8 @@ const struct spdk_bdev_aliases_list *spdk_bdev_get_aliases(const struct spdk_bde
 * callback on read path.  The buffer will be freed automatically
 * on \c spdk_bdev_free_io() call. This call will never fail.
 * In case of lack of memory given callback \c cb will be deferred
 * until enough memory is freed.
 * until enough memory is freed.  This function *must* be called
 * from the thread issuing \c bdev_io.
 *
 * \param bdev_io I/O to allocate buffer for.
 * \param cb callback to be called when the buffer is allocated
+1 −0
Original line number Diff line number Diff line
@@ -1227,6 +1227,7 @@ bdev_io_get_buf(struct spdk_bdev_io *bdev_io, uint64_t len)
	uint64_t alignment, md_len;
	void *buf;

	assert(spdk_bdev_io_get_thread(bdev_io) == spdk_get_thread());
	alignment = spdk_bdev_get_buf_align(bdev);
	md_len = spdk_bdev_is_md_separate(bdev) ? bdev_io->u.bdev.num_blocks * bdev->md_len : 0;