168 vnode_t *vp = bp->b_private;
169 ssize_t resid;
170 int error;
171
172 error = vn_rdwr((bp->b_flags & B_READ) ? UIO_READ : UIO_WRITE,
173 vp, bp->b_un.b_addr, bp->b_bcount, ldbtob(bp->b_lblkno),
174 UIO_SYSSPACE, 0, RLIM64_INFINITY, kcred, &resid);
175
176 if (error == 0) {
177 bp->b_resid = resid;
178 biodone(bp);
179 } else {
180 bioerror(bp, error);
181 biodone(bp);
182 }
183 }
184
185 static int
186 vdev_file_io_start(zio_t *zio)
187 {
188 spa_t *spa = zio->io_spa;
189 vdev_t *vd = zio->io_vd;
190 vdev_file_t *vf = vd->vdev_tsd;
191 vdev_buf_t *vb;
192 buf_t *bp;
193
194 if (zio->io_type == ZIO_TYPE_IOCTL) {
195 /* XXPOLICY */
196 if (!vdev_readable(vd)) {
197 zio->io_error = SET_ERROR(ENXIO);
198 return (ZIO_PIPELINE_CONTINUE);
199 }
200
201 switch (zio->io_cmd) {
202 case DKIOCFLUSHWRITECACHE:
203 zio->io_error = VOP_FSYNC(vf->vf_vnode, FSYNC | FDSYNC,
204 kcred, NULL);
205 break;
206 default:
207 zio->io_error = SET_ERROR(ENOTSUP);
208 }
209
210 return (ZIO_PIPELINE_CONTINUE);
211 }
212
213 vb = kmem_alloc(sizeof (vdev_buf_t), KM_SLEEP);
214
215 vb->vb_io = zio;
216 bp = &vb->vb_buf;
217
218 bioinit(bp);
219 bp->b_flags = (zio->io_type == ZIO_TYPE_READ ? B_READ : B_WRITE);
220 bp->b_bcount = zio->io_size;
221 bp->b_un.b_addr = zio->io_data;
222 bp->b_lblkno = lbtodb(zio->io_offset);
223 bp->b_bufsize = zio->io_size;
224 bp->b_private = vf->vf_vnode;
225 bp->b_iodone = (int (*)())vdev_file_io_intr;
226
227 spa_taskq_dispatch_ent(spa, ZIO_TYPE_FREE, ZIO_TASKQ_ISSUE,
228 vdev_file_io_strategy, bp, 0, &zio->io_tqent);
229
230 return (ZIO_PIPELINE_STOP);
231 }
232
233 /* ARGSUSED */
234 static void
235 vdev_file_io_done(zio_t *zio)
236 {
237 }
238
239 vdev_ops_t vdev_file_ops = {
240 vdev_file_open,
241 vdev_file_close,
242 vdev_default_asize,
243 vdev_file_io_start,
244 vdev_file_io_done,
245 NULL,
246 vdev_file_hold,
247 vdev_file_rele,
248 VDEV_TYPE_FILE, /* name of this vdev type */
|
168 vnode_t *vp = bp->b_private;
169 ssize_t resid;
170 int error;
171
172 error = vn_rdwr((bp->b_flags & B_READ) ? UIO_READ : UIO_WRITE,
173 vp, bp->b_un.b_addr, bp->b_bcount, ldbtob(bp->b_lblkno),
174 UIO_SYSSPACE, 0, RLIM64_INFINITY, kcred, &resid);
175
176 if (error == 0) {
177 bp->b_resid = resid;
178 biodone(bp);
179 } else {
180 bioerror(bp, error);
181 biodone(bp);
182 }
183 }
184
185 static int
186 vdev_file_io_start(zio_t *zio)
187 {
188 vdev_t *vd = zio->io_vd;
189 vdev_file_t *vf = vd->vdev_tsd;
190 vdev_buf_t *vb;
191 buf_t *bp;
192
193 if (zio->io_type == ZIO_TYPE_IOCTL) {
194 /* XXPOLICY */
195 if (!vdev_readable(vd)) {
196 zio->io_error = SET_ERROR(ENXIO);
197 return (ZIO_PIPELINE_CONTINUE);
198 }
199
200 switch (zio->io_cmd) {
201 case DKIOCFLUSHWRITECACHE:
202 zio->io_error = VOP_FSYNC(vf->vf_vnode, FSYNC | FDSYNC,
203 kcred, NULL);
204 break;
205 default:
206 zio->io_error = SET_ERROR(ENOTSUP);
207 }
208
209 return (ZIO_PIPELINE_CONTINUE);
210 }
211
212 vb = kmem_alloc(sizeof (vdev_buf_t), KM_SLEEP);
213
214 vb->vb_io = zio;
215 bp = &vb->vb_buf;
216
217 bioinit(bp);
218 bp->b_flags = (zio->io_type == ZIO_TYPE_READ ? B_READ : B_WRITE);
219 bp->b_bcount = zio->io_size;
220 bp->b_un.b_addr = zio->io_data;
221 bp->b_lblkno = lbtodb(zio->io_offset);
222 bp->b_bufsize = zio->io_size;
223 bp->b_private = vf->vf_vnode;
224 bp->b_iodone = (int (*)())vdev_file_io_intr;
225
226 VERIFY3U(taskq_dispatch(system_taskq, vdev_file_io_strategy, bp,
227 TQ_SLEEP), !=, 0);
228
229 return (ZIO_PIPELINE_STOP);
230 }
231
232 /* ARGSUSED */
233 static void
234 vdev_file_io_done(zio_t *zio)
235 {
236 }
237
238 vdev_ops_t vdev_file_ops = {
239 vdev_file_open,
240 vdev_file_close,
241 vdev_default_asize,
242 vdev_file_io_start,
243 vdev_file_io_done,
244 NULL,
245 vdev_file_hold,
246 vdev_file_rele,
247 VDEV_TYPE_FILE, /* name of this vdev type */
|