]> git.hungrycats.org Git - linux/commitdiff
Revert "btrfs: Add load read policy"
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Fri, 19 Nov 2021 04:44:33 +0000 (23:44 -0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Fri, 19 Nov 2021 04:44:33 +0000 (23:44 -0500)
This reverts commit aa6b80b6757e0bea21f8c4ce4389091acebd173a.

fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/sysfs.c
fs/btrfs/volumes.c
fs/btrfs/volumes.h

index 726c71ede2032f4d1861eccdd0d4b93334f5df72..8a1027bc9ab4dd0bf5723d3f5f33c101b2e03145 100644 (file)
@@ -1020,10 +1020,6 @@ struct btrfs_fs_info {
        spinlock_t treelog_bg_lock;
        u64 treelog_bg;
 
-       /* Data for scheduling made by the "load" read policy */
-       u64 __percpu *last_sched_time;
-       int __percpu *last_mirror;
-
 #ifdef CONFIG_BTRFS_FS_REF_VERIFY
        spinlock_t ref_verify_lock;
        struct rb_root block_tree;
index 4c4af1fb71209f2eefa4dd89dd638fd60cf307d5..0026d4f6ddf9ed18eb0a76911bdf110e236b2bd5 100644 (file)
@@ -1644,8 +1644,6 @@ void btrfs_free_fs_info(struct btrfs_fs_info *fs_info)
        btrfs_extent_buffer_leak_debug_check(fs_info);
        kfree(fs_info->super_copy);
        kfree(fs_info->super_for_commit);
-       free_percpu(fs_info->last_sched_time);
-       free_percpu(fs_info->last_mirror);
        kvfree(fs_info);
 }
 
@@ -2992,9 +2990,6 @@ void btrfs_init_fs_info(struct btrfs_fs_info *fs_info)
 
        fs_info->bg_reclaim_threshold = BTRFS_DEFAULT_RECLAIM_THRESH;
        INIT_WORK(&fs_info->reclaim_bgs_work, btrfs_reclaim_bgs_work);
-
-       fs_info->last_sched_time = __alloc_percpu(sizeof(u64), __alignof__(u64));
-       fs_info->last_mirror = __alloc_percpu(sizeof(int), __alignof__(int));
 }
 
 static int init_mount_fs_info(struct btrfs_fs_info *fs_info, struct super_block *sb)
index ceeaae36e423afd82dbfede84549c4543a60c08a..e3687bcd9b6b53d9d57c8fba345e4201145eca48 100644 (file)
@@ -900,97 +900,6 @@ static ssize_t btrfs_generation_show(struct kobject *kobj,
 }
 BTRFS_ATTR(, generation, btrfs_generation_show);
 
