usr/src/uts/common/fs/zfs/dmu_send.c
changeset 4543 12bb2876a62e
parent 3655 bf932d11a0cb
child 4944 96d96f8de974
equal deleted inserted replaced
4542:ad60c8518fd5 4543:12bb2876a62e
   333 	return (0);
   333 	return (0);
   334 }
   334 }
   335 
   335 
   336 /* ARGSUSED */
   336 /* ARGSUSED */
   337 static void
   337 static void
   338 replay_incremental_sync(void *arg1, void *arg2, dmu_tx_t *tx)
   338 replay_incremental_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx)
   339 {
   339 {
   340 	dsl_dataset_t *ds = arg1;
   340 	dsl_dataset_t *ds = arg1;
   341 	dmu_buf_will_dirty(ds->ds_dbuf, tx);
   341 	dmu_buf_will_dirty(ds->ds_dbuf, tx);
   342 	ds->ds_phys->ds_flags |= DS_FLAG_INCONSISTENT;
   342 	ds->ds_phys->ds_flags |= DS_FLAG_INCONSISTENT;
       
   343 
       
   344 	spa_history_internal_log(LOG_DS_REPLAY_INC_SYNC,
       
   345 	    ds->ds_dir->dd_pool->dp_spa, tx, cr, "dataset = %lld",
       
   346 	    ds->ds_phys->ds_dir_obj);
   343 }
   347 }
   344 
   348 
   345 /* ARGSUSED */
   349 /* ARGSUSED */
   346 static int
   350 static int
   347 replay_full_check(void *arg1, void *arg2, dmu_tx_t *tx)
   351 replay_full_check(void *arg1, void *arg2, dmu_tx_t *tx)
   365 
   369 
   366 	return (0);
   370 	return (0);
   367 }
   371 }
   368 
   372 
   369 static void
   373 static void
   370 replay_full_sync(void *arg1, void *arg2, dmu_tx_t *tx)
   374 replay_full_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx)
   371 {
   375 {
   372 	dsl_dir_t *dd = arg1;
   376 	dsl_dir_t *dd = arg1;
   373 	struct drr_begin *drrb = arg2;
   377 	struct drr_begin *drrb = arg2;
   374 	char *cp;
   378 	char *cp;
   375 	dsl_dataset_t *ds;
   379 	dsl_dataset_t *ds;
   377 
   381 
   378 	cp = strchr(drrb->drr_toname, '@');
   382 	cp = strchr(drrb->drr_toname, '@');
   379 	*cp = '\0';
   383 	*cp = '\0';
   380 	dsobj = dsl_dataset_create_sync(dd, strrchr(drrb->drr_toname, '/') + 1,
   384 	dsobj = dsl_dataset_create_sync(dd, strrchr(drrb->drr_toname, '/') + 1,
   381 	    NULL, tx);
   385 	    NULL, tx);
   382 	*cp = '@';
       
   383 
   386 
   384 	VERIFY(0 == dsl_dataset_open_obj(dd->dd_pool, dsobj, NULL,
   387 	VERIFY(0 == dsl_dataset_open_obj(dd->dd_pool, dsobj, NULL,
   385 	    DS_MODE_EXCLUSIVE, FTAG, &ds));
   388 	    DS_MODE_EXCLUSIVE, FTAG, &ds));
   386 
   389 
   387 	(void) dmu_objset_create_impl(dsl_dataset_get_spa(ds),
   390 	(void) dmu_objset_create_impl(dsl_dataset_get_spa(ds),
   388 	    ds, &ds->ds_phys->ds_bp, drrb->drr_type, tx);
   391 	    ds, &ds->ds_phys->ds_bp, drrb->drr_type, tx);
   389 
   392 
   390 	dmu_buf_will_dirty(ds->ds_dbuf, tx);
   393 	dmu_buf_will_dirty(ds->ds_dbuf, tx);
   391 	ds->ds_phys->ds_flags |= DS_FLAG_INCONSISTENT;
   394 	ds->ds_phys->ds_flags |= DS_FLAG_INCONSISTENT;
       
   395 
       
   396 	spa_history_internal_log(LOG_DS_REPLAY_FULL_SYNC,
       
   397 	    ds->ds_dir->dd_pool->dp_spa, tx, cr, "dataset = %lld",
       
   398 	    ds->ds_phys->ds_dir_obj);
       
   399 
       
   400 	*cp = '@';
   392 
   401 
   393 	dsl_dataset_close(ds, DS_MODE_EXCLUSIVE, FTAG);
   402 	dsl_dataset_close(ds, DS_MODE_EXCLUSIVE, FTAG);
   394 }
   403 }
   395 
   404 
   396 static int
   405 static int
   409 
   418 
   410 	return (dsl_dataset_snapshot_check(os, snapname, tx));
   419 	return (dsl_dataset_snapshot_check(os, snapname, tx));
   411 }
   420 }
   412 
   421 
   413 static void
   422 static void
   414 replay_end_sync(void *arg1, void *arg2, dmu_tx_t *tx)
   423 replay_end_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx)
   415 {
   424 {
   416 	objset_t *os = arg1;
   425 	objset_t *os = arg1;
   417 	struct drr_begin *drrb = arg2;
   426 	struct drr_begin *drrb = arg2;
   418 	char *snapname;
   427 	char *snapname;
   419 	dsl_dataset_t *ds, *hds;
   428 	dsl_dataset_t *ds, *hds;
   420 
   429 
   421 	snapname = strchr(drrb->drr_toname, '@') + 1;
   430 	snapname = strchr(drrb->drr_toname, '@') + 1;
   422 
   431 
   423 	dsl_dataset_snapshot_sync(os, snapname, tx);
   432 	dsl_dataset_snapshot_sync(os, snapname, cr, tx);
   424 
   433 
   425 	/* set snapshot's creation time and guid */
   434 	/* set snapshot's creation time and guid */
   426 	hds = os->os->os_dsl_dataset;
   435 	hds = os->os->os_dsl_dataset;
   427 	VERIFY(0 == dsl_dataset_open_obj(hds->ds_dir->dd_pool,
   436 	VERIFY(0 == dsl_dataset_open_obj(hds->ds_dir->dd_pool,
   428 	    hds->ds_phys->ds_prev_snap_obj, NULL,
   437 	    hds->ds_phys->ds_prev_snap_obj, NULL,
   431 
   440 
   432 	dmu_buf_will_dirty(ds->ds_dbuf, tx);
   441 	dmu_buf_will_dirty(ds->ds_dbuf, tx);
   433 	ds->ds_phys->ds_creation_time = drrb->drr_creation_time;
   442 	ds->ds_phys->ds_creation_time = drrb->drr_creation_time;
   434 	ds->ds_phys->ds_guid = drrb->drr_toguid;
   443 	ds->ds_phys->ds_guid = drrb->drr_toguid;
   435 	ds->ds_phys->ds_flags &= ~DS_FLAG_INCONSISTENT;
   444 	ds->ds_phys->ds_flags &= ~DS_FLAG_INCONSISTENT;
       
   445 
       
   446 	/* log the end of the receive */
       
   447 	spa_history_internal_log(LOG_DS_RECEIVE, ds->ds_dir->dd_pool->dp_spa,
       
   448 	    tx, cr, "dataset = %llu", ds->ds_phys->ds_dir_obj);
   436 
   449 
   437 	dsl_dataset_close(ds, DS_MODE_PRIMARY, FTAG);
   450 	dsl_dataset_close(ds, DS_MODE_PRIMARY, FTAG);
   438 
   451 
   439 	dmu_buf_will_dirty(hds->ds_dbuf, tx);
   452 	dmu_buf_will_dirty(hds->ds_dbuf, tx);
   440 	hds->ds_phys->ds_flags &= ~DS_FLAG_INCONSISTENT;
   453 	hds->ds_phys->ds_flags &= ~DS_FLAG_INCONSISTENT;