svn commit: r278999 - stable/10/sys/cam/ctl
Alexander Motin
mav at FreeBSD.org
Thu Feb 19 13:06:40 UTC 2015
Author: mav
Date: Thu Feb 19 13:06:38 2015
New Revision: 278999
URL: https://svnweb.freebsd.org/changeset/base/278999
Log:
MFC r278619: Make WRITE SAME commands respect physical block size.
This change by 2-3 times improves performance of misaligned WRITE SAME
commands by avoiding unneeded read-modify-write cycles inside ZFS.
Modified:
stable/10/sys/cam/ctl/ctl_backend_block.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/cam/ctl/ctl_backend_block.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_backend_block.c Thu Feb 19 12:47:48 2015 (r278998)
+++ stable/10/sys/cam/ctl/ctl_backend_block.c Thu Feb 19 13:06:38 2015 (r278999)
@@ -1190,7 +1190,7 @@ ctl_be_block_cw_dispatch_ws(struct ctl_b
struct ctl_be_block_io *beio;
struct ctl_be_block_softc *softc;
struct ctl_lba_len_flags *lbalen;
- uint64_t len_left, lba;
+ uint64_t len_left, lba, pb, pbo, adj;
int i, seglen;
uint8_t *buf, *end;
@@ -1244,6 +1244,8 @@ ctl_be_block_cw_dispatch_ws(struct ctl_b
DPRINTF("WRITE SAME at LBA %jx len %u\n",
(uintmax_t)lbalen->lba, lbalen->len);
+ pb = (uint64_t)be_lun->blocksize << be_lun->pblockexp;
+ pbo = pb - (uint64_t)be_lun->blocksize * be_lun->pblockoff;
len_left = (uint64_t)lbalen->len * be_lun->blocksize;
for (i = 0, lba = 0; i < CTLBLK_MAX_SEGS && len_left > 0; i++) {
@@ -1251,7 +1253,15 @@ ctl_be_block_cw_dispatch_ws(struct ctl_b
* Setup the S/G entry for this chunk.
*/
seglen = MIN(CTLBLK_MAX_SEG, len_left);
- seglen -= seglen % be_lun->blocksize;
+ if (pb > be_lun->blocksize) {
+ adj = ((lbalen->lba + lba) * be_lun->blocksize +
+ seglen - pbo) % pb;
+ if (seglen > adj)
+ seglen -= adj;
+ else
+ seglen -= seglen % be_lun->blocksize;
+ } else
+ seglen -= seglen % be_lun->blocksize;
beio->sg_segs[i].len = seglen;
beio->sg_segs[i].addr = uma_zalloc(be_lun->lun_zone, M_WAITOK);
More information about the svn-src-stable-10
mailing list