Author: mav Date: Fri Feb 13 13:26:23 2015 New Revision: 278672 URL: https://svnweb.freebsd.org/changeset/base/278672
Log: Teach CTL to ask GEOM devices about BIO_DELETE support. MFC after: 1 week Modified: head/sys/cam/ctl/ctl_backend_block.c head/sys/cam/ctl/ctl_backend_ramdisk.c head/sys/sys/disk.h Modified: head/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- head/sys/cam/ctl/ctl_backend_block.c Fri Feb 13 11:13:08 2015 (r278671) +++ head/sys/cam/ctl/ctl_backend_block.c Fri Feb 13 13:26:23 2015 (r278672) @@ -1874,7 +1874,7 @@ ctl_be_block_open_dev(struct ctl_be_bloc struct cdev *dev; struct cdevsw *devsw; char *value; - int error, atomic, maxio; + int error, atomic, maxio, unmap; off_t ps, pss, po, pos, us, uss, uo, uos; params = &be_lun->params; @@ -1899,7 +1899,6 @@ ctl_be_block_open_dev(struct ctl_be_bloc 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; error = VOP_GETATTR(be_lun->vn, &vattr, NOCRED); @@ -2030,6 +2029,24 @@ ctl_be_block_open_dev(struct ctl_be_bloc be_lun->atomicblock = atomic / be_lun->blocksize; be_lun->opttxferlen = maxio / be_lun->blocksize; + + if (be_lun->dispatch == ctl_be_block_dispatch_zvol) { + unmap = 1; + } else { + struct diocgattr_arg arg; + + strlcpy(arg.name, "GEOM::candelete", sizeof(arg.name)); + arg.len = sizeof(arg.value.i); + error = devsw->d_ioctl(dev, DIOCGATTR, + (caddr_t)&arg, FREAD, curthread); + unmap = (error == 0) ? arg.value.i : 0; + } + value = ctl_get_opt(&be_lun->ctl_be_lun.options, "unmap"); + if (value != NULL) + unmap = (strcmp(value, "on") == 0); + if (unmap) + be_lun->unmap = ctl_be_block_unmap_dev; + return (0); } @@ -2182,7 +2199,7 @@ ctl_be_block_create(struct ctl_be_block_ char num_thread_str[16]; char tmpstr[32]; char *value; - int retval, num_threads, unmap; + int retval, num_threads; int tmp_num_threads; params = &req->reqdata.create; @@ -2275,16 +2292,12 @@ ctl_be_block_create(struct ctl_be_block_ } num_threads = tmp_num_threads; } - unmap = (be_lun->dispatch == ctl_be_block_dispatch_zvol); - value = ctl_get_opt(&be_lun->ctl_be_lun.options, "unmap"); - if (value != NULL) - unmap = (strcmp(value, "on") == 0); be_lun->flags = CTL_BE_BLOCK_LUN_UNCONFIGURED; be_lun->ctl_be_lun.flags = CTL_LUN_FLAG_PRIMARY; if (be_lun->vn == NULL) be_lun->ctl_be_lun.flags |= CTL_LUN_FLAG_OFFLINE; - if (unmap) + if (be_lun->unmap != NULL) be_lun->ctl_be_lun.flags |= CTL_LUN_FLAG_UNMAP; if (be_lun->dispatch != ctl_be_block_dispatch_dev) be_lun->ctl_be_lun.flags |= CTL_LUN_FLAG_SERSEQ_READ; @@ -2668,6 +2681,8 @@ ctl_be_block_modify(struct ctl_be_block_ * XXX: Note that this field is being updated without locking, * which might cause problems on 32-bit architectures. */ + if (be_lun->unmap != NULL) + be_lun->ctl_be_lun.flags |= CTL_LUN_FLAG_UNMAP; be_lun->ctl_be_lun.maxlba = (be_lun->size_blocks == 0) ? 0 : (be_lun->size_blocks - 1); be_lun->ctl_be_lun.blocksize = be_lun->blocksize; Modified: head/sys/cam/ctl/ctl_backend_ramdisk.c ============================================================================== --- head/sys/cam/ctl/ctl_backend_ramdisk.c Fri Feb 13 11:13:08 2015 (r278671) +++ head/sys/cam/ctl/ctl_backend_ramdisk.c Fri Feb 13 13:26:23 2015 (r278672) @@ -588,10 +588,10 @@ ctl_backend_ramdisk_create(struct ctl_be be_lun->softc = softc; - unmap = 0; + unmap = 1; value = ctl_get_opt(&be_lun->ctl_be_lun.options, "unmap"); if (value != NULL && strcmp(value, "on") == 0) - unmap = 1; + unmap = (strcmp(value, "on") == 0); be_lun->flags = CTL_BE_RAMDISK_LUN_UNCONFIGURED; be_lun->ctl_be_lun.flags = CTL_LUN_FLAG_PRIMARY; Modified: head/sys/sys/disk.h ============================================================================== --- head/sys/sys/disk.h Fri Feb 13 11:13:08 2015 (r278671) +++ head/sys/sys/disk.h Fri Feb 13 13:26:23 2015 (r278672) @@ -131,6 +131,7 @@ struct diocgattr_arg { union { char str[DISK_IDENT_SIZE]; off_t off; + int i; } value; }; #define DIOCGATTR _IOWR('d', 142, struct diocgattr_arg) _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"