View | Details | Raw Unified | Return to bug 192085
Collapse All | Expand All

(-)amd64/conf/GENERIC (+1 lines)
Lines 75-80 Link Here
75
# Debugging support.  Always need this:
75
# Debugging support.  Always need this:
76
options 	KDB			# Enable kernel debugger support.
76
options 	KDB			# Enable kernel debugger support.
77
options 	KDB_TRACE		# Print a stack trace for a panic.
77
options 	KDB_TRACE		# Print a stack trace for a panic.
78
options		KDB_UNATTENDED
78
# For full debugger support use (turn off in stable branch):
79
# For full debugger support use (turn off in stable branch):
79
options 	DDB			# Support DDB.
80
options 	DDB			# Support DDB.
80
options 	GDB			# Support remote GDB.
81
options 	GDB			# Support remote GDB.
(-)cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h (-1 / +1 lines)
Lines 43-49 Link Here
43
extern int zvol_create_minor(const char *);
43
extern int zvol_create_minor(const char *);
44
extern int zvol_remove_minor(const char *);
44
extern int zvol_remove_minor(const char *);
45
extern void zvol_remove_minors(const char *);
45
extern void zvol_remove_minors(const char *);
46
extern int zvol_set_volsize(const char *, major_t, uint64_t);
46
extern int zvol_set_volsize(const char *, uint64_t);
47
47
48
#ifdef sun
48
#ifdef sun
49
extern int zvol_open(dev_t *devp, int flag, int otyp, cred_t *cr);
49
extern int zvol_open(dev_t *devp, int flag, int otyp, cred_t *cr);
(-)cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c (-2 / +1 lines)
Lines 2482-2489 Link Here
2482
		err = dsl_dataset_set_refreservation(dsname, source, intval);
2482
		err = dsl_dataset_set_refreservation(dsname, source, intval);
2483
		break;
2483
		break;
2484
	case ZFS_PROP_VOLSIZE:
2484
	case ZFS_PROP_VOLSIZE:
2485
		err = zvol_set_volsize(dsname, ddi_driver_major(zfs_dip),
2485
		err = zvol_set_volsize(dsname, intval);
2486
		    intval);
2487
		break;
2486
		break;
2488
	case ZFS_PROP_VERSION:
2487
	case ZFS_PROP_VERSION:
