]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
btrfs: preallocate radix tree node for readahead
authorDavid Sterba <dsterba@suse.com>
Thu, 2 Mar 2017 17:54:52 +0000 (18:54 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 18 Apr 2017 12:07:25 +0000 (14:07 +0200)
We can preallocate the node so insertion does not have to do that under
the lock. The GFP flags for the per-device radix tree are initialized to
 GFP_NOFS & ~__GFP_DIRECT_RECLAIM
but we can use GFP_KERNEL, same as an allocation above anyway, but also
because readahead is optional and not on any critical writeout path.

Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/reada.c
fs/btrfs/volumes.c

index e88bca87f5d275c7c25b2ee6279fe4cdc1482413..fdae8ca79401e69dd786f5c534761fd5b2d3d5f5 100644 (file)
@@ -270,6 +270,12 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,
        if (!zone)
                return NULL;
 
+       ret = radix_tree_preload(GFP_KERNEL);
+       if (ret) {
+               kfree(zone);
+               return NULL;
+       }
+
        zone->start = start;
        zone->end = end;
        INIT_LIST_HEAD(&zone->list);
@@ -299,6 +305,7 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,
                        zone = NULL;
        }
        spin_unlock(&fs_info->reada_lock);
+       radix_tree_preload_end();
 
        return zone;
 }
index 13574f37dc364475d16fe9512ad2f628903cb165..df50a63bbc3f52971f8e871234d5d98883e5629f 100644 (file)
@@ -252,7 +252,7 @@ static struct btrfs_device *__alloc_device(void)
        atomic_set(&dev->reada_in_flight, 0);
        atomic_set(&dev->dev_stats_ccnt, 0);
        btrfs_device_data_ordered_init(dev);
-       INIT_RADIX_TREE(&dev->reada_zones, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
+       INIT_RADIX_TREE(&dev->reada_zones, GFP_KERNEL);
        INIT_RADIX_TREE(&dev->reada_extents, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
 
        return dev;