/* * Common read path running under the zvol taskq context. This function * is responsible for copying the requested data out of the DMU and in to * a linux request structure. It then must signal the request queue with * an error code describing the result of the copy. */ static void zvol_read(void *arg) { struct request *req = (struct request *)arg; struct request_queue *q = req->q; zvol_state_t *zv = q->queuedata; uint64_t offset = blk_rq_pos(req) << 9; uint64_t size = blk_rq_bytes(req); int error; rl_t *rl; if (size == 0) { blk_end_request(req, 0, size); return; } rl = zfs_range_lock(&zv->zv_znode, offset, size, RL_READER); error = dmu_read_req(zv->zv_objset, ZVOL_OBJ, req); zfs_range_unlock(rl); /* convert checksum errors into IO errors */ if (error == ECKSUM) error = EIO; blk_end_request(req, -error, size); }
/* * Common read path running under the zvol taskq context. This function * is responsible for copying the requested data out of the DMU and in to * a linux request structure. It then must signal the request queue with * an error code describing the result of the copy. */ static void zvol_read(void *arg) { struct request *req = (struct request *)arg; struct request_queue *q = req->q; zvol_state_t *zv = q->queuedata; fstrans_cookie_t cookie = spl_fstrans_mark(); uint64_t offset = blk_rq_pos(req) << 9; uint64_t size = blk_rq_bytes(req); int error; rl_t *rl; if (size == 0) { error = 0; goto out; } rl = zfs_range_lock(&zv->zv_znode, offset, size, RL_READER); error = dmu_read_req(zv->zv_objset, ZVOL_OBJ, req); zfs_range_unlock(rl); /* convert checksum errors into IO errors */ if (error == ECKSUM) error = SET_ERROR(EIO); out: blk_end_request(req, -error, size); spl_fstrans_unmark(cookie); }