mirror of
				https://git.proxmox.com/git/mirror_zfs.git
				synced 2025-10-26 18:05:04 +03:00 
			
		
		
		
	Delay ZFS_PROP_SHARESMB property to handle it for encrypted raw receive
For encrypted raw receive, objset creation is delayed until a call to dmu_recv_stream(). ZFS_PROP_SHARESMB property requires objset to be populated when calling zpl_earlier_version(). To correctly handle the ZFS_PROP_SHARESMB property for encrypted raw receive, this change delays setting the property. Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ameer Hamza <ahamza@ixsystems.com> Closes #13878
This commit is contained in:
		
							parent
							
								
									d5105f068f
								
							
						
					
					
						commit
						035e52f591
					
				| @ -4787,6 +4787,11 @@ extract_delay_props(nvlist_t *props) | |||||||
| 	static const zfs_prop_t delayable[] = { | 	static const zfs_prop_t delayable[] = { | ||||||
| 		ZFS_PROP_REFQUOTA, | 		ZFS_PROP_REFQUOTA, | ||||||
| 		ZFS_PROP_KEYLOCATION, | 		ZFS_PROP_KEYLOCATION, | ||||||
|  | 		/*
 | ||||||
|  | 		 * Setting ZFS_PROP_SHARESMB requires the objset type to be | ||||||
|  | 		 * known, which is not possible prior to receipt of raw sends. | ||||||
|  | 		 */ | ||||||
|  | 		ZFS_PROP_SHARESMB, | ||||||
| 		0 | 		0 | ||||||
| 	}; | 	}; | ||||||
| 	int i; | 	int i; | ||||||
| @ -4850,6 +4855,7 @@ zfs_ioc_recv_impl(char *tofs, char *tosnap, char *origin, nvlist_t *recvprops, | |||||||
| 	offset_t off, noff; | 	offset_t off, noff; | ||||||
| 	nvlist_t *local_delayprops = NULL; | 	nvlist_t *local_delayprops = NULL; | ||||||
| 	nvlist_t *recv_delayprops = NULL; | 	nvlist_t *recv_delayprops = NULL; | ||||||
|  | 	nvlist_t *inherited_delayprops = NULL; | ||||||
| 	nvlist_t *origprops = NULL; /* existing properties */ | 	nvlist_t *origprops = NULL; /* existing properties */ | ||||||
| 	nvlist_t *origrecvd = NULL; /* existing received properties */ | 	nvlist_t *origrecvd = NULL; /* existing received properties */ | ||||||
| 	boolean_t first_recvd_props = B_FALSE; | 	boolean_t first_recvd_props = B_FALSE; | ||||||
| @ -4964,6 +4970,7 @@ zfs_ioc_recv_impl(char *tofs, char *tosnap, char *origin, nvlist_t *recvprops, | |||||||
| 		local_delayprops = extract_delay_props(oprops); | 		local_delayprops = extract_delay_props(oprops); | ||||||
| 		(void) zfs_set_prop_nvlist(tofs, ZPROP_SRC_LOCAL, | 		(void) zfs_set_prop_nvlist(tofs, ZPROP_SRC_LOCAL, | ||||||
| 		    oprops, *errors); | 		    oprops, *errors); | ||||||
|  | 		inherited_delayprops = extract_delay_props(xprops); | ||||||
| 		(void) zfs_set_prop_nvlist(tofs, ZPROP_SRC_INHERITED, | 		(void) zfs_set_prop_nvlist(tofs, ZPROP_SRC_INHERITED, | ||||||
| 		    xprops, *errors); | 		    xprops, *errors); | ||||||
| 
 | 
 | ||||||
| @ -5021,6 +5028,10 @@ zfs_ioc_recv_impl(char *tofs, char *tosnap, char *origin, nvlist_t *recvprops, | |||||||
| 			(void) zfs_set_prop_nvlist(tofs, ZPROP_SRC_LOCAL, | 			(void) zfs_set_prop_nvlist(tofs, ZPROP_SRC_LOCAL, | ||||||
| 			    local_delayprops, *errors); | 			    local_delayprops, *errors); | ||||||
| 		} | 		} | ||||||
|  | 		if (inherited_delayprops != NULL && error == 0) { | ||||||
|  | 			(void) zfs_set_prop_nvlist(tofs, ZPROP_SRC_INHERITED, | ||||||
|  | 			    inherited_delayprops, *errors); | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/*
 | 	/*
 | ||||||
| @ -5040,6 +5051,10 @@ zfs_ioc_recv_impl(char *tofs, char *tosnap, char *origin, nvlist_t *recvprops, | |||||||
| 		ASSERT(nvlist_merge(localprops, local_delayprops, 0) == 0); | 		ASSERT(nvlist_merge(localprops, local_delayprops, 0) == 0); | ||||||
| 		nvlist_free(local_delayprops); | 		nvlist_free(local_delayprops); | ||||||
| 	} | 	} | ||||||
|  | 	if (inherited_delayprops != NULL) { | ||||||
|  | 		ASSERT(nvlist_merge(localprops, inherited_delayprops, 0) == 0); | ||||||
|  | 		nvlist_free(inherited_delayprops); | ||||||
|  | 	} | ||||||
| 	*read_bytes = off - noff; | 	*read_bytes = off - noff; | ||||||
| 
 | 
 | ||||||
| #ifdef	ZFS_DEBUG | #ifdef	ZFS_DEBUG | ||||||
|  | |||||||
| @ -133,6 +133,14 @@ recv_cksum=$(md5digest /$ds/$TESTFILE0) | |||||||
| log_must test "$recv_cksum" == "$cksum" | log_must test "$recv_cksum" == "$cksum" | ||||||
| log_must zfs destroy -r $ds | log_must zfs destroy -r $ds | ||||||
| 
 | 
 | ||||||
|  | # Test that we can override sharesmb property for encrypted raw stream. | ||||||
|  | log_note "Must be able to override sharesmb property for encrypted raw stream" | ||||||
|  | ds=$TESTPOOL/recv | ||||||
|  | log_must eval "zfs send -w $esnap > $sendfile" | ||||||
|  | log_must eval "zfs recv -o sharesmb=on $ds < $sendfile" | ||||||
|  | log_must test "$(get_prop 'sharesmb' $ds)" == "on" | ||||||
|  | log_must zfs destroy -r $ds | ||||||
|  | 
 | ||||||
| # Test that we can override encryption properties on a properties stream | # Test that we can override encryption properties on a properties stream | ||||||
| # of an unencrypted dataset, turning it into an encryption root. | # of an unencrypted dataset, turning it into an encryption root. | ||||||
| log_note "Must be able to receive stream with props as encryption root" | log_note "Must be able to receive stream with props as encryption root" | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Ameer Hamza
						Ameer Hamza