2489
	{
2488
	{
(-)cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c (-49 / +72 lines)
Lines 203-213 Link Here
203
static void zvol_geom_worker(void *arg);
203
static void zvol_geom_worker(void *arg);
204
204
205
static void
205
static void
206
zvol_size_changed(zvol_state_t *zv)
206
zvol_size_changed(zvol_state_t *zv, uint64_t volsize)
207
{
207
{
208
#ifdef sun
208
#ifdef sun
209
	dev_t dev = makedevice(maj, min);
209
	dev_t dev = makedevice(maj, min);
210
210
211
	zv->zv_volsize = volsize;
211
	VERIFY(ddi_prop_update_int64(dev, zfs_dip,
212
	VERIFY(ddi_prop_update_int64(dev, zfs_dip,
212
	    "Size", volsize) == DDI_SUCCESS);
213
	    "Size", volsize) == DDI_SUCCESS);
213
	VERIFY(ddi_prop_update_int64(dev, zfs_dip,
214
	VERIFY(ddi_prop_update_int64(dev, zfs_dip,
Lines 765-773 Link Here
765
		dmu_objset_disown(os, zvol_tag);
766
		dmu_objset_disown(os, zvol_tag);
766
		return (error);
767
		return (error);
767
	}
768
	}
768
	zv->zv_volsize = volsize;
769
770
	zvol_size_changed(zv, volsize);
769
	zv->zv_zilog = zil_open(os, zvol_get_data);
771
	zv->zv_zilog = zil_open(os, zvol_get_data);
770
	zvol_size_changed(zv);
771
772
772
	VERIFY(dsl_prop_get_integer(zv->zv_name, "readonly", &readonly,
773
	VERIFY(dsl_prop_get_integer(zv->zv_name, "readonly", &readonly,
773
	    NULL) == 0);
774
	    NULL) == 0);
Lines 891-955 Link Here
891
	PICKUP_GIANT();
892
	PICKUP_GIANT();
892
}
893
}
893
894
894
int
895
static int
895
zvol_set_volsize(const char *name, major_t maj, uint64_t volsize)
896
zvol_update_live_volsize(zvol_state_t *zv, uint64_t volsize)
896
{
897
{
897
	zvol_state_t *zv = NULL;
898
	objset_t *os;
899
	int error;
900
	dmu_object_info_t doi;
901
	uint64_t old_volsize = 0ULL;
898
	uint64_t old_volsize = 0ULL;
902
	uint64_t readonly;
899
	int error = 0;
903
900
904
	mutex_enter(&spa_namespace_lock);
901
	ASSERT(MUTEX_HELD(&spa_namespace_lock));
905
	zv = zvol_minor_lookup(name);
906
	if ((error = dmu_objset_hold(name, FTAG, &os)) != 0) {
907
		mutex_exit(&spa_namespace_lock);
908
		return (error);
909
	}
910
902
911
	if ((error = dmu_object_info(os, ZVOL_OBJ, &doi)) != 0 ||
912
	    (error = zvol_check_volsize(volsize,
913
	    doi.doi_data_block_size)) != 0)
914
		goto out;
915
916
	VERIFY(dsl_prop_get_integer(name, "readonly", &readonly,
917
	    NULL) == 0);
918
	if (readonly) {
919
		error = EROFS;
920
		goto out;
921
	}
922
923
	error = zvol_update_volsize(os, volsize);
924
	/*
903
	/*
925
	 * Reinitialize the dump area to the new size. If we
904
	 * Reinitialize the dump area to the new size. If we
926
	 * failed to resize the dump area then restore it back to
905
	 * failed to resize the dump area then restore it back to
927
	 * its original size.
906
	 * its original size.  We must set the new volsize prior
907
	 * to calling dumpvp_resize() to ensure that the devices'
908
	 * size(9P) is not visible by the dump subsystem.
928
	 */
909
	 */
929
	if (zv && error == 0) {
910
	old_volsize = zv->zv_volsize;
911
	zvol_size_changed(zv, volsize);
930
#ifdef ZVOL_DUMP
912
#ifdef ZVOL_DUMP
931
		if (zv->zv_flags & ZVOL_DUMPIFIED) {
913
	if (zv->zv_flags & ZVOL_DUMPIFIED) {
932
			old_volsize = zv->zv_volsize;
914
		if ((error = zvol_dumpify(zv)) != 0 ||
933
			zv->zv_volsize = volsize;
915
		    (error = dumpvp_resize()) != 0) {
934
			if ((error = zvol_dumpify(zv)) != 0 ||
916
			int dumpify_error;
935
			    (error = dumpvp_resize()) != 0) {
917
936
				(void) zvol_update_volsize(os, old_volsize);
918
			(void) zvol_update_volsize(zv->zv_objset, old_volsize);
937
				zv->zv_volsize = old_volsize;
919
			zvol_size_changed(zv, old_volsize);
938
				error = zvol_dumpify(zv);
920
			dumpify_error = zvol_dumpify(zv);
939
			}
921
			error = dumpify_error ? dumpify_error : error;
940
		}
922
		}
941
#endif	/* ZVOL_DUMP */
942
		if (error == 0) {
943
			zv->zv_volsize = volsize;
944
			zvol_size_changed(zv);
945
		}
946
	}
923
	}
924
#endif /* ZVOL_DUMP */
947
925
948
#ifdef sun
926
#ifdef sun
949
	/*
927
	/*
950
	 * Generate a LUN expansion event.
928
	 * Generate a LUN expansion event.
951
	 */
929
	 */
952
	if (zv && error == 0) {
930
	if (error == 0) {
953
		sysevent_id_t eid;
931
		sysevent_id_t eid;
954
		nvlist_t *attr;
932
		nvlist_t *attr;
955
		char *physpath = kmem_zalloc(MAXPATHLEN, KM_SLEEP);
933
		char *physpath = kmem_zalloc(MAXPATHLEN, KM_SLEEP);
Lines 967-978 Link Here
967
		kmem_free(physpath, MAXPATHLEN);
945
		kmem_free(physpath, MAXPATHLEN);
968
	}
946
	}
969
#endif	/* sun */
947
#endif	/* sun */
948
	return (error);
949
}
970
950
951
int
952
zvol_set_volsize(const char *name, uint64_t volsize)
953
{
954
	zvol_state_t *zv = NULL;
955
	objset_t *os;
956
	int error;
957
	dmu_object_info_t doi;
958
	uint64_t readonly;
959
	boolean_t owned = B_FALSE;
960
961
	error = dsl_prop_get_integer(name,
962
	    zfs_prop_to_name(ZFS_PROP_READONLY), &readonly, NULL);
963
	if (error != 0)
964
		return (error);
965
	if (readonly)
966
		return (SET_ERROR(EROFS));
967
968
	mutex_enter(&spa_namespace_lock);
969
	zv = zvol_minor_lookup(name);
970
971
	if (zv == NULL || zv->zv_objset == NULL) {
972
		if ((error = dmu_objset_own(name, DMU_OST_ZVOL, B_FALSE,
973
		    FTAG, &os)) != 0) {
974
			mutex_exit(&spa_namespace_lock);
975
			return (error);
976
		}
977
		owned = B_TRUE;
978
		if (zv != NULL)
979
			zv->zv_objset = os;
980
	} else {
981
		os = zv->zv_objset;
982
	}
983
984
	if ((error = dmu_object_info(os, ZVOL_OBJ, &doi)) != 0 ||
985
	    (error = zvol_check_volsize(volsize, doi.doi_data_block_size)) != 0)
986
		goto out;
987
988
	error = zvol_update_volsize(os, volsize);
989
990
	if (error == 0 && zv != NULL)
991
		error = zvol_update_live_volsize(zv, volsize);
971
out:
992
out:
972
	dmu_objset_rele(os, FTAG);
993
	if (owned) {
973
994
		dmu_objset_disown(os, FTAG);
995
		if (zv != NULL)
996
			zv->zv_objset = NULL;
997
	}
974
	mutex_exit(&spa_namespace_lock);
998
	mutex_exit(&spa_namespace_lock);
975
976
	return (error);
999
	return (error);
977
}
1000
}
978
1001

Return to bug 192085