Skip to content

Commit 0443477

Browse files
ahrensbehlendorf
authored andcommitted
Illumos #3100: zvol rename fails with EBUSY when dirty.
illumos/illumos-gate@2e2c135 Illumos changeset: 13780:6da32a929222 3100 zvol rename fails with EBUSY when dirty Reviewed by: Christopher Siden <chris.siden@delphix.com> Reviewed by: Adam H. Leventhal <ahl@delphix.com> Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Garrett D'Amore <garrett@damore.org> Approved by: Eric Schrock <eric.schrock@delphix.com> Ported-by: Etienne Dechamps <etienne.dechamps@ovh.net> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #995
1 parent 0677cb6 commit 0443477

File tree

8 files changed

+28
-32
lines changed

8 files changed

+28
-32
lines changed

include/sys/dmu_objset.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ timestruc_t dmu_objset_snap_cmtime(objset_t *os);
161161
/* called from dsl */
162162
void dmu_objset_sync(objset_t *os, zio_t *zio, dmu_tx_t *tx);
163163
boolean_t dmu_objset_is_dirty(objset_t *os, uint64_t txg);
164-
boolean_t dmu_objset_is_dirty_anywhere(objset_t *os);
165164
objset_t *dmu_objset_create_impl(spa_t *spa, struct dsl_dataset *ds,
166165
blkptr_t *bp, dmu_objset_type_t type, dmu_tx_t *tx);
167166
int dmu_objset_open_impl(spa_t *spa, struct dsl_dataset *ds, blkptr_t *bp,

include/sys/dsl_dataset.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ int dsl_dataset_space_written(dsl_dataset_t *oldsnap, dsl_dataset_t *new,
258258
uint64_t *usedp, uint64_t *compp, uint64_t *uncompp);
259259
int dsl_dataset_space_wouldfree(dsl_dataset_t *firstsnap, dsl_dataset_t *last,
260260
uint64_t *usedp, uint64_t *compp, uint64_t *uncompp);
261+
boolean_t dsl_dataset_is_dirty(dsl_dataset_t *ds);
261262

262263
int dsl_dsobj_to_dsname(char *pname, uint64_t obj, char *buf);
263264

lib/libzfs/libzfs_dataset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3700,7 +3700,7 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force)
37003700
zhp->zfs_type == ZFS_TYPE_VOLUME);
37013701

37023702
/*
3703-
* Destroy all recent snapshots and its dependends.
3703+
* Destroy all recent snapshots and their dependents.
37043704
*/
37053705
cb.cb_force = force;
37063706
cb.cb_target = snap->zfs_name;

module/zfs/dmu_objset.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,17 +1182,6 @@ dmu_objset_is_dirty(objset_t *os, uint64_t txg)
11821182
!list_is_empty(&os->os_free_dnodes[txg & TXG_MASK]));
11831183
}
11841184

1185-
boolean_t
1186-
dmu_objset_is_dirty_anywhere(objset_t *os)
1187-
{
1188-
int t;
1189-
1190-
for (t = 0; t < TXG_SIZE; t++)
1191-
if (dmu_objset_is_dirty(os, t))
1192-
return (B_TRUE);
1193-
return (B_FALSE);
1194-
}
1195-
11961185
static objset_used_cb_t *used_cbs[DMU_OST_NUMTYPES];
11971186

11981187
void

module/zfs/dsl_dataset.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,19 @@ dsl_dataset_dirty(dsl_dataset_t *ds, dmu_tx_t *tx)
12311231
}
12321232
}
12331233

