diff options
author | Klaus Jensen | 2021-01-19 23:01:02 +0100 |
---|---|---|
committer | Klaus Jensen | 2021-03-09 11:00:57 +0100 |
commit | b0a79429d964ad2d8c1c41fdc18b3ae5def41ff8 (patch) | |
tree | 89f0d70ec3999263b0fd1d820dd34b78e6ee8d41 | |
parent | hw/block/nvme: refactor zone resource management (diff) | |
download | qemu-b0a79429d964ad2d8c1c41fdc18b3ae5def41ff8.tar.gz qemu-b0a79429d964ad2d8c1c41fdc18b3ae5def41ff8.tar.xz qemu-b0a79429d964ad2d8c1c41fdc18b3ae5def41ff8.zip |
hw/block/nvme: pull write pointer advancement to separate function
In preparation for Simple Copy, pull write pointer advancement into a
separate function that is independent off an NvmeRequest.
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
-rw-r--r-- | hw/block/nvme.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 7897390b6d..44129f8e8b 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1407,6 +1407,16 @@ static inline uint16_t nvme_zrm_open(NvmeNamespace *ns, NvmeZone *zone) return __nvme_zrm_open(ns, zone, false); } +static void __nvme_advance_zone_wp(NvmeNamespace *ns, NvmeZone *zone, + uint32_t nlb) +{ + zone->d.wp += nlb; + + if (zone->d.wp == nvme_zone_wr_boundary(zone)) { + nvme_zrm_finish(ns, zone); + } +} + static void nvme_finalize_zoned_write(NvmeNamespace *ns, NvmeRequest *req) { NvmeRwCmd *rw = (NvmeRwCmd *)&req->cmd; @@ -1418,11 +1428,7 @@ static void nvme_finalize_zoned_write(NvmeNamespace *ns, NvmeRequest *req) nlb = le16_to_cpu(rw->nlb) + 1; zone = nvme_get_zone_by_slba(ns, slba); - zone->d.wp += nlb; - - if (zone->d.wp == nvme_zone_wr_boundary(zone)) { - nvme_zrm_finish(ns, zone); - } + __nvme_advance_zone_wp(ns, zone, nlb); } static inline bool nvme_is_write(NvmeRequest *req) |