Merge branch 'foreign/josef/space-updates' into for-chris-4.6

This commit is contained in:
David Sterba 2016-02-26 15:38:31 +01:00
commit e9ddd77a31
3 changed files with 36 additions and 17 deletions

View file

@ -4838,7 +4838,7 @@ static inline int need_do_async_reclaim(struct btrfs_space_info *space_info,
u64 thresh = div_factor_fine(space_info->total_bytes, 98); u64 thresh = div_factor_fine(space_info->total_bytes, 98);
/* If we're just plain full then async reclaim just slows us down. */ /* If we're just plain full then async reclaim just slows us down. */
if (space_info->bytes_used >= thresh) if ((space_info->bytes_used + space_info->bytes_reserved) >= thresh)
return 0; return 0;
return (used >= thresh && !btrfs_fs_closing(fs_info) && return (used >= thresh && !btrfs_fs_closing(fs_info) &&
@ -5373,27 +5373,33 @@ static void update_global_block_rsv(struct btrfs_fs_info *fs_info)
block_rsv->size = min_t(u64, num_bytes, SZ_512M); block_rsv->size = min_t(u64, num_bytes, SZ_512M);
num_bytes = sinfo->bytes_used + sinfo->bytes_pinned + if (block_rsv->reserved < block_rsv->size) {
sinfo->bytes_reserved + sinfo->bytes_readonly + num_bytes = sinfo->bytes_used + sinfo->bytes_pinned +
sinfo->bytes_may_use; sinfo->bytes_reserved + sinfo->bytes_readonly +
sinfo->bytes_may_use;
if (sinfo->total_bytes > num_bytes) { if (sinfo->total_bytes > num_bytes) {
num_bytes = sinfo->total_bytes - num_bytes; num_bytes = sinfo->total_bytes - num_bytes;
block_rsv->reserved += num_bytes; num_bytes = min(num_bytes,
sinfo->bytes_may_use += num_bytes; block_rsv->size - block_rsv->reserved);
trace_btrfs_space_reservation(fs_info, "space_info", block_rsv->reserved += num_bytes;
sinfo->flags, num_bytes, 1); sinfo->bytes_may_use += num_bytes;
} trace_btrfs_space_reservation(fs_info, "space_info",
sinfo->flags, num_bytes,
if (block_rsv->reserved >= block_rsv->size) { 1);
}
} else if (block_rsv->reserved > block_rsv->size) {
num_bytes = block_rsv->reserved - block_rsv->size; num_bytes = block_rsv->reserved - block_rsv->size;
sinfo->bytes_may_use -= num_bytes; sinfo->bytes_may_use -= num_bytes;
trace_btrfs_space_reservation(fs_info, "space_info", trace_btrfs_space_reservation(fs_info, "space_info",
sinfo->flags, num_bytes, 0); sinfo->flags, num_bytes, 0);
block_rsv->reserved = block_rsv->size; block_rsv->reserved = block_rsv->size;
block_rsv->full = 1;
} }
if (block_rsv->reserved == block_rsv->size)
block_rsv->full = 1;
else
block_rsv->full = 0;
spin_unlock(&block_rsv->lock); spin_unlock(&block_rsv->lock);
spin_unlock(&sinfo->lock); spin_unlock(&sinfo->lock);
} }

View file

@ -4212,11 +4212,20 @@ static int truncate_space_check(struct btrfs_trans_handle *trans,
{ {
int ret; int ret;
/*
* This is only used to apply pressure to the enospc system, we don't
* intend to use this reservation at all.
*/
bytes_deleted = btrfs_csum_bytes_to_leaves(root, bytes_deleted); bytes_deleted = btrfs_csum_bytes_to_leaves(root, bytes_deleted);
bytes_deleted *= root->nodesize;
ret = btrfs_block_rsv_add(root, &root->fs_info->trans_block_rsv, ret = btrfs_block_rsv_add(root, &root->fs_info->trans_block_rsv,
bytes_deleted, BTRFS_RESERVE_NO_FLUSH); bytes_deleted, BTRFS_RESERVE_NO_FLUSH);
if (!ret) if (!ret) {
trace_btrfs_space_reservation(root->fs_info, "transaction",
trans->transid,
bytes_deleted, 1);
trans->bytes_reserved += bytes_deleted; trans->bytes_reserved += bytes_deleted;
}
return ret; return ret;
} }

View file

@ -637,6 +637,8 @@ struct btrfs_trans_handle *btrfs_start_transaction_fallback_global_rsv(
trans->block_rsv = &root->fs_info->trans_block_rsv; trans->block_rsv = &root->fs_info->trans_block_rsv;
trans->bytes_reserved = num_bytes; trans->bytes_reserved = num_bytes;
trace_btrfs_space_reservation(root->fs_info, "transaction",
trans->transid, num_bytes, 1);
return trans; return trans;
} }
@ -1375,7 +1377,9 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
rsv = trans->block_rsv; rsv = trans->block_rsv;
trans->block_rsv = &pending->block_rsv; trans->block_rsv = &pending->block_rsv;
trans->bytes_reserved = trans->block_rsv->reserved; trans->bytes_reserved = trans->block_rsv->reserved;
trace_btrfs_space_reservation(root->fs_info, "transaction",
trans->transid,
trans->bytes_reserved, 1);
dentry = pending->dentry; dentry = pending->dentry;
parent_inode = pending->dir; parent_inode = pending->dir;
parent_root = BTRFS_I(parent_inode)->root; parent_root = BTRFS_I(parent_inode)->root;