svn commit: r275920 - head/sys/cam/ctl
Alexander Motin
mav at FreeBSD.org
Thu Dec 18 22:32:24 UTC 2014
Author: mav
Date: Thu Dec 18 22:32:22 2014
New Revision: 275920
URL: https://svnweb.freebsd.org/changeset/base/275920
Log:
Pass real optimal transfer size supported by backend.
For files and ZVOLs that is 1MB now, not 128K.
MFC after: 1 week
Modified:
head/sys/cam/ctl/ctl.c
head/sys/cam/ctl/ctl_backend.h
head/sys/cam/ctl/ctl_backend_block.c
head/sys/cam/ctl/ctl_backend_ramdisk.c
Modified: head/sys/cam/ctl/ctl.c
==============================================================================
--- head/sys/cam/ctl/ctl.c Thu Dec 18 21:22:23 2014 (r275919)
+++ head/sys/cam/ctl/ctl.c Thu Dec 18 22:32:22 2014 (r275920)
@@ -10142,7 +10142,7 @@ ctl_inquiry_evpd_block_limits(struct ctl
scsi_ulto4b(0xffffffff, bl_ptr->max_txfer_len);
if (lun != NULL) {
bs = lun->be_lun->blocksize;
- scsi_ulto4b(MAXPHYS / bs, bl_ptr->opt_txfer_len);
+ scsi_ulto4b(lun->be_lun->opttxferlen, bl_ptr->opt_txfer_len);
if (lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) {
scsi_ulto4b(0xffffffff, bl_ptr->max_unmap_lba_cnt);
scsi_ulto4b(0xffffffff, bl_ptr->max_unmap_blk_cnt);
Modified: head/sys/cam/ctl/ctl_backend.h
==============================================================================
--- head/sys/cam/ctl/ctl_backend.h Thu Dec 18 21:22:23 2014 (r275919)
+++ head/sys/cam/ctl/ctl_backend.h Thu Dec 18 22:32:22 2014 (r275920)
@@ -146,10 +146,16 @@ typedef void (*be_lun_config_t)(void *be
*
* pblockexp is the log2() of number of LBAs on the LUN per physical sector.
*
- * pblockoff is the lowest LBA on the LUN aligned ot physical sector.
+ * pblockoff is the lowest LBA on the LUN aligned to physical sector.
+ *
+ * ublockexp is the log2() of number of LBAs on the LUN per UNMAP block.
+ *
+ * ublockoff is the lowest LBA on the LUN aligned to UNMAP block.
*
* atomicblock is the number of blocks that can be written atomically.
*
+ * opttxferlen is the number of blocks that can be written in one operation.
+ *
* req_lun_id is the requested LUN ID. CTL only pays attention to this
* field if the CTL_LUN_FLAG_ID_REQ flag is set. If the requested LUN ID is
* not available, the LUN addition will fail. If a particular LUN ID isn't
@@ -197,6 +203,7 @@ struct ctl_be_lun {
uint16_t ublockexp; /* passed to CTL */
uint16_t ublockoff; /* passed to CTL */
uint32_t atomicblock; /* passed to CTL */
+ uint32_t opttxferlen; /* passed to CTL */
uint32_t req_lun_id; /* passed to CTL */
uint32_t lun_id; /* returned from CTL */
uint8_t serial_num[CTL_SN_LEN]; /* passed to CTL */
Modified: head/sys/cam/ctl/ctl_backend_block.c
==============================================================================
--- head/sys/cam/ctl/ctl_backend_block.c Thu Dec 18 21:22:23 2014 (r275919)
+++ head/sys/cam/ctl/ctl_backend_block.c Thu Dec 18 22:32:22 2014 (r275920)
@@ -175,6 +175,8 @@ struct ctl_be_block_lun {
uint16_t pblockoff;
uint16_t ublockexp;
uint16_t ublockoff;
+ uint32_t atomicblock;
+ uint32_t opttxferlen;
struct ctl_be_block_softc *softc;
struct devstat *disk_stats;
ctl_be_block_lun_flags flags;
@@ -1845,6 +1847,8 @@ ctl_be_block_open_file(struct ctl_be_blo
"file %s size %ju < block size %u", be_lun->dev_path,
(uintmax_t)be_lun->size_bytes, be_lun->blocksize);
}
+
+ be_lun->opttxferlen = CTLBLK_MAX_IO_SIZE / be_lun->blocksize;
return (error);
}
@@ -1856,7 +1860,7 @@ ctl_be_block_open_dev(struct ctl_be_bloc
struct cdev *dev;
struct cdevsw *devsw;
char *value;
- int error;
+ int error, atomic, maxio;
off_t ps, pss, po, pos, us, uss, uo, uos;
params = &be_lun->params;
@@ -1870,8 +1874,16 @@ ctl_be_block_open_dev(struct ctl_be_bloc
if (strcmp(be_lun->backend.dev.csw->d_name, "zvol") == 0) {
be_lun->dispatch = ctl_be_block_dispatch_zvol;
be_lun->get_lba_status = ctl_be_block_gls_zvol;
- } else
+ atomic = maxio = CTLBLK_MAX_IO_SIZE;
+ } else {
be_lun->dispatch = ctl_be_block_dispatch_dev;
+ atomic = 0;
+ maxio = be_lun->backend.dev.cdev->si_iosize_max;
+ if (maxio <= 0)
+ maxio = DFLTPHYS;
+ if (maxio > CTLBLK_MAX_IO_SIZE)
+ maxio = CTLBLK_MAX_IO_SIZE;
+ }
be_lun->lun_flush = ctl_be_block_flush_dev;
be_lun->unmap = ctl_be_block_unmap_dev;
be_lun->getattr = ctl_be_block_getattr_dev;
@@ -2002,6 +2014,8 @@ ctl_be_block_open_dev(struct ctl_be_bloc
be_lun->ublockoff = (uss - uos) % uss;
}
+ be_lun->atomicblock = atomic / be_lun->blocksize;
+ be_lun->opttxferlen = maxio / be_lun->blocksize;
return (0);
}
@@ -2268,10 +2282,8 @@ ctl_be_block_create(struct ctl_be_block_
be_lun->ctl_be_lun.pblockoff = be_lun->pblockoff;
be_lun->ctl_be_lun.ublockexp = be_lun->ublockexp;
be_lun->ctl_be_lun.ublockoff = be_lun->ublockoff;
- if (be_lun->dispatch == ctl_be_block_dispatch_zvol &&
- be_lun->blocksize != 0)
- be_lun->ctl_be_lun.atomicblock = CTLBLK_MAX_IO_SIZE /
- be_lun->blocksize;
+ be_lun->ctl_be_lun.atomicblock = be_lun->atomicblock;
+ be_lun->ctl_be_lun.opttxferlen = be_lun->opttxferlen;
/* Tell the user the blocksize we ended up using */
params->lun_size_bytes = be_lun->size_bytes;
params->blocksize_bytes = be_lun->blocksize;
@@ -2649,10 +2661,8 @@ ctl_be_block_modify(struct ctl_be_block_
be_lun->ctl_be_lun.pblockoff = be_lun->pblockoff;
be_lun->ctl_be_lun.ublockexp = be_lun->ublockexp;
be_lun->ctl_be_lun.ublockoff = be_lun->ublockoff;
- if (be_lun->dispatch == ctl_be_block_dispatch_zvol &&
- be_lun->blocksize != 0)
- be_lun->ctl_be_lun.atomicblock = CTLBLK_MAX_IO_SIZE /
- be_lun->blocksize;
+ be_lun->ctl_be_lun.atomicblock = be_lun->atomicblock;
+ be_lun->ctl_be_lun.opttxferlen = be_lun->opttxferlen;
ctl_lun_capacity_changed(&be_lun->ctl_be_lun);
if (oldsize == 0 && be_lun->size_blocks != 0)
ctl_lun_online(&be_lun->ctl_be_lun);
Modified: head/sys/cam/ctl/ctl_backend_ramdisk.c
==============================================================================
--- head/sys/cam/ctl/ctl_backend_ramdisk.c Thu Dec 18 21:22:23 2014 (r275919)
+++ head/sys/cam/ctl/ctl_backend_ramdisk.c Thu Dec 18 22:32:22 2014 (r275920)
@@ -597,6 +597,7 @@ ctl_backend_ramdisk_create(struct ctl_be
if (unmap)
be_lun->ctl_be_lun.flags |= CTL_LUN_FLAG_UNMAP;
be_lun->ctl_be_lun.atomicblock = UINT32_MAX;
+ be_lun->ctl_be_lun.opttxferlen = softc->rd_size / blocksize;
be_lun->ctl_be_lun.be_lun = be_lun;
if (params->flags & CTL_LUN_FLAG_ID_REQ) {
More information about the svn-src-head
mailing list