usr/src/lib/libzfs/common/libzfs_dataset.c
changeset 5481 1364fb7de75d
parent 5473 fcdd1931b3aa
child 5498 334b476844ca
--- a/usr/src/lib/libzfs/common/libzfs_dataset.c	Wed Nov 14 08:38:43 2007 -0800
+++ b/usr/src/lib/libzfs/common/libzfs_dataset.c	Wed Nov 14 12:28:57 2007 -0800
@@ -852,17 +852,43 @@
 	    &intval) == 0) {
 		uint64_t old_volsize = zfs_prop_get_int(zhp,
 		    ZFS_PROP_VOLSIZE);
-		uint64_t old_reservation = zfs_prop_get_int(zhp,
-		    ZFS_PROP_RESERVATION);
+		uint64_t old_reservation;
 		uint64_t new_reservation;
+		char *pool_name;
+		zpool_handle_t *zpool_handle;
+		char *p;
+		zfs_prop_t resv_prop;
+		uint64_t spa_version;
+
+		pool_name = zfs_alloc(zhp->zfs_hdl, MAXPATHLEN);
+		if (zfs_prop_get(zhp, ZFS_PROP_NAME, pool_name,
+		    MAXPATHLEN, NULL, NULL, 0, B_FALSE) != 0) {
+			free(pool_name);
+			goto error;
+		}
+
+		if (p = strchr(pool_name, '/'))
+			*p = '\0';
+		zpool_handle = zpool_open(hdl, pool_name);
+		free(pool_name);
+		if (zpool_handle == NULL)
+			goto error;
+
+		spa_version = zpool_get_prop_int(zpool_handle,
+		    ZPOOL_PROP_VERSION, NULL);
+		zpool_close(zpool_handle);
+		if (spa_version >= SPA_VERSION_REFRESERVATION)
+			resv_prop = ZFS_PROP_REFRESERVATION;
+		else
+			resv_prop = ZFS_PROP_RESERVATION;
+
+		old_reservation = zfs_prop_get_int(zhp, resv_prop);
 
 		if (old_volsize == old_reservation &&
-		    nvlist_lookup_uint64(ret,
-		    zfs_prop_to_name(ZFS_PROP_RESERVATION),
+		    nvlist_lookup_uint64(ret, zfs_prop_to_name(resv_prop),
 		    &new_reservation) != 0) {
 			if (nvlist_add_uint64(ret,
-			    zfs_prop_to_name(ZFS_PROP_RESERVATION),
-			    intval) != 0) {
+			    zfs_prop_to_name(resv_prop), intval) != 0) {
 				(void) no_memory(hdl);
 				goto error;
 			}