1234+
boolean_t
1235+
dsl_dataset_is_dirty(dsl_dataset_t *ds)
1236+
{
1237+
int t;
1238+
1239+
for (t = 0; t < TXG_SIZE; t++) {
1240+
if (txg_list_member(&ds->ds_dir->dd_pool->dp_dirty_datasets,
1241+
ds, t))
1242+
return (B_TRUE);
1243+
}
1244+
return (B_FALSE);
1245+
}
1246+
12341247
/*
12351248
* The unique space in the head dataset can be calculated by subtracting
12361249
* the space used in the most recent snapshot, that is still being used
@@ -3402,10 +3415,6 @@ dsl_dataset_set_quota_sync(void *arg1, void *arg2, dmu_tx_t *tx)
34023415
if (ds->ds_quota != effective_value) {
34033416
dmu_buf_will_dirty(ds->ds_dbuf, tx);
34043417
ds->ds_quota = effective_value;
3405-
3406-
spa_history_log_internal(LOG_DS_REFQUOTA,
3407-
ds->ds_dir->dd_pool->dp_spa, tx, "%lld dataset = %llu ",
3408-
(longlong_t)ds->ds_quota, ds->ds_object);
34093418
}
34103419
}
34113420

@@ -3509,10 +3518,6 @@ dsl_dataset_set_reservation_sync(void *arg1, void *arg2, dmu_tx_t *tx)
35093518

35103519
dsl_dir_diduse_space(ds->ds_dir, DD_USED_REFRSRV, delta, 0, 0, tx);
35113520
mutex_exit(&ds->ds_dir->dd_lock);
3512-
3513-
spa_history_log_internal(LOG_DS_REFRESERV,
3514-
ds->ds_dir->dd_pool->dp_spa, tx, "%lld dataset = %llu",
3515-
(longlong_t)effective_value, ds->ds_object);
35163521
}
35173522

35183523
int

module/zfs/dsl_dir.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,10 +1066,6 @@ dsl_dir_set_quota_sync(void *arg1, void *arg2, dmu_tx_t *tx)
10661066
mutex_enter(&dd->dd_lock);
10671067
dd->dd_phys->dd_quota = effective_value;
10681068
mutex_exit(&dd->dd_lock);
1069-
1070-
spa_history_log_internal(LOG_DS_QUOTA, dd->dd_pool->dp_spa,
1071-
tx, "%lld dataset = %llu ",
1072-
(longlong_t)effective_value, dd->dd_phys->dd_head_dataset_obj);
10731069
}
10741070

10751071
int
@@ -1182,10 +1178,6 @@ dsl_dir_set_reservation_sync(void *arg1, void *arg2, dmu_tx_t *tx)
11821178
delta, 0, 0, tx);
11831179
}
11841180
mutex_exit(&dd->dd_lock);
1185-
1186-
spa_history_log_internal(LOG_DS_RESERVATION, dd->dd_pool->dp_spa,
1187-
tx, "%lld dataset = %llu",
1188-
(longlong_t)effective_value, dd->dd_phys->dd_head_dataset_obj);
11891181
}
11901182

11911183
int

module/zfs/zfs_vfsops.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,9 +1112,9 @@ zfs_sb_teardown(zfs_sb_t *zsb, boolean_t unmounting)
11121112
/*
11131113
* Evict cached data
11141114
*/
1115-
if (dmu_objset_is_dirty_anywhere(zsb->z_os))
1116-
if (!zfs_is_readonly(zsb))
1117-
txg_wait_synced(dmu_objset_pool(zsb->z_os), 0);
1115+
if (dsl_dataset_is_dirty(dmu_objset_ds(zsb->z_os)) &&
1116+
!zfs_is_readonly(zsb))
1117+
txg_wait_synced(dmu_objset_pool(zsb->z_os), 0);
11181118
(void) dmu_objset_evict_dbufs(zsb->z_os);
11191119

11201120
return (0);

module/zfs/zvol.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,18 @@ zvol_last_close(zvol_state_t *zv)
901901
{
902902
zil_close(zv->zv_zilog);
903903
zv->zv_zilog = NULL;
904+
904905
dmu_buf_rele(zv->zv_dbuf, zvol_tag);
905906
zv->zv_dbuf = NULL;
907+
908+
/*
909+
* Evict cached data
910+
*/
911+
if (dsl_dataset_is_dirty(dmu_objset_ds(zv->zv_objset)) &&
912+
!(zv->zv_flags & ZVOL_RDONLY))
913+
txg_wait_synced(dmu_objset_pool(zv->zv_objset), 0);
914+
(void) dmu_objset_evict_dbufs(zv->zv_objset);
915+
906916
dmu_objset_disown(zv->zv_objset, zvol_tag);
907917
zv->zv_objset = NULL;
908918
}

0 commit comments

Comments
 (0)