]> git.hungrycats.org Git - linux/commitdiff
Revert "btrfs: track ordered bytes instead of just dio ordered bytes"
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Wed, 9 Dec 2020 15:31:49 +0000 (10:31 -0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Wed, 9 Dec 2020 15:31:49 +0000 (10:31 -0500)
This reverts commit 823bce35a4aad7e661364b9a04b0329de1ccfaea.

fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/ordered-data.c
fs/btrfs/space-info.c

index eb3fa19eba7e91ce87ab453f1199c7d15a55a2b8..ce2afcf422fa502eb59d4b850d9779dcdb5cc2ef 100644 (file)
@@ -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;
 
index 41908ef7b6bb10e5ebd92af34d081101fe0b1e6d..3a74120ff43bdc424c215b33c9d484d8bf3cb43c 100644 (file)
@@ -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);
index ed4287f79370b297caaf08725418678567170d15..e13b3d28c063b4f3bf015dc8c5a2a4abcdf044bd 100644 (file)
@@ -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);
index f2cdf7a9c9986ab362add1eccea5e296d24d1c54..590feec3e8be0f751519f6b79de45456d51d1bd4 100644 (file)
@@ -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);
        }
 }