From: Zygo Blaxell Date: Wed, 9 Dec 2020 15:31:49 +0000 (-0500) Subject: Revert "btrfs: track ordered bytes instead of just dio ordered bytes" X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe34ff37e5353840f196f9863492a130c97393b5;p=linux Revert "btrfs: track ordered bytes instead of just dio ordered bytes" This reverts commit 823bce35a4aad7e661364b9a04b0329de1ccfaea. --- diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index eb3fa19eba7e..ce2afcf422fa 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -787,7 +787,7 @@ struct btrfs_fs_info { /* used to keep from writing metadata until there is a nice batch */ struct percpu_counter dirty_metadata_bytes; struct percpu_counter delalloc_bytes; - struct percpu_counter ordered_bytes; + struct percpu_counter dio_bytes; s32 dirty_metadata_batch; s32 delalloc_batch; diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 41908ef7b6bb..3a74120ff43b 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1524,7 +1524,7 @@ void btrfs_free_fs_info(struct btrfs_fs_info *fs_info) { percpu_counter_destroy(&fs_info->dirty_metadata_bytes); percpu_counter_destroy(&fs_info->delalloc_bytes); - percpu_counter_destroy(&fs_info->ordered_bytes); + percpu_counter_destroy(&fs_info->dio_bytes); percpu_counter_destroy(&fs_info->dev_replace.bio_counter); btrfs_free_csum_hash(fs_info); btrfs_free_stripe_hash_table(fs_info); @@ -2834,7 +2834,7 @@ static int init_mount_fs_info(struct btrfs_fs_info *fs_info, struct super_block sb->s_blocksize = BTRFS_BDEV_BLOCKSIZE; sb->s_blocksize_bits = blksize_bits(BTRFS_BDEV_BLOCKSIZE); - ret = percpu_counter_init(&fs_info->ordered_bytes, 0, GFP_KERNEL); + ret = percpu_counter_init(&fs_info->dio_bytes, 0, GFP_KERNEL); if (ret) return ret; @@ -4133,9 +4133,9 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info) percpu_counter_sum(&fs_info->delalloc_bytes)); } - if (percpu_counter_sum(&fs_info->ordered_bytes)) + if (percpu_counter_sum(&fs_info->dio_bytes)) btrfs_info(fs_info, "at unmount dio bytes count %lld", - percpu_counter_sum(&fs_info->ordered_bytes)); + percpu_counter_sum(&fs_info->dio_bytes)); btrfs_sysfs_remove_mounted(fs_info); btrfs_sysfs_remove_fsid(fs_info->fs_devices); diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index ed4287f79370..e13b3d28c063 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -184,11 +184,11 @@ static int __btrfs_add_ordered_extent(struct inode *inode, u64 file_offset, if (type != BTRFS_ORDERED_IO_DONE && type != BTRFS_ORDERED_COMPLETE) set_bit(type, &entry->flags); - percpu_counter_add_batch(&fs_info->ordered_bytes, num_bytes, - fs_info->delalloc_batch); - - if (dio) + if (dio) { + percpu_counter_add_batch(&fs_info->dio_bytes, num_bytes, + fs_info->delalloc_batch); set_bit(BTRFS_ORDERED_DIRECT, &entry->flags); + } /* one ref for the tree */ refcount_set(&entry->refs, 1); @@ -466,8 +466,9 @@ void btrfs_remove_ordered_extent(struct inode *inode, btrfs_delalloc_release_metadata(btrfs_inode, entry->num_bytes, false); - percpu_counter_add_batch(&fs_info->ordered_bytes, -entry->num_bytes, - fs_info->delalloc_batch); + if (test_bit(BTRFS_ORDERED_DIRECT, &entry->flags)) + percpu_counter_add_batch(&fs_info->dio_bytes, -entry->num_bytes, + fs_info->delalloc_batch); tree = &btrfs_inode->ordered_tree; spin_lock_irq(&tree->lock); diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index f2cdf7a9c998..590feec3e8be 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -500,7 +500,7 @@ static void shrink_delalloc(struct btrfs_fs_info *fs_info, u64 to_reclaim, struct btrfs_space_info *space_info; struct btrfs_trans_handle *trans; u64 delalloc_bytes; - u64 ordered_bytes; + u64 dio_bytes; u64 items; long time_left; int loops; @@ -514,20 +514,25 @@ static void shrink_delalloc(struct btrfs_fs_info *fs_info, u64 to_reclaim, delalloc_bytes = percpu_counter_sum_positive( &fs_info->delalloc_bytes); - ordered_bytes = percpu_counter_sum_positive(&fs_info->ordered_bytes); - if (delalloc_bytes == 0 && ordered_bytes == 0) + dio_bytes = percpu_counter_sum_positive(&fs_info->dio_bytes); + if (delalloc_bytes == 0 && dio_bytes == 0) { + if (trans) + return; + if (wait_ordered) + btrfs_wait_ordered_roots(fs_info, items, 0, (u64)-1); return; + } /* * If we are doing more ordered than delalloc we need to just wait on * ordered extents, otherwise we'll waste time trying to flush delalloc * that likely won't give us the space back we need. */ - if (ordered_bytes > delalloc_bytes) + if (dio_bytes > delalloc_bytes) wait_ordered = true; loops = 0; - while ((delalloc_bytes || ordered_bytes) && loops < 3) { + while ((delalloc_bytes || dio_bytes) && loops < 3) { btrfs_start_delalloc_roots(fs_info, items); spin_lock(&space_info->lock); @@ -548,8 +553,7 @@ static void shrink_delalloc(struct btrfs_fs_info *fs_info, u64 to_reclaim, } delalloc_bytes = percpu_counter_sum_positive( &fs_info->delalloc_bytes); - ordered_bytes = percpu_counter_sum_positive( - &fs_info->ordered_bytes); + dio_bytes = percpu_counter_sum_positive(&fs_info->dio_bytes); } }