usr/src/lib/libzpool/common/kernel.c
changeset 13700 2889e2596bd6
parent 13682 e7836650181b
child 13743 95aba6e49b9f
equal deleted inserted replaced
13699:733714f4dc24 13700:2889e2596bd6
   424 	} else {
   424 	} else {
   425 		/*
   425 		/*
   426 		 * To simulate partial disk writes, we split writes into two
   426 		 * To simulate partial disk writes, we split writes into two
   427 		 * system calls so that the process can be killed in between.
   427 		 * system calls so that the process can be killed in between.
   428 		 */
   428 		 */
   429 		split = (len > 0 ? rand() % len : 0);
   429 		int sectors = len >> SPA_MINBLOCKSHIFT;
       
   430 		split = (sectors > 0 ? rand() % sectors : 0) <<
       
   431 		    SPA_MINBLOCKSHIFT;
   430 		iolen = pwrite64(vp->v_fd, addr, split, offset);
   432 		iolen = pwrite64(vp->v_fd, addr, split, offset);
   431 		iolen += pwrite64(vp->v_fd, (char *)addr + split,
   433 		iolen += pwrite64(vp->v_fd, (char *)addr + split,
   432 		    len - split, offset + split);
   434 		    len - split, offset + split);
   433 	}
   435 	}
   434 
   436