-static ssize_t btrfs_read_policy_load_duration_show(struct kobject *kobj,
-                                                   struct kobj_attribute *a,
-                                                   char *buf)
-{
-       struct btrfs_fs_devices *fs_devs = to_fs_devs(kobj->parent->parent);
-
-       return scnprintf(buf, PAGE_SIZE, "%d\n", fs_devs->read_policy_load_duration);
-}
-
-static ssize_t btrfs_read_policy_load_duration_store(struct kobject *kobj,
-                                                    struct kobj_attribute *a,
-                                                    const char *buf, size_t len)
-{
-       struct btrfs_fs_devices *fs_devs = to_fs_devs(kobj->parent->parent);
-       u32 duration;
-       int ret;
-
-       ret = kstrtou32(buf, 10, &duration);
-       if (ret)
-               return -EINVAL;
-
-       WRITE_ONCE(fs_devs->read_policy_load_duration, duration);
-       return len;
-}
-BTRFS_ATTR_RW(read_policy_load, duration, btrfs_read_policy_load_duration_show,
-             btrfs_read_policy_load_duration_store);
-
-static ssize_t btrfs_read_policy_load_rotating_inc_show(struct kobject *kobj,
-                                                       struct kobj_attribute *a,
-                                                       char *buf)
-{
-       struct btrfs_fs_devices *fs_devs = to_fs_devs(kobj->parent->parent);
-
-       return scnprintf(buf, PAGE_SIZE, "%d\n",
-                        fs_devs->read_policy_load_rotating_inc);
-}
-
-static ssize_t btrfs_read_policy_load_rotating_inc_store(struct kobject *kobj,
-                                                        struct kobj_attribute *a,
-                                                        const char *buf,
-                                                        size_t len)
-{
-       struct btrfs_fs_devices *fs_devs = to_fs_devs(kobj->parent->parent);
-       u32 rotating_inc;
-       int ret;
-
-       ret = kstrtou32(buf, 10, &rotating_inc);
-       if (ret)
-               return -EINVAL;
-
-       WRITE_ONCE(fs_devs->read_policy_load_rotating_inc, rotating_inc);
-       return len;
-}
-BTRFS_ATTR_RW(read_policy_load, rotating_inc,
-             btrfs_read_policy_load_rotating_inc_show,
-             btrfs_read_policy_load_rotating_inc_store);
-
-static struct attribute *read_policy_load_attrs[] = {
-       BTRFS_ATTR_PTR(read_policy_load, duration),
-       BTRFS_ATTR_PTR(read_policy_load, rotating_inc),
-       NULL
-};
-ATTRIBUTE_GROUPS(read_policy_load);
-
-static void btrfs_release_read_policy_load_kobj(struct kobject *kobj)
-{
-       struct btrfs_fs_devices *fs_devs = to_fs_devs(kobj->parent);
-
-       memset(&fs_devs->read_policy_load_kobj, 0, sizeof(struct kobject));
-}
-
-static struct kobj_type read_policy_load_ktype = {
-       .sysfs_ops      = &kobj_sysfs_ops,
-       .default_groups = read_policy_load_groups,
-       .release        = btrfs_release_read_policy_load_kobj,
-};
-
-static int btrfs_sysfs_add_read_policy_load(struct btrfs_fs_devices *devices)
-{
-       int ret;
-
-       ret = kobject_init_and_add(&devices->read_policy_load_kobj,
-                                  &read_policy_load_ktype,
-                                  devices->read_policies_kobj,
-                                  "%s", "load");
-       if (ret < 0)
-               kobject_put(&devices->read_policy_load_kobj);
-
-       return ret;
-}
-
 /*
  * Look for an exact string @string in @buffer with possible leading or
  * trailing whitespace
@@ -1012,7 +921,7 @@ static bool strmatch(const char *buffer, const char *string)
 
 /* Must follow the order as in enum btrfs_read_policy */
 static const char * const btrfs_read_policy_name[] = { "pid", "latency",
-       "device", "load" };
+                                                      "device" };
 
 static ssize_t btrfs_read_policy_show(struct kobject *kobj,
                                      struct kobj_attribute *a, char *buf)
@@ -1190,12 +1099,6 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
 
 static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
 {
-       if (fs_devs->read_policies_kobj) {
-               kobject_del(fs_devs->read_policies_kobj);
-               kobject_put(fs_devs->read_policies_kobj);
-               fs_devs->read_policies_kobj = NULL;
-       }
-
        if (fs_devs->devinfo_kobj) {
                kobject_del(fs_devs->devinfo_kobj);
                kobject_put(fs_devs->devinfo_kobj);
@@ -1854,19 +1757,6 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs)
                return -ENOMEM;
        }
 
-       fs_devs->read_policies_kobj = kobject_create_and_add(
-               "read_policies", &fs_devs->fsid_kobj);
-       if (!fs_devs->read_policies_kobj) {
-               btrfs_err(fs_devs->fs_info,
-                         "failed to init sysfs read_polivies kobject");
-               btrfs_sysfs_remove_fsid(fs_devs);
-               return -ENOMEM;
-       }
-
-       error = btrfs_sysfs_add_read_policy_load(fs_devs);
-       if (error)
-               return error;
-
        return 0;
 }
 
index 1a43526b654f532d682a182de628db13e643b4c7..3720c71f224864ab169fdb0be7d9d34ae686c2be 100644 (file)
@@ -370,11 +370,6 @@ static struct btrfs_fs_devices *alloc_fs_devices(const u8 *fsid,
        else if (fsid)
                memcpy(fs_devs->metadata_uuid, fsid, BTRFS_FSID_SIZE);
 
-       fs_devs->read_policy_load_duration =
-               BTRFS_DEFAULT_READ_POLICY_LOAD_DURATION;
-       fs_devs->read_policy_load_rotating_inc =
-               BTRFS_DEFAULT_READ_POLICY_LOAD_ROTATING_INC;
-
        return fs_devs;
 }
 
