409 
 410         umem_free(realpath, strlen(path) + 2);
 411 
 412         return (ret);
 413 }
 414 
 415 /*ARGSUSED*/
 416 int
 417 vn_rdwr(int uio, vnode_t *vp, void *addr, ssize_t len, offset_t offset,
 418         int x1, int x2, rlim64_t x3, void *x4, ssize_t *residp)
 419 {
 420         ssize_t iolen, split;
 421 
 422         if (uio == UIO_READ) {
 423                 iolen = pread64(vp->v_fd, addr, len, offset);
 424         } else {
 425                 /*
 426                  * To simulate partial disk writes, we split writes into two
 427                  * system calls so that the process can be killed in between.
 428                  */
 429                 split = (len > 0 ? rand() % len : 0);
 430                 iolen = pwrite64(vp->v_fd, addr, split, offset);
 431                 iolen += pwrite64(vp->v_fd, (char *)addr + split,
 432                     len - split, offset + split);
 433         }
 434 
 435         if (iolen == -1)
 436                 return (errno);
 437         if (residp)
 438                 *residp = len - iolen;
 439         else if (iolen != len)
 440                 return (EIO);
 441         return (0);
 442 }
 443 
 444 void
 445 vn_close(vnode_t *vp)
 446 {
 447         close(vp->v_fd);
 448         spa_strfree(vp->v_path);
 449         umem_free(vp, sizeof (vnode_t));
 
 | 
 
 
 409 
 410         umem_free(realpath, strlen(path) + 2);
 411 
 412         return (ret);
 413 }
 414 
 415 /*ARGSUSED*/
 416 int
 417 vn_rdwr(int uio, vnode_t *vp, void *addr, ssize_t len, offset_t offset,
 418         int x1, int x2, rlim64_t x3, void *x4, ssize_t *residp)
 419 {
 420         ssize_t iolen, split;
 421 
 422         if (uio == UIO_READ) {
 423                 iolen = pread64(vp->v_fd, addr, len, offset);
 424         } else {
 425                 /*
 426                  * To simulate partial disk writes, we split writes into two
 427                  * system calls so that the process can be killed in between.
 428                  */
 429                 int sectors = len >> SPA_MINBLOCKSHIFT;
 430                 split = (sectors > 0 ? rand() % sectors : 0) <<
 431                     SPA_MINBLOCKSHIFT;
 432                 iolen = pwrite64(vp->v_fd, addr, split, offset);
 433                 iolen += pwrite64(vp->v_fd, (char *)addr + split,
 434                     len - split, offset + split);
 435         }
 436 
 437         if (iolen == -1)
 438                 return (errno);
 439         if (residp)
 440                 *residp = len - iolen;
 441         else if (iolen != len)
 442                 return (EIO);
 443         return (0);
 444 }
 445 
 446 void
 447 vn_close(vnode_t *vp)
 448 {
 449         close(vp->v_fd);
 450         spa_strfree(vp->v_path);
 451         umem_free(vp, sizeof (vnode_t));
 
 |