Skip to content

Commit

Permalink
Make zvol update volsize operation synchronous.
Browse files Browse the repository at this point in the history
There is a race condition when new transaction group is added
to dp->dp_dirty_datasets list by the zap_update in the zvol_update_volsize.
Meanwhile, before these dirty data are synchronized, the receive process
can cause that dmu_recv_end_sync is executed. Then finally dirty data
are going to be synchronized but the synchronization ends with the NULL
pointer dereference error.

Signed-off-by: ab-oe <arkadiusz.bubala@open-e.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4116
  • Loading branch information
ab-oe authored and behlendorf committed Feb 29, 2016
1 parent 9f50093 commit 513168a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions module/zfs/zvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ zvol_update_volsize(uint64_t volsize, objset_t *os)
{
dmu_tx_t *tx;
int error;
uint64_t txg;

ASSERT(MUTEX_HELD(&zvol_state_lock));

Expand All @@ -287,11 +288,14 @@ zvol_update_volsize(uint64_t volsize, objset_t *os)
dmu_tx_abort(tx);
return (SET_ERROR(error));
}
txg = dmu_tx_get_txg(tx);

error = zap_update(os, ZVOL_ZAP_OBJ, "size", 8, 1,
&volsize, tx);
dmu_tx_commit(tx);

txg_wait_synced(dmu_objset_pool(os), txg);

if (error == 0)
error = dmu_free_long_range(os,
ZVOL_OBJ, volsize, DMU_OBJECT_END);
Expand Down

0 comments on commit 513168a

Please sign in to comment.