mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Switch KM_SLEEP to KM_PUSHPAGE
Differences between how paging is done on Solaris and Linux can cause deadlocks if KM_SLEEP is used in any the following contexts. * The txg_sync thread * The zvol write/discard threads * The zpl_putpage() VFS callback This is because KM_SLEEP will allow for direct reclaim which may result in the VM calling back in to the filesystem or block layer to write out pages. If a lock is held over this operation the potential exists to deadlock the system. To ensure forward progress all memory allocations in these contexts must us KM_PUSHPAGE which disables performing any I/O to accomplish the memory allocation. Previously, this behavior was acheived by setting PF_MEMALLOC on the thread. However, that resulted in unexpected side effects such as the exhaustion of pages in ZONE_DMA. This approach touchs more of the zfs code, but it is more consistent with the right way to handle these cases under Linux. This is patch lays the ground work for being able to safely revert the following commits which used PF_MEMALLOC:21ade34Disable direct reclaim for z_wr_* threadscfc9a5cFix zpl_writepage() deadlockeec8164Fix ASSERTION(!dsl_pool_sync_context(tx->tx_pool)) Signed-off-by: Richard Yao <ryao@cs.stonybrook.edu> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Issue #726
This commit is contained in:
committed by
Brian Behlendorf
parent
991fc1d7ae
commit
b8d06fca08
+13
-13
@@ -433,10 +433,10 @@ sa_add_layout_entry(objset_t *os, sa_attr_type_t *attrs, int attr_count,
|
||||
avl_index_t loc;
|
||||
|
||||
ASSERT(MUTEX_HELD(&sa->sa_lock));
|
||||
tb = kmem_zalloc(sizeof (sa_lot_t), KM_SLEEP);
|
||||
tb = kmem_zalloc(sizeof (sa_lot_t), KM_PUSHPAGE);
|
||||
tb->lot_attr_count = attr_count;
|
||||
tb->lot_attrs = kmem_alloc(sizeof (sa_attr_type_t) * attr_count,
|
||||
KM_SLEEP);
|
||||
KM_PUSHPAGE);
|
||||
bcopy(attrs, tb->lot_attrs, sizeof (sa_attr_type_t) * attr_count);
|
||||
tb->lot_num = lot_num;
|
||||
tb->lot_hash = hash;
|
||||
@@ -721,7 +721,7 @@ sa_build_layouts(sa_handle_t *hdl, sa_bulk_attr_t *attr_desc, int attr_count,
|
||||
buf_space = hdl->sa_bonus->db_size - hdrsize;
|
||||
|
||||
attrs_start = attrs = kmem_alloc(sizeof (sa_attr_type_t) * attr_count,
|
||||
KM_SLEEP);
|
||||
KM_PUSHPAGE);
|
||||
lot_count = 0;
|
||||
|
||||
for (i = 0, len_idx = 0, hash = -1ULL; i != attr_count; i++) {
|
||||
@@ -842,7 +842,7 @@ sa_attr_table_setup(objset_t *os, sa_attr_reg_t *reg_attrs, int count)
|
||||
dmu_objset_type_t ostype = dmu_objset_type(os);
|
||||
|
||||
sa->sa_user_table =
|
||||
kmem_zalloc(count * sizeof (sa_attr_type_t), KM_SLEEP);
|
||||
kmem_zalloc(count * sizeof (sa_attr_type_t), KM_PUSHPAGE);
|
||||
sa->sa_user_table_sz = count * sizeof (sa_attr_type_t);
|
||||
|
||||
if (sa->sa_reg_attr_obj != 0) {
|
||||
@@ -901,7 +901,7 @@ sa_attr_table_setup(objset_t *os, sa_attr_reg_t *reg_attrs, int count)
|
||||
|
||||
sa->sa_num_attrs = sa_attr_count;
|
||||
tb = sa->sa_attr_table =
|
||||
kmem_zalloc(sizeof (sa_attr_table_t) * sa_attr_count, KM_SLEEP);
|
||||
kmem_zalloc(sizeof (sa_attr_table_t) * sa_attr_count, KM_PUSHPAGE);
|
||||
|
||||
/*
|
||||
* Attribute table is constructed from requested attribute list,
|
||||
@@ -926,7 +926,7 @@ sa_attr_table_setup(objset_t *os, sa_attr_reg_t *reg_attrs, int count)
|
||||
continue;
|
||||
}
|
||||
tb[ATTR_NUM(value)].sa_name =
|
||||
kmem_zalloc(strlen(za.za_name) +1, KM_SLEEP);
|
||||
kmem_zalloc(strlen(za.za_name) +1, KM_PUSHPAGE);
|
||||
(void) strlcpy(tb[ATTR_NUM(value)].sa_name, za.za_name,
|
||||
strlen(za.za_name) +1);
|
||||
}
|
||||
@@ -952,7 +952,7 @@ sa_attr_table_setup(objset_t *os, sa_attr_reg_t *reg_attrs, int count)
|
||||
tb[i].sa_registered = B_FALSE;
|
||||
tb[i].sa_name =
|
||||
kmem_zalloc(strlen(sa_legacy_attrs[i].sa_name) +1,
|
||||
KM_SLEEP);
|
||||
KM_PUSHPAGE);
|
||||
(void) strlcpy(tb[i].sa_name,
|
||||
sa_legacy_attrs[i].sa_name,
|
||||
strlen(sa_legacy_attrs[i].sa_name) + 1);
|
||||
@@ -970,7 +970,7 @@ sa_attr_table_setup(objset_t *os, sa_attr_reg_t *reg_attrs, int count)
|
||||
tb[attr_id].sa_byteswap = reg_attrs[i].sa_byteswap;
|
||||
tb[attr_id].sa_attr = attr_id;
|
||||
tb[attr_id].sa_name =
|
||||
kmem_zalloc(strlen(reg_attrs[i].sa_name) + 1, KM_SLEEP);
|
||||
kmem_zalloc(strlen(reg_attrs[i].sa_name) + 1, KM_PUSHPAGE);
|
||||
(void) strlcpy(tb[attr_id].sa_name, reg_attrs[i].sa_name,
|
||||
strlen(reg_attrs[i].sa_name) + 1);
|
||||
}
|
||||
@@ -1007,7 +1007,7 @@ sa_setup(objset_t *os, uint64_t sa_obj, sa_attr_reg_t *reg_attrs, int count,
|
||||
return (0);
|
||||
}
|
||||
|
||||
sa = kmem_zalloc(sizeof (sa_os_t), KM_SLEEP);
|
||||
sa = kmem_zalloc(sizeof (sa_os_t), KM_PUSHPAGE);
|
||||
mutex_init(&sa->sa_lock, NULL, MUTEX_DEFAULT, NULL);
|
||||
sa->sa_master_obj = sa_obj;
|
||||
|
||||
@@ -1055,7 +1055,7 @@ sa_setup(objset_t *os, uint64_t sa_obj, sa_attr_reg_t *reg_attrs, int count,
|
||||
uint64_t lot_num;
|
||||
|
||||
lot_attrs = kmem_zalloc(sizeof (sa_attr_type_t) *
|
||||
za.za_num_integers, KM_SLEEP);
|
||||
za.za_num_integers, KM_PUSHPAGE);
|
||||
|
||||
if ((error = (zap_lookup(os, sa->sa_layout_attr_obj,
|
||||
za.za_name, 2, za.za_num_integers,
|
||||
@@ -1540,14 +1540,14 @@ sa_find_idx_tab(objset_t *os, dmu_object_type_t bonustype, void *data)
|
||||
}
|
||||
|
||||
/* No such luck, create a new entry */
|
||||
idx_tab = kmem_zalloc(sizeof (sa_idx_tab_t), KM_SLEEP);
|
||||
idx_tab = kmem_zalloc(sizeof (sa_idx_tab_t), KM_PUSHPAGE);
|
||||
idx_tab->sa_idx_tab =
|
||||
kmem_zalloc(sizeof (uint32_t) * sa->sa_num_attrs, KM_SLEEP);
|
||||
kmem_zalloc(sizeof (uint32_t) * sa->sa_num_attrs, KM_PUSHPAGE);
|
||||
idx_tab->sa_layout = tb;
|
||||
refcount_create(&idx_tab->sa_refcount);
|
||||
if (tb->lot_var_sizes)
|
||||
idx_tab->sa_variable_lengths = kmem_alloc(sizeof (uint16_t) *
|
||||
tb->lot_var_sizes, KM_SLEEP);
|
||||
tb->lot_var_sizes, KM_PUSHPAGE);
|
||||
|
||||
sa_attr_iter(os, hdr, bonustype, sa_build_idx_tab,
|
||||
tb, idx_tab);
|
||||
|
||||
Reference in New Issue
Block a user