mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 10:01:01 +03:00
Retry zfs_znode_alloc() in zfs_mknode()
For historical reasons zfs_mknode() was written such that it could never fail. This poses a problem for Linux since zfs_znode_alloc() could potentually failure due to low memory. Handle this gracefully by retrying zfs_znode_alloc() until it succeeds, direct reclaim will eventually be able to allocate memory. Reviewed-by: George Melikov <mail@gmelikov.ru> Reviewed-by: loli10K <ezomori.nozomu@gmail.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #5535 Closes #5908
This commit is contained in:
parent
b25c5b0639
commit
8d70398740
@ -915,7 +915,18 @@ zfs_mknode(znode_t *dzp, vattr_t *vap, dmu_tx_t *tx, cred_t *cr,
|
||||
VERIFY(sa_replace_all_by_template(sa_hdl, sa_attrs, cnt, tx) == 0);
|
||||
|
||||
if (!(flag & IS_ROOT_NODE)) {
|
||||
*zpp = zfs_znode_alloc(zfsvfs, db, 0, obj_type, obj, sa_hdl);
|
||||
/*
|
||||
* The call to zfs_znode_alloc() may fail if memory is low
|
||||
* via the call path: alloc_inode() -> inode_init_always() ->
|
||||
* security_inode_alloc() -> inode_alloc_security(). Since
|
||||
* the existing code is written such that zfs_mknode() can
|
||||
* not fail retry until sufficient memory has been reclaimed.
|
||||
*/
|
||||
do {
|
||||
*zpp = zfs_znode_alloc(zfsvfs, db, 0, obj_type, obj,
|
||||
sa_hdl);
|
||||
} while (*zpp == NULL);
|
||||
|
||||
VERIFY(*zpp != NULL);
|
||||
VERIFY(dzp != NULL);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user