From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH] btrfs: use kvzalloc for EXTENT_SAME temporary data
Date: Fri, 11 May 2018 17:57:54 +0200 [thread overview]
Message-ID: <20180511155754.27084-1-dsterba@suse.com> (raw)
The dedupe range is 16 MiB, with 4KiB pages and 8 byte pointers, the
arrays can be 32KiB large. To avoid allocation failures due to
fragmented memory, use the allocation with fallback to vmalloc.
Signed-off-by: David Sterba <dsterba@suse.com>
---
This depends on the patches that remove the 16MiB restriction in the
dedupe ioctl, but contextually can be applied to the current code too.
https://patchwork.kernel.org/patch/10374941/
fs/btrfs/ioctl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index b572e38b4b64..a7f517009cd7 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3178,8 +3178,8 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
* locking. We use an array for the page pointers. Size of the array is
* bounded by len, which is in turn bounded by BTRFS_MAX_DEDUPE_LEN.
*/
- cmp.src_pages = kcalloc(num_pages, sizeof(struct page *), GFP_KERNEL);
- cmp.dst_pages = kcalloc(num_pages, sizeof(struct page *), GFP_KERNEL);
+ cmp.src_pages = kvzalloc(num_pages, sizeof(struct page *), GFP_KERNEL);
+ cmp.dst_pages = kvzalloc(num_pages, sizeof(struct page *), GFP_KERNEL);
if (!cmp.src_pages || !cmp.dst_pages) {
kfree(cmp.src_pages);
kfree(cmp.dst_pages);
--
2.16.2
next reply other threads:[~2018-05-11 16:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-11 15:57 David Sterba [this message]
2018-05-11 16:25 ` [PATCH] btrfs: use kvzalloc for EXTENT_SAME temporary data Filipe Manana
2018-05-11 16:49 ` David Sterba
2018-05-11 17:16 ` Filipe Manana
2018-05-11 21:01 ` David Sterba
2018-05-11 17:31 ` Omar Sandoval
2018-05-11 17:47 ` Timofey Titovets
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180511155754.27084-1-dsterba@suse.com \
--to=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox