Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Feb 2015 14:40:50 +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: r279005 - in stable/10/sys: cam/ctl sys
Message-ID:  <201502191440.t1JEeosp005847@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Thu Feb 19 14:40:50 2015
New Revision: 279005
URL: https://svnweb.freebsd.org/changeset/base/279005

Log:
  MFC r278672: Teach CTL to ask GEOM devices about BIO_DELETE support.

Modified:
  stable/10/sys/cam/ctl/ctl_backend_block.c
  stable/10/sys/cam/ctl/ctl_backend_ramdisk.c
  stable/10/sys/sys/disk.h
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 14:36:03 2015	(r279004)
+++ stable/10/sys/cam/ctl/ctl_backend_block.c	Thu Feb 19 14:40:50 2015	(r279005)
@@ -1877,7 +1877,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;
@@ -1902,7 +1902,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);
@@ -2033,6 +2032,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);
 }
 
@@ -2185,7 +2202,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;
@@ -2278,16 +2295,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;
@@ -2671,6 +2684,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: stable/10/sys/cam/ctl/ctl_backend_ramdisk.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_backend_ramdisk.c	Thu Feb 19 14:36:03 2015	(r279004)
+++ stable/10/sys/cam/ctl/ctl_backend_ramdisk.c	Thu Feb 19 14:40:50 2015	(r279005)
@@ -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: stable/10/sys/sys/disk.h
==============================================================================
--- stable/10/sys/sys/disk.h	Thu Feb 19 14:36:03 2015	(r279004)
+++ stable/10/sys/sys/disk.h	Thu Feb 19 14:40:50 2015	(r279005)
@@ -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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502191440.t1JEeosp005847>