Lines Matching refs:vdev_blk

52     VubDev *vdev_blk;  member
87 VubDev *vdev_blk; in vub_panic_cb() local
92 vdev_blk = container_of(gdev, VubDev, parent); in vub_panic_cb()
97 g_main_loop_quit(vdev_blk->loop); in vub_panic_cb()
102 VugDev *gdev = &req->vdev_blk->parent; in vub_req_complete()
136 VubDev *vdev_blk = req->vdev_blk; in vub_readv() local
145 rc = preadv(vdev_blk->blk_fd, iov, iovcnt, req->sector_num * 512); in vub_readv()
148 vdev_blk->blk_name, req->sector_num, req->size, in vub_readv()
159 VubDev *vdev_blk = req->vdev_blk; in vub_writev() local
168 rc = pwritev(vdev_blk->blk_fd, iov, iovcnt, req->sector_num * 512); in vub_writev()
171 vdev_blk->blk_name, req->sector_num, req->size, in vub_writev()
196 VubDev *vdev_blk = req->vdev_blk; in vub_discard_write_zeroes() local
201 if (ioctl(vdev_blk->blk_fd, BLKDISCARD, range) == 0) { in vub_discard_write_zeroes()
206 if (ioctl(vdev_blk->blk_fd, BLKZEROOUT, range) == 0) { in vub_discard_write_zeroes()
220 VubDev *vdev_blk = req->vdev_blk; in vub_flush() local
222 fdatasync(vdev_blk->blk_fd); in vub_flush()
225 static int vub_virtio_process_req(VubDev *vdev_blk, in vub_virtio_process_req() argument
228 VugDev *gdev = &vdev_blk->parent; in vub_virtio_process_req()
249 req->vdev_blk = vdev_blk; in vub_virtio_process_req()
334 VubDev *vdev_blk; in vub_process_vq() local
339 vdev_blk = container_of(gdev, VubDev, parent); in vub_process_vq()
340 assert(vdev_blk); in vub_process_vq()
346 ret = vub_virtio_process_req(vdev_blk, vq); in vub_process_vq()
368 VubDev *vdev_blk; in vub_get_features() local
371 vdev_blk = container_of(gdev, VubDev, parent); in vub_get_features()
384 if (vdev_blk->enable_ro) { in vub_get_features()
402 VubDev *vdev_blk; in vub_get_config() local
409 vdev_blk = container_of(gdev, VubDev, parent); in vub_get_config()
410 memcpy(config, &vdev_blk->blkcfg, len); in vub_get_config()
420 VubDev *vdev_blk; in vub_set_config() local
430 vdev_blk = container_of(gdev, VubDev, parent); in vub_set_config()
438 if (wce == vdev_blk->blkcfg.wce) { in vub_set_config()
443 vdev_blk->blkcfg.wce = wce; in vub_set_config()
445 if (vdev_blk->blk_fd >= 0) { in vub_set_config()
446 close(vdev_blk->blk_fd); in vub_set_config()
447 vdev_blk->blk_fd = -1; in vub_set_config()
450 fd = vub_open(vdev_blk->blk_name, wce); in vub_set_config()
452 fprintf(stderr, "Error to open block device %s\n", vdev_blk->blk_name); in vub_set_config()
453 vdev_blk->blk_fd = -1; in vub_set_config()
456 vdev_blk->blk_fd = fd; in vub_set_config()
504 static void vub_free(struct VubDev *vdev_blk) in vub_free() argument
506 if (!vdev_blk) { in vub_free()
510 g_main_loop_unref(vdev_blk->loop); in vub_free()
511 if (vdev_blk->blk_fd >= 0) { in vub_free()
512 close(vdev_blk->blk_fd); in vub_free()
514 g_free(vdev_blk); in vub_free()
556 VubDev *vdev_blk; in vub_new() local
558 vdev_blk = g_new0(VubDev, 1); in vub_new()
559 vdev_blk->loop = g_main_loop_new(NULL, FALSE); in vub_new()
560 vdev_blk->blk_fd = vub_open(blk_file, 0); in vub_new()
561 if (vdev_blk->blk_fd < 0) { in vub_new()
563 vub_free(vdev_blk); in vub_new()
566 vdev_blk->enable_ro = false; in vub_new()
567 vdev_blk->blkcfg.wce = 0; in vub_new()
568 vdev_blk->blk_name = blk_file; in vub_new()
571 vub_initialize_config(vdev_blk->blk_fd, &vdev_blk->blkcfg); in vub_new()
573 return vdev_blk; in vub_new()
599 VubDev *vdev_blk = NULL; in main() local
643 vdev_blk = vub_new(opt_blk_file); in main()
644 if (!vdev_blk) { in main()
648 vdev_blk->enable_ro = true; in main()
651 if (!vug_init(&vdev_blk->parent, VHOST_USER_BLK_MAX_QUEUES, csock, in main()
657 g_main_loop_run(vdev_blk->loop); in main()
658 g_main_loop_unref(vdev_blk->loop); in main()
660 vug_deinit(&vdev_blk->parent); in main()
661 vub_free(vdev_blk); in main()