Reduce size of zfs_sb_t: allocate z_hold_mtx separately
zfs_sb_t has grown to the point where using kmem_zalloc() for allocations is triggering the 32k warning threshold. We can't safely convert this entire allocation to use vmem_alloc() instead of kmem_alloc() because the backing_dev_info structure is embedded here. It depends on the bit_waitqueue() function which won't behave properly when given a virtual address. Instead, use vmem_alloc() to allocate the z_hold_mtx array separately. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Chris Dunlop <chris@onthe.net.au> Closes #3178
This commit is contained in:
parent
bc88866657
commit
d07b7c7f21
|
@ -92,7 +92,7 @@ typedef struct zfs_sb {
|
||||||
uint64_t z_replay_eof; /* New end of file - replay only */
|
uint64_t z_replay_eof; /* New end of file - replay only */
|
||||||
sa_attr_type_t *z_attr_table; /* SA attr mapping->id */
|
sa_attr_type_t *z_attr_table; /* SA attr mapping->id */
|
||||||
#define ZFS_OBJ_MTX_SZ 256
|
#define ZFS_OBJ_MTX_SZ 256
|
||||||
kmutex_t z_hold_mtx[ZFS_OBJ_MTX_SZ]; /* znode hold locks */
|
kmutex_t *z_hold_mtx; /* znode hold locks */
|
||||||
} zfs_sb_t;
|
} zfs_sb_t;
|
||||||
|
|
||||||
#define ZFS_SUPER_MAGIC 0x2fc12fc1
|
#define ZFS_SUPER_MAGIC 0x2fc12fc1
|
||||||
|
|
|
@ -776,6 +776,9 @@ zfs_sb_create(const char *osname, zfs_sb_t **zsbp)
|
||||||
rrw_init(&zsb->z_teardown_lock, B_FALSE);
|
rrw_init(&zsb->z_teardown_lock, B_FALSE);
|
||||||
rw_init(&zsb->z_teardown_inactive_lock, NULL, RW_DEFAULT, NULL);
|
rw_init(&zsb->z_teardown_inactive_lock, NULL, RW_DEFAULT, NULL);
|
||||||
rw_init(&zsb->z_fuid_lock, NULL, RW_DEFAULT, NULL);
|
rw_init(&zsb->z_fuid_lock, NULL, RW_DEFAULT, NULL);
|
||||||
|
|
||||||
|
zsb->z_hold_mtx = vmem_zalloc(sizeof (kmutex_t) * ZFS_OBJ_MTX_SZ,
|
||||||
|
KM_SLEEP);
|
||||||
for (i = 0; i != ZFS_OBJ_MTX_SZ; i++)
|
for (i = 0; i != ZFS_OBJ_MTX_SZ; i++)
|
||||||
mutex_init(&zsb->z_hold_mtx[i], NULL, MUTEX_DEFAULT, NULL);
|
mutex_init(&zsb->z_hold_mtx[i], NULL, MUTEX_DEFAULT, NULL);
|
||||||
|
|
||||||
|
@ -789,6 +792,8 @@ zfs_sb_create(const char *osname, zfs_sb_t **zsbp)
|
||||||
out:
|
out:
|
||||||
dmu_objset_disown(os, zsb);
|
dmu_objset_disown(os, zsb);
|
||||||
*zsbp = NULL;
|
*zsbp = NULL;
|
||||||
|
|
||||||
|
vmem_free(zsb->z_hold_mtx, sizeof (kmutex_t) * ZFS_OBJ_MTX_SZ);
|
||||||
kmem_free(zsb, sizeof (zfs_sb_t));
|
kmem_free(zsb, sizeof (zfs_sb_t));
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
@ -892,6 +897,7 @@ zfs_sb_free(zfs_sb_t *zsb)
|
||||||
rw_destroy(&zsb->z_fuid_lock);
|
rw_destroy(&zsb->z_fuid_lock);
|
||||||
for (i = 0; i != ZFS_OBJ_MTX_SZ; i++)
|
for (i = 0; i != ZFS_OBJ_MTX_SZ; i++)
|
||||||
mutex_destroy(&zsb->z_hold_mtx[i]);
|
mutex_destroy(&zsb->z_hold_mtx[i]);
|
||||||
|
vmem_free(zsb->z_hold_mtx, sizeof (kmutex_t) * ZFS_OBJ_MTX_SZ);
|
||||||
mutex_destroy(&zsb->z_ctldir_lock);
|
mutex_destroy(&zsb->z_ctldir_lock);
|
||||||
avl_destroy(&zsb->z_ctldir_snaps);
|
avl_destroy(&zsb->z_ctldir_snaps);
|
||||||
kmem_free(zsb, sizeof (zfs_sb_t));
|
kmem_free(zsb, sizeof (zfs_sb_t));
|
||||||
|
|
|
@ -1731,6 +1731,8 @@ zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx)
|
||||||
list_create(&zsb->z_all_znodes, sizeof (znode_t),
|
list_create(&zsb->z_all_znodes, sizeof (znode_t),
|
||||||
offsetof(znode_t, z_link_node));
|
offsetof(znode_t, z_link_node));
|
||||||
|
|
||||||
|
zsb->z_hold_mtx = vmem_zalloc(sizeof (kmutex_t) * ZFS_OBJ_MTX_SZ,
|
||||||
|
KM_SLEEP);
|
||||||
for (i = 0; i != ZFS_OBJ_MTX_SZ; i++)
|
for (i = 0; i != ZFS_OBJ_MTX_SZ; i++)
|
||||||
mutex_init(&zsb->z_hold_mtx[i], NULL, MUTEX_DEFAULT, NULL);
|
mutex_init(&zsb->z_hold_mtx[i], NULL, MUTEX_DEFAULT, NULL);
|
||||||
|
|
||||||
|
@ -1755,6 +1757,7 @@ zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx)
|
||||||
for (i = 0; i != ZFS_OBJ_MTX_SZ; i++)
|
for (i = 0; i != ZFS_OBJ_MTX_SZ; i++)
|
||||||
mutex_destroy(&zsb->z_hold_mtx[i]);
|
mutex_destroy(&zsb->z_hold_mtx[i]);
|
||||||
|
|
||||||
|
vmem_free(zsb->z_hold_mtx, sizeof (kmutex_t) * ZFS_OBJ_MTX_SZ);
|
||||||
kmem_free(sb, sizeof (struct super_block));
|
kmem_free(sb, sizeof (struct super_block));
|
||||||
kmem_free(zsb, sizeof (zfs_sb_t));
|
kmem_free(zsb, sizeof (zfs_sb_t));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue