mirror of
				https://git.proxmox.com/git/mirror_zfs.git
				synced 2025-10-26 18:05:04 +03:00 
			
		
		
		
	ZIL: Allow to replay blocks of any size.
There seems to be no reason for ZIL blocks to be limited by 128KB other than replay code is written in such a way. This change does not increase the limit yet, just removes the artificial limitation. Avoided extra memcpy() may save us a second during replay. Signed-off-by: Alexander Motin <mav@FreeBSD.org> Sponsored by: iXsystems, Inc.
This commit is contained in:
		
							parent
							
								
									b01a8cc2c0
								
							
						
					
					
						commit
						8a315a30ab
					
				@ -226,11 +226,10 @@ zil_init_log_chain(zilog_t *zilog, blkptr_t *bp)
 | 
			
		||||
 */
 | 
			
		||||
static int
 | 
			
		||||
zil_read_log_block(zilog_t *zilog, boolean_t decrypt, const blkptr_t *bp,
 | 
			
		||||
    blkptr_t *nbp, void *dst, char **end)
 | 
			
		||||
    blkptr_t *nbp, char **begin, char **end, arc_buf_t **abuf)
 | 
			
		||||
{
 | 
			
		||||
	enum zio_flag zio_flags = ZIO_FLAG_CANFAIL;
 | 
			
		||||
	arc_flags_t aflags = ARC_FLAG_WAIT;
 | 
			
		||||
	arc_buf_t *abuf = NULL;
 | 
			
		||||
	zbookmark_phys_t zb;
 | 
			
		||||
	int error;
 | 
			
		||||
 | 
			
		||||
@ -247,7 +246,7 @@ zil_read_log_block(zilog_t *zilog, boolean_t decrypt, const blkptr_t *bp,
 | 
			
		||||
	    ZB_ZIL_OBJECT, ZB_ZIL_LEVEL, bp->blk_cksum.zc_word[ZIL_ZC_SEQ]);
 | 
			
		||||
 | 
			
		||||
	error = arc_read(NULL, zilog->zl_spa, bp, arc_getbuf_func,
 | 
			
		||||
	    &abuf, ZIO_PRIORITY_SYNC_READ, zio_flags, &aflags, &zb);
 | 
			
		||||
	    abuf, ZIO_PRIORITY_SYNC_READ, zio_flags, &aflags, &zb);
 | 
			
		||||
 | 
			
		||||
	if (error == 0) {
 | 
			
		||||
		zio_cksum_t cksum = bp->blk_cksum;
 | 
			
		||||
@ -262,23 +261,23 @@ zil_read_log_block(zilog_t *zilog, boolean_t decrypt, const blkptr_t *bp,
 | 
			
		||||
		 */
 | 
			
		||||
		cksum.zc_word[ZIL_ZC_SEQ]++;
 | 
			
		||||
 | 
			
		||||
		uint64_t size = BP_GET_LSIZE(bp);
 | 
			
		||||
		if (BP_GET_CHECKSUM(bp) == ZIO_CHECKSUM_ZILOG2) {
 | 
			
		||||
			zil_chain_t *zilc = abuf->b_data;
 | 
			
		||||
			zil_chain_t *zilc = (*abuf)->b_data;
 | 
			
		||||
			char *lr = (char *)(zilc + 1);
 | 
			
		||||
			uint64_t len = zilc->zc_nused - sizeof (zil_chain_t);
 | 
			
		||||
 | 
			
		||||
			if (bcmp(&cksum, &zilc->zc_next_blk.blk_cksum,
 | 
			
		||||
			    sizeof (cksum)) || BP_IS_HOLE(&zilc->zc_next_blk)) {
 | 
			
		||||
			    sizeof (cksum)) || BP_IS_HOLE(&zilc->zc_next_blk) ||
 | 
			
		||||
			    zilc->zc_nused < sizeof (*zilc) ||
 | 
			
		||||
			    zilc->zc_nused > size) {
 | 
			
		||||
				error = SET_ERROR(ECKSUM);
 | 
			
		||||
			} else {
 | 
			
		||||
				ASSERT3U(len, <=, SPA_OLD_MAXBLOCKSIZE);
 | 
			
		||||
				bcopy(lr, dst, len);
 | 
			
		||||
				*end = (char *)dst + len;
 | 
			
		||||
				*begin = lr;
 | 
			
		||||
				*end = lr + zilc->zc_nused - sizeof (*zilc);
 | 
			
		||||
				*nbp = zilc->zc_next_blk;
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			char *lr = abuf->b_data;
 | 
			
		||||
			uint64_t size = BP_GET_LSIZE(bp);
 | 
			
		||||
			char *lr = (*abuf)->b_data;
 | 
			
		||||
			zil_chain_t *zilc = (zil_chain_t *)(lr + size) - 1;
 | 
			
		||||
 | 
			
		||||
			if (bcmp(&cksum, &zilc->zc_next_blk.blk_cksum,
 | 
			
		||||
@ -286,15 +285,11 @@ zil_read_log_block(zilog_t *zilog, boolean_t decrypt, const blkptr_t *bp,
 | 
			
		||||
			    (zilc->zc_nused > (size - sizeof (*zilc)))) {
 | 
			
		||||
				error = SET_ERROR(ECKSUM);
 | 
			
		||||
			} else {
 | 
			
		||||
				ASSERT3U(zilc->zc_nused, <=,
 | 
			
		||||
				    SPA_OLD_MAXBLOCKSIZE);
 | 
			
		||||
				bcopy(lr, dst, zilc->zc_nused);
 | 
			
		||||
				*end = (char *)dst + zilc->zc_nused;
 | 
			
		||||
				*begin = lr;
 | 
			
		||||
				*end = lr + zilc->zc_nused;
 | 
			
		||||
				*nbp = zilc->zc_next_blk;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		arc_buf_destroy(abuf, &abuf);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return (error);
 | 
			
		||||
@ -362,7 +357,6 @@ zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func,
 | 
			
		||||
	uint64_t blk_count = 0;
 | 
			
		||||
	uint64_t lr_count = 0;
 | 
			
		||||
	blkptr_t blk, next_blk;
 | 
			
		||||
	char *lrbuf, *lrp;
 | 
			
		||||
	int error = 0;
 | 
			
		||||
 | 
			
		||||
	bzero(&next_blk, sizeof (blkptr_t));
 | 
			
		||||
@ -382,13 +376,13 @@ zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func,
 | 
			
		||||
	 * If the log has been claimed, stop if we encounter a sequence
 | 
			
		||||
	 * number greater than the highest claimed sequence number.
 | 
			
		||||
	 */
 | 
			
		||||
	lrbuf = zio_buf_alloc(SPA_OLD_MAXBLOCKSIZE);
 | 
			
		||||
	zil_bp_tree_init(zilog);
 | 
			
		||||
 | 
			
		||||
	for (blk = zh->zh_log; !BP_IS_HOLE(&blk); blk = next_blk) {
 | 
			
		||||
		uint64_t blk_seq = blk.blk_cksum.zc_word[ZIL_ZC_SEQ];
 | 
			
		||||
		int reclen;
 | 
			
		||||
		char *end = NULL;
 | 
			
		||||
		char *lrp, *end;
 | 
			
		||||
		arc_buf_t *abuf = NULL;
 | 
			
		||||
 | 
			
		||||
		if (blk_seq > claim_blk_seq)
 | 
			
		||||
			break;
 | 
			
		||||
@ -404,8 +398,10 @@ zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func,
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
		error = zil_read_log_block(zilog, decrypt, &blk, &next_blk,
 | 
			
		||||
		    lrbuf, &end);
 | 
			
		||||
		    &lrp, &end, &abuf);
 | 
			
		||||
		if (error != 0) {
 | 
			
		||||
			if (abuf)
 | 
			
		||||
				arc_buf_destroy(abuf, &abuf);
 | 
			
		||||
			if (claimed) {
 | 
			
		||||
				char name[ZFS_MAX_DATASET_NAME_LEN];
 | 
			
		||||
 | 
			
		||||
@ -418,7 +414,7 @@ zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func,
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for (lrp = lrbuf; lrp < end; lrp += reclen) {
 | 
			
		||||
		for (; lrp < end; lrp += reclen) {
 | 
			
		||||
			lr_t *lr = (lr_t *)lrp;
 | 
			
		||||
			reclen = lr->lrc_reclen;
 | 
			
		||||
			ASSERT3U(reclen, >=, sizeof (lr_t));
 | 
			
		||||
@ -432,6 +428,7 @@ zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func,
 | 
			
		||||
			max_lr_seq = lr->lrc_seq;
 | 
			
		||||
			lr_count++;
 | 
			
		||||
		}
 | 
			
		||||
		arc_buf_destroy(abuf, &abuf);
 | 
			
		||||
	}
 | 
			
		||||
done:
 | 
			
		||||
	zilog->zl_parse_error = error;
 | 
			
		||||
@ -441,7 +438,6 @@ done:
 | 
			
		||||
	zilog->zl_parse_lr_count = lr_count;
 | 
			
		||||
 | 
			
		||||
	zil_bp_tree_fini(zilog);
 | 
			
		||||
	zio_buf_free(lrbuf, SPA_OLD_MAXBLOCKSIZE);
 | 
			
		||||
 | 
			
		||||
	return (error);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user