@@ -5992,59 +5987,6 @@ static int btrfs_find_read_preferred(struct map_lookup *map, int first, int num_
        return first;
 }
 
-static int mirror_load(struct btrfs_fs_info *fs_info,
-                      struct btrfs_bio_stripe *stripe)
-{
-       struct btrfs_device *dev;
-       int load;
-
-       dev = stripe->dev;
-       load = percpu_counter_sum(&dev->inflight);
-
-       if (blk_queue_nonrot(dev->bdev->bd_disk->queue))
-               return load;
-
-       return load + fs_info->fs_devices->read_policy_load_rotating_inc;
-}
-
-static int find_live_mirror_load(struct btrfs_fs_info *fs_info,
-                                struct map_lookup *map, int first,
-                                int num_stripes)
-{
-       int preferred_mirror;
-       u64 last_sched_time;
-       int min_load;
-       int cur_load;
-       u64 duration;
-       u64 now;
-       int i;
-
-       last_sched_time = this_cpu_read(*fs_info->last_sched_time);
-       if (last_sched_time != 0) {
-               now = ktime_get_ns();
-               duration = now - last_sched_time;
-
-               if (duration < (NSEC_PER_MSEC *
-                               fs_info->fs_devices->read_policy_load_duration))
-                       return this_cpu_read(*fs_info->last_mirror);
-       }
-
-       preferred_mirror = first;
-       min_load = INT_MAX;
-
-       for (i = first; i < first + num_stripes; i++) {
-               cur_load = mirror_load(fs_info, &map->stripes[i]);
-               if (cur_load < min_load) {
-                       preferred_mirror = i;
-                       min_load = cur_load;
-               }
-       }
-
-       this_cpu_write(*fs_info->last_sched_time, now);
-       this_cpu_write(*fs_info->last_mirror, preferred_mirror);
-       return preferred_mirror;
-}
-
 static int find_live_mirror(struct btrfs_fs_info *fs_info,
                            struct map_lookup *map, int first,
                            int dev_replace_is_ongoing)
@@ -6074,10 +6016,6 @@ static int find_live_mirror(struct btrfs_fs_info *fs_info,
        case BTRFS_READ_POLICY_PID:
                preferred_mirror = first + (unsigned)atomic_inc_return(&rr_counter) % num_stripes;
                break;
-       case BTRFS_READ_POLICY_LOAD:
-               preferred_mirror = find_live_mirror_load(fs_info, map, first,
-                                                        num_stripes);
-               break;
        case BTRFS_READ_POLICY_LATENCY:
                preferred_mirror = btrfs_find_best_stripe(fs_info, map, first,
                                                          num_stripes);
index 2c4f798d64ced7ef068e0eb62a6c5eaa2effdb0d..95cfaa7f9ca4654f8c2f35f89ff177f4551be9d9 100644 (file)
@@ -235,19 +235,9 @@ enum btrfs_read_policy {
        BTRFS_READ_POLICY_LATENCY,
        /* Use the device marked with READ_PREFERRED state */
        BTRFS_READ_POLICY_DEVICE,
-       /* Use the least loaded mirrors */
-       BTRFS_READ_POLICY_LOAD,
        BTRFS_NR_READ_POLICY,
 };
 
-/* Default duration in the load read policy (100 ms) */
-#define BTRFS_DEFAULT_READ_POLICY_LOAD_DURATION 100
-/*
- * Default value by which the load of rotational disks is increased, to bias
- * them in favor of non-rotationnal disks.
- */
-#define BTRFS_DEFAULT_READ_POLICY_LOAD_ROTATING_INC 0
-
 struct btrfs_fs_devices {
        u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
        u8 metadata_uuid[BTRFS_FSID_SIZE];
@@ -298,18 +288,12 @@ struct btrfs_fs_devices {
        struct kobject fsid_kobj;
        struct kobject *devices_kobj;
        struct kobject *devinfo_kobj;
-       struct kobject *read_policies_kobj;
-       struct kobject read_policy_load_kobj;
        struct completion kobj_unregister;
 
        enum btrfs_chunk_allocation_policy chunk_alloc_policy;
 
        /* Policy used to read the mirrored stripes */
        enum btrfs_read_policy read_policy;
-
-       /* Configuration specific for the load read policy */
-       u32 read_policy_load_duration;
-       u32 read_policy_load_rotating_inc;
 };
 
 #define BTRFS_BIO_INLINE_CSUM_SIZE     64