diff options
author | Matthew Ahrens <[email protected]> | 2014-11-03 12:28:43 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2015-05-04 09:41:10 -0700 |
commit | 3d45fdd6c0d5b4c8e42b6a2cda00bf6f22c9f2bf (patch) | |
tree | 79fabc013cdea334851b2b7ae9d59118e601f8eb /module/zfs/spa_misc.c | |
parent | cfec5b17b3b04f07381cc705eaf733794d034065 (diff) |
Illumos 4951 - ZFS administrative commands should use reserved space
4951 ZFS administrative commands should use reserved space, not with ENOSPC
Reviewed by: John Kennedy <[email protected]>
Reviewed by: George Wilson <[email protected]>
Reviewed by: Christopher Siden <[email protected]>
Reviewed by: Dan McDonald <[email protected]>
Approved by: Garrett D'Amore <[email protected]>
References:
https://www.illumos.org/issues/4373
https://github.com/illumos/illumos-gate/commit/7d46dc6
Ported by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'module/zfs/spa_misc.c')
-rw-r--r-- | module/zfs/spa_misc.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/module/zfs/spa_misc.c b/module/zfs/spa_misc.c index c17043657..8e5fa683e 100644 --- a/module/zfs/spa_misc.c +++ b/module/zfs/spa_misc.c @@ -312,6 +312,32 @@ int zfs_deadman_enabled = 1; int spa_asize_inflation = 24; /* + * Normally, we don't allow the last 3.2% (1/(2^spa_slop_shift)) of space in + * the pool to be consumed. This ensures that we don't run the pool + * completely out of space, due to unaccounted changes (e.g. to the MOS). + * It also limits the worst-case time to allocate space. If we have + * less than this amount of free space, most ZPL operations (e.g. write, + * create) will return ENOSPC. + * + * Certain operations (e.g. file removal, most administrative actions) can + * use half the slop space. They will only return ENOSPC if less than half + * the slop space is free. Typically, once the pool has less than the slop + * space free, the user will use these operations to free up space in the pool. + * These are the operations that call dsl_pool_adjustedsize() with the netfree + * argument set to TRUE. + * + * A very restricted set of operations are always permitted, regardless of + * the amount of free space. These are the operations that call + * dsl_sync_task(ZFS_SPACE_CHECK_NONE), e.g. "zfs destroy". If these + * operations result in a net increase in the amount of space used, + * it is possible to run the pool completely out of space, causing it to + * be permanently read-only. + * + * See also the comments in zfs_space_check_t. + */ +int spa_slop_shift = 5; + +/* * ========================================================================== * SPA config locking * ========================================================================== @@ -1564,6 +1590,18 @@ spa_get_asize(spa_t *spa, uint64_t lsize) return (lsize * spa_asize_inflation); } +/* + * Return the amount of slop space in bytes. It is 1/32 of the pool (3.2%), + * or at least 32MB. + * + * See the comment above spa_slop_shift for details. + */ +uint64_t +spa_get_slop_space(spa_t *spa) { + uint64_t space = spa_get_dspace(spa); + return (MAX(space >> spa_slop_shift, SPA_MINDEVSIZE >> 1)); +} + uint64_t spa_get_dspace(spa_t *spa) { |