diff options
author | Sweet Tea Dorminy <sweettea-kernel@dorminy.me> | 2022-03-30 16:11:22 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2022-05-16 17:03:11 +0200 |
commit | dd137dd1f2d719682b522d4eabe6dec461b7d6fa (patch) | |
tree | bc566f7f1b070e24604cc790070ee1955c80572b /fs/btrfs/inode.c | |
parent | 0d031dc4aa05819beb8b9188f4306a3f2bc17f55 (diff) |
btrfs: factor out allocating an array of pages
Several functions currently populate an array of page pointers one
allocated page at a time. Factor out the common code so as to allow
improvements to all of the sites at once.
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 5ebc86d1f08c8..77fd450c786f7 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -10461,13 +10461,11 @@ static ssize_t btrfs_encoded_read_regular(struct kiocb *iocb, pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS); if (!pages) return -ENOMEM; - for (i = 0; i < nr_pages; i++) { - pages[i] = alloc_page(GFP_NOFS); - if (!pages[i]) { - ret = -ENOMEM; - goto out; + ret = btrfs_alloc_page_array(nr_pages, pages); + if (ret) { + ret = -ENOMEM; + goto out; } - } ret = btrfs_encoded_read_regular_fill_pages(inode, start, disk_bytenr, disk_io_size, pages); |