X-Git-Url: https://git.subgeniuskitty.com/xeon-phi-kernel-module/.git/blobdiff_plain/800f879a77716ad833d229ccc058e700c698b039..db10dc009b1dea6ccb377d4ecd2d0ecbb5548865:/host/vhost/mic_blk.c diff --git a/host/vhost/mic_blk.c b/host/vhost/mic_blk.c index 9ac2cb8..1d763d6 100644 --- a/host/vhost/mic_blk.c +++ b/host/vhost/mic_blk.c @@ -41,8 +41,8 @@ #include "vhost.h" #include "mic/mic_virtio.h" -#define SECTOR_SHIFT 9 -#define SECTOR_SIZE (1UL << SECTOR_SHIFT) +#define MIC_SECTOR_SHIFT 9 +#define MIC_SECTOR_SIZE (1UL << MIC_SECTOR_SHIFT) #define VIRTIO_BLK_QUEUE_SIZE 128 #define DISK_SEG_MAX (VIRTIO_BLK_QUEUE_SIZE - 2) @@ -116,6 +116,7 @@ static void handle_io_work(struct work_struct *work) struct vhost_blk *blk; struct list_head single, *head, *node, *tmp; struct iovec *iov; + struct iov_iter iter; uint8_t *aper_va; struct vring *vring; unsigned int num; @@ -127,7 +128,7 @@ static void handle_io_work(struct work_struct *work) vbio = container_of(work, struct vhost_blk_io, work); blk = vbio->blk; vq = &blk->dev.vqs[0]; - pos = vbio->sector << SECTOR_SHIFT; + pos = vbio->sector << MIC_SECTOR_SHIFT; aper_va = blk->bd_info->bi_ctx.aper.va; vring = &((struct mic_virtblk *)blk->bd_info->bi_virtio)->vb_shared.vring; @@ -150,15 +151,17 @@ static void handle_io_work(struct work_struct *work) ret = vfs_fsync(vbio->file, 1); #endif } else if (vbio->type & VIRTIO_BLK_T_OUT) { - for (iov = vbio->iov; iov < &vbio->iov[vbio->nvecs]; iov++) { - iov->iov_base = mic_addr_in_host(aper_va, iov->iov_base); - } - ret = vfs_writev(vbio->file, vbio->iov, vbio->nvecs, &pos); + for (iov = vbio->iov; iov < &vbio->iov[vbio->nvecs]; iov++) { + iov->iov_base = mic_addr_in_host(aper_va, iov->iov_base); + } + iov_iter_init(&iter, WRITE, vbio->iov, vbio->nvecs, iov_length(vbio->iov, vbio->nvecs)); + ret = vfs_iter_write(vbio->file, &iter, &pos, 0); } else { - for (iov = vbio->iov; iov < &vbio->iov[vbio->nvecs]; iov++) { - iov->iov_base = mic_addr_in_host(aper_va, iov->iov_base); - } - ret = vfs_readv(vbio->file, vbio->iov, vbio->nvecs, &pos); + for (iov = vbio->iov; iov < &vbio->iov[vbio->nvecs]; iov++) { + iov->iov_base = mic_addr_in_host(aper_va, iov->iov_base); + } + iov_iter_init(&iter, READ, vbio->iov, vbio->nvecs, iov_length(vbio->iov, vbio->nvecs)); + ret = vfs_iter_read(vbio->file, &iter, &pos, 0); } status = (ret < 0) ? VIRTIO_BLK_S_IOERR : VIRTIO_BLK_S_OK; if (vbio->head != -1) { @@ -258,7 +261,7 @@ static void start_io(struct list_head *queue) vbio = entry; continue; } - if (vbio->sector + (vbio->len >> SECTOR_SHIFT) == entry->sector) { + if (vbio->sector + (vbio->len >> MIC_SECTOR_SHIFT) == entry->sector) { vbio = entry; } else { INIT_LIST_HEAD(&start); @@ -473,22 +476,17 @@ static long vhost_blk_set_backend(struct vhost_blk *vblk) #endif writel(virtio_blk_features, &vb_shared->host_features); writel(DISK_SEG_MAX, &vb_shared->blk_config.seg_max); - writel(SECTOR_SIZE, &vb_shared->blk_config.blk_size); + writel(MIC_SECTOR_SIZE, &vb_shared->blk_config.blk_size); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) - ret = vfs_getattr(&vblk->virtblk_file->f_path, &stat); -#else - ret = vfs_getattr(vblk->virtblk_file->f_path.mnt, - vblk->virtblk_file->f_path.dentry, &stat); -#endif + ret = vfs_getattr(&vblk->virtblk_file->f_path, &stat, STATX_BASIC_STATS, AT_STATX_SYNC_AS_STAT); if (ret < 0) goto _exit_; if (S_ISBLK(stat.mode)) { - writel(i_size_read(I_BDEV(vblk->virtblk_file->f_mapping->host)->bd_inode) / SECTOR_SIZE, + writel(i_size_read(I_BDEV(vblk->virtblk_file->f_mapping->host)->bd_inode) / MIC_SECTOR_SIZE, &vb_shared->blk_config.capacity); } else { - writel(stat.size / SECTOR_SIZE, &vb_shared->blk_config.capacity); + writel(stat.size / MIC_SECTOR_SIZE, &vb_shared->blk_config.capacity); } ret = mic_reg_irqhandler(&bd_info->bi_ctx, MIC_IRQ_DB2, "Host DoorBell 2",