mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:04:41 +01:00
Under heavy concurrent flush traffic, virtio-pmem can overflow its request
virtqueue (req_vq): virtqueue_add_sgs() starts returning -ENOSPC and the
driver logs "no free slots in the virtqueue". Shortly after that the
device enters VIRTIO_CONFIG_S_NEEDS_RESET and flush requests fail with
"virtio pmem device needs a reset".
Serialize virtio_pmem_flush() with a per-device mutex so only one flush
request is in-flight at a time. This prevents req_vq descriptor overflow
under high concurrency.
Reproducer (guest with virtio-pmem):
- mkfs.ext4 -F /dev/pmem0
- mount -t ext4 -o dax,noatime /dev/pmem0 /mnt/bench
- fio: ioengine=io_uring rw=randwrite bs=4k iodepth=64 numjobs=64
direct=1 fsync=1 runtime=30s time_based=1
- dmesg: "no free slots in the virtqueue"
"virtio pmem device needs a reset"
Fixes: 6e84200c0a ("virtio-pmem: Add virtio pmem driver")
Signed-off-by: Li Chen <me@linux.beauty>
Acked-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Link: https://patch.msgid.link/20260203021353.121091-1-me@linux.beauty
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
59 lines
1.4 KiB
C
59 lines
1.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* virtio_pmem.h: virtio pmem Driver
|
|
*
|
|
* Discovers persistent memory range information
|
|
* from host and provides a virtio based flushing
|
|
* interface.
|
|
**/
|
|
|
|
#ifndef _LINUX_VIRTIO_PMEM_H
|
|
#define _LINUX_VIRTIO_PMEM_H
|
|
|
|
#include <linux/module.h>
|
|
#include <uapi/linux/virtio_pmem.h>
|
|
#include <linux/libnvdimm.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/spinlock.h>
|
|
|
|
struct virtio_pmem_request {
|
|
struct virtio_pmem_req req;
|
|
struct virtio_pmem_resp resp;
|
|
|
|
/* Wait queue to process deferred work after ack from host */
|
|
wait_queue_head_t host_acked;
|
|
bool done;
|
|
|
|
/* Wait queue to process deferred work after virt queue buffer avail */
|
|
wait_queue_head_t wq_buf;
|
|
bool wq_buf_avail;
|
|
struct list_head list;
|
|
};
|
|
|
|
struct virtio_pmem {
|
|
struct virtio_device *vdev;
|
|
|
|
/* Virtio pmem request queue */
|
|
struct virtqueue *req_vq;
|
|
|
|
/* Serialize flush requests to the device. */
|
|
struct mutex flush_lock;
|
|
|
|
/* nvdimm bus registers virtio pmem device */
|
|
struct nvdimm_bus *nvdimm_bus;
|
|
struct nvdimm_bus_descriptor nd_desc;
|
|
|
|
/* List to store deferred work if virtqueue is full */
|
|
struct list_head req_list;
|
|
|
|
/* Synchronize virtqueue data */
|
|
spinlock_t pmem_lock;
|
|
|
|
/* Memory region information */
|
|
__u64 start;
|
|
__u64 size;
|
|
};
|
|
|
|
void virtio_pmem_host_ack(struct virtqueue *vq);
|
|
int async_pmem_flush(struct nd_region *nd_region, struct bio *bio);
|
|
#endif
|