summaryrefslogtreecommitdiffstats
path: root/module/zfs/zap_micro.c
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2014-08-05 13:46:49 -0700
committerBrian Behlendorf <[email protected]>2014-08-11 16:10:32 -0700
commit4dd18932ba4cfdcf9b16609f6a80c2d6c239cb15 (patch)
tree74f3f43d07e47d6847ec0f40511de492f0ec3af1 /module/zfs/zap_micro.c
parent50b25b2187134ac7b19cf93bd35a420223f1d343 (diff)
Avoid 128K kmem allocations in mzap_upgrade()
As originally implemented the mzap_upgrade() function will perform up to SPA_MAXBLOCKSIZE allocations using kmem_alloc(). These large allocations can potentially block indefinitely if contiguous memory is not available. Since this allocation is done under the zap->zap_rwlock it can appear as if there is a deadlock in zap_lockdir(). This is shown below. The optimal fix for this would be to rework mzap_upgrade() such that no large allocations are required. This could be done but it would result in us diverging further from the other implementations. Therefore I've opted against doing this unless it becomes absolutely necessary. Instead mzap_upgrade() has been updated to use zio_buf_alloc() which can reliably provide buffers of up to SPA_MAXBLOCKSIZE. Signed-off-by: Brian Behlendorf <[email protected]> Signed-off-by: Richard Yao <[email protected]> Close #2580
Diffstat (limited to 'module/zfs/zap_micro.c')
-rw-r--r--module/zfs/zap_micro.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/module/zfs/zap_micro.c b/module/zfs/zap_micro.c
index 68fb74769..2249b7338 100644
--- a/module/zfs/zap_micro.c
+++ b/module/zfs/zap_micro.c
@@ -533,7 +533,7 @@ mzap_upgrade(zap_t **zapp, dmu_tx_t *tx, zap_flags_t flags)
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock));
sz = zap->zap_dbuf->db_size;
- mzp = kmem_alloc(sz, KM_PUSHPAGE | KM_NODEBUG);
+ mzp = zio_buf_alloc(sz);
bcopy(zap->zap_dbuf->db_data, mzp, sz);
nchunks = zap->zap_m.zap_num_chunks;
@@ -541,7 +541,7 @@ mzap_upgrade(zap_t **zapp, dmu_tx_t *tx, zap_flags_t flags)
err = dmu_object_set_blocksize(zap->zap_objset, zap->zap_object,
1ULL << fzap_default_block_shift, 0, tx);
if (err) {
- kmem_free(mzp, sz);
+ zio_buf_free(mzp, sz);
return (err);
}
}
@@ -567,7 +567,7 @@ mzap_upgrade(zap_t **zapp, dmu_tx_t *tx, zap_flags_t flags)
if (err)
break;
}
- kmem_free(mzp, sz);
+ zio_buf_free(mzp, sz);
*zapp = zap;
return (err);
}