FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_replay.c
/*
 * TX_WRITE2 are only generated when dmu_sync() returns EALREADY
 * meaning the pool block is already being synced. So now that we always write
 * out full blocks, all we have to do is expand the eof if
 * the file is grown.
 */
TX_WRITE2 are only generated when dmu_sync() returns EALREADY
meaning the pool block is already being synced. So now that we always write
out full blocks, all we have to do is expand the eof if
the file is grown.
TX_WRITE2 are only generated when dmu_sync () returns EALREADY meaning the pool block is already being synced . So now that we always write out full blocks all we have to do is expand the eof if the file is grown .
static int
zfs_replay_write2(zfsvfs_t *zfsvfs, lr_write_t *lr, boolean_t byteswap)
{
	znode_t	*zp;
	int error;
	uint64_t end;
	if (byteswap)
		byteswap_uint64_array(lr, sizeof (*lr));
	if ((error = zfs_zget(zfsvfs, lr->lr_foid, &zp)) != 0)
		return (error);
top:
	end = lr->lr_offset + lr->lr_length;
	if (end > zp->z_size) {
		dmu_tx_t *tx = dmu_tx_create(zfsvfs->z_os);
		zp->z_size = end;
		dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);
		error = dmu_tx_assign(tx, TXG_WAIT);
		if (error) {
			VN_RELE(ZTOV(zp));
			if (error == ERESTART) {
				dmu_tx_wait(tx);
				dmu_tx_abort(tx);
				goto top;
			}
			dmu_tx_abort(tx);
			return (error);
		}
		(void) sa_update(zp->z_sa_hdl, SA_ZPL_SIZE(zfsvfs),
		    (void *)&zp->z_size, sizeof (uint64_t), tx);
		(void) zil_replaying(zfsvfs->z_log, tx);
		dmu_tx_commit(tx);
	}
	VN_RELE(ZTOV(zp));
	return (error);
}
static int zfs_replay_write2 ( zfsvfs_t * zfsvfs , lr_write_t * lr , boolean_t byteswap ) { znode_t * zp ; int error ; uint64_t end ; if ( byteswap ) byteswap_uint64_array ( lr , sizeof ( * lr ) ) ; if ( ( error = zfs_zget ( zfsvfs , lr -> lr_foid , & zp ) ) != 0 ) return ( error ) ; top : end = lr -> lr_offset + lr -> lr_length ; if ( end > zp -> z_size ) { dmu_tx_t * tx = dmu_tx_create ( zfsvfs -> z_os ) ; zp -> z_size = end ; dmu_tx_hold_sa ( tx , zp -> z_sa_hdl , B_FALSE ) ; error = dmu_tx_assign ( tx , TXG_WAIT ) ; if ( error ) { VN_RELE ( ZTOV ( zp ) ) ; if ( error == ERESTART ) { dmu_tx_wait ( tx ) ; dmu_tx_abort ( tx ) ; goto top ; } dmu_tx_abort ( tx ) ; return ( error ) ; } ( void ) sa_update ( zp -> z_sa_hdl , SA_ZPL_SIZE ( zfsvfs ) , ( void * ) & zp -> z_size , sizeof ( uint64_t ) , tx ) ; ( void ) zil_replaying ( zfsvfs -> z_log , tx ) ; dmu_tx_commit ( tx ) ; } VN_RELE ( ZTOV ( zp ) ) ; return ( error ) ; }
TX_WRITE2 are only generated when dmu_sync() returns EALREADY
 meaning the pool block is already being synced.
TX_WRITE2 are only generated when dmu_sync () returns EALREADY meaning the pool block is already being synced .
/* Ensure the replayed seq is updated */