Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Oct 2012 19:57:27 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r241297 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201210061957.q96JvRA5030144@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Sat Oct  6 19:57:27 2012
New Revision: 241297
URL: http://svn.freebsd.org/changeset/base/241297

Log:
  zvol: set mediasize in geom provider right upon its creation
  
  ... instead of deferring the action until first open.
  Unlike upstream this has no benefit on FreeBSD.
  We know that as soon as the provider is created it is going to be tasted
  and thus opened.  Initial mediasize of zero causes tasting failure
  and subsequent retasting because of the size change.
  
  MFC after:	14 days

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c	Sat Oct  6 19:52:50 2012	(r241296)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c	Sat Oct  6 19:57:27 2012	(r241297)
@@ -475,6 +475,7 @@ zvol_create_minor(const char *name)
 	zvol_state_t *zv;
 	objset_t *os;
 	dmu_object_info_t doi;
+	uint64_t volsize;
 	int error;
 
 	ZFS_LOG(1, "Creating ZVOL %s...", name);
@@ -535,9 +536,20 @@ zvol_create_minor(const char *name)
 	zv = zs->zss_data = kmem_zalloc(sizeof (zvol_state_t), KM_SLEEP);
 #else	/* !sun */
 
+	error = zap_lookup(os, ZVOL_ZAP_OBJ, "size", 8, 1, &volsize);
+	if (error) {
+		ASSERT(error == 0);
+		dmu_objset_disown(os, zvol_tag);
+		mutex_exit(&spa_namespace_lock);
+		return (error);
+	}
+
 	DROP_GIANT();
 	g_topology_lock();
 	zv = zvol_geom_create(name);
+	zv->zv_volsize = volsize;
+	zv->zv_provider->mediasize = zv->zv_volsize;
+
 #endif	/* !sun */
 
 	(void) strlcpy(zv->zv_name, name, MAXPATHLEN);



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