From 4bb9240e6350ec3e176decc8383082b188265fa8 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 24 Feb 2019 05:36:46 +0000 Subject: [PATCH] vdisk_fileio, async mode: Switch from kvec to bvec This patch does not change any functionality. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7985 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 47 +++++++++++++++--------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index b5baa00a3..4494720c8 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -266,9 +266,9 @@ struct vdisk_cmd_params { struct iovec small_iv[4]; } sync; struct { - struct kiocb iocb; - struct kvec *kvec; - struct kvec small_kvec[4]; + struct kiocb iocb; + struct bio_vec *bvec; + struct bio_vec small_bvec[4]; } async; }; struct scst_cmd *cmd; @@ -3192,20 +3192,20 @@ static bool do_fileio_async(const struct vdisk_cmd_params *p) } } -static bool vdisk_alloc_kvec(struct scst_cmd *cmd, struct vdisk_cmd_params *p) +static bool vdisk_alloc_bvec(struct scst_cmd *cmd, struct vdisk_cmd_params *p) { int n; n = scst_get_buf_count(cmd); - if (n <= ARRAY_SIZE(p->async.small_kvec)) { - p->async.kvec = &p->async.small_kvec[0]; + if (n <= ARRAY_SIZE(p->async.small_bvec)) { + p->async.bvec = &p->async.small_bvec[0]; return true; } - p->async.kvec = kmalloc_array(n, sizeof(*p->async.kvec), + p->async.bvec = kmalloc_array(n, sizeof(*p->async.bvec), cmd->cmd_gfp_mask); - if (p->async.kvec == NULL) { - PRINT_ERROR("Unable to allocate kvecv (%d)", n); + if (p->async.bvec == NULL) { + PRINT_ERROR("Unable to allocate bvec (%d)", n); return false; } @@ -3253,10 +3253,10 @@ static enum compl_status_e fileio_exec_async(struct vdisk_cmd_params *p) struct file *fd = virt_dev->fd; struct iov_iter iter = { }; ssize_t length, total = 0; - struct kvec *kvec; + struct bio_vec *bvec; + struct page *page; struct kiocb *iocb = &p->async.iocb; - uint8_t *address; - int dir, ret; + int offset, sg_cnt = 0, dir, ret; switch (cmd->data_direction) { case SCST_DATA_READ: @@ -3270,31 +3270,32 @@ static enum compl_status_e fileio_exec_async(struct vdisk_cmd_params *p) return CMD_FAILED; } - if (!vdisk_alloc_kvec(cmd, p)) { + if (!vdisk_alloc_bvec(cmd, p)) { scst_set_busy(cmd); return CMD_SUCCEEDED; } p->execute_async = true; - kvec = p->async.kvec; - length = scst_get_buf_first(cmd, &address); + bvec = p->async.bvec; + length = scst_get_sg_page_first(cmd, &page, &offset); while (length) { - *kvec++ = (struct kvec){ - .iov_base = address, - .iov_len = length, + *bvec++ = (struct bio_vec){ + .bv_page = page, + .bv_offset = offset, + .bv_len = length, }; total += length; - length = scst_get_buf_next(cmd, &address); + sg_cnt++; + length = scst_get_sg_page_next(cmd, &page, &offset); } - WARN_ON_ONCE(kvec - p->async.kvec != scst_get_buf_count(cmd)); + WARN_ON_ONCE(sg_cnt != scst_get_buf_count(cmd)); #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0) - iov_iter_kvec(&iter, dir, p->async.kvec, kvec - p->async.kvec, total); + iov_iter_bvec(&iter, dir, p->async.bvec, sg_cnt, total); #else - iov_iter_kvec(&iter, ITER_KVEC | dir, p->async.kvec, - kvec - p->async.kvec, total); + iov_iter_bvec(&iter, ITER_BVEC | dir, p->async.bvec, sg_cnt, total); #endif *iocb = (struct kiocb) { .ki_pos = p->loff,