Date: Fri, 26 Dec 2014 09:44:33 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r276237 - stable/10/sys/cam/ctl Message-ID: <201412260944.sBQ9iXYl002042@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Fri Dec 26 09:44:32 2014 New Revision: 276237 URL: https://svnweb.freebsd.org/changeset/base/276237 Log: MFC r275920, r276127: Pass real optimal transfer size supported by backend. For files and ZVOLs that is 1MB now, not 128K. Modified: stable/10/sys/cam/ctl/ctl.c stable/10/sys/cam/ctl/ctl_backend.h stable/10/sys/cam/ctl/ctl_backend_block.c stable/10/sys/cam/ctl/ctl_backend_ramdisk.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl.c ============================================================================== --- stable/10/sys/cam/ctl/ctl.c Fri Dec 26 09:35:23 2014 (r276236) +++ stable/10/sys/cam/ctl/ctl.c Fri Dec 26 09:44:32 2014 (r276237) @@ -10144,7 +10144,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: stable/10/sys/cam/ctl/ctl_backend.h ============================================================================== --- stable/10/sys/cam/ctl/ctl_backend.h Fri Dec 26 09:35:23 2014 (r276236) +++ stable/10/sys/cam/ctl/ctl_backend.h Fri Dec 26 09:44:32 2014 (r276237) @@ -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: stable/10/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_backend_block.c Fri Dec 26 09:35:23 2014 (r276236) +++ stable/10/sys/cam/ctl/ctl_backend_block.c Fri Dec 26 09:44:32 2014 (r276237) @@ -177,6 +177,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; @@ -1848,6 +1850,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); } @@ -1859,7 +1863,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; @@ -1873,8 +1877,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; @@ -2005,6 +2017,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); } @@ -2271,10 +2285,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; @@ -2652,10 +2664,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: stable/10/sys/cam/ctl/ctl_backend_ramdisk.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_backend_ramdisk.c Fri Dec 26 09:35:23 2014 (r276236) +++ stable/10/sys/cam/ctl/ctl_backend_ramdisk.c Fri Dec 26 09:44:32 2014 (r276237) @@ -570,6 +570,8 @@ ctl_backend_ramdisk_create(struct ctl_be be_lun->size_bytes = be_lun->size_blocks * blocksize; be_lun->ctl_be_lun.maxlba = be_lun->size_blocks - 1; + be_lun->ctl_be_lun.atomicblock = UINT32_MAX; + be_lun->ctl_be_lun.opttxferlen = softc->rd_size / blocksize; } else { be_lun->ctl_be_lun.maxlba = 0; blocksize = 0; @@ -596,7 +598,6 @@ ctl_backend_ramdisk_create(struct ctl_be be_lun->ctl_be_lun.flags = CTL_LUN_FLAG_PRIMARY; 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.be_lun = be_lun; if (params->flags & CTL_LUN_FLAG_ID_REQ) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412260944.sBQ9iXYl002042>