diff options
author | Andrey Ryabinin <aryabinin@virtuozzo.com> | 2018-07-17 12:00:34 -0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2018-07-26 10:13:12 -0400 |
commit | d6d931adce1193ef54d06fa9bbf58e5780ca516c (patch) | |
tree | cc055c3dc51301c32c998a5863dddfe25bd17938 /fs/fuse | |
parent | a64ba10f65bfe2bead4693ef7fda9f7978dfa162 (diff) |
fuse: use kvmalloc to allocate array of pipe_buffer structs.
The amount of pipe->buffers is basically controlled by userspace by
fcntl(... F_SETPIPE_SZ ...) so it could be large. High order allocations
could be slow (if memory is heavily fragmented) or may fail if the order
is larger than PAGE_ALLOC_COSTLY_ORDER.
Since the 'bufs' doesn't need to be physically contiguous, use
the kvmalloc_array() to allocate memory. If high order
page isn't available, the kvamalloc*() will fallback to 0-order.
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/fuse')
-rw-r--r-- | fs/fuse/dev.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index de3d273c9366..1050c1cc22fe 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
@@ -1373,8 +1373,8 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos, | |||
1373 | if (!fud) | 1373 | if (!fud) |
1374 | return -EPERM; | 1374 | return -EPERM; |
1375 | 1375 | ||
1376 | bufs = kmalloc_array(pipe->buffers, sizeof(struct pipe_buffer), | 1376 | bufs = kvmalloc_array(pipe->buffers, sizeof(struct pipe_buffer), |
1377 | GFP_KERNEL); | 1377 | GFP_KERNEL); |
1378 | if (!bufs) | 1378 | if (!bufs) |
1379 | return -ENOMEM; | 1379 | return -ENOMEM; |
1380 | 1380 | ||
@@ -1407,7 +1407,7 @@ out: | |||
1407 | for (; page_nr < cs.nr_segs; page_nr++) | 1407 | for (; page_nr < cs.nr_segs; page_nr++) |
1408 | put_page(bufs[page_nr].page); | 1408 | put_page(bufs[page_nr].page); |
1409 | 1409 | ||
1410 | kfree(bufs); | 1410 | kvfree(bufs); |
1411 | return ret; | 1411 | return ret; |
1412 | } | 1412 | } |
1413 | 1413 | ||
@@ -1957,8 +1957,8 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe, | |||
1957 | 1957 | ||
1958 | pipe_lock(pipe); | 1958 | pipe_lock(pipe); |
1959 | 1959 | ||
1960 | bufs = kmalloc_array(pipe->buffers, sizeof(struct pipe_buffer), | 1960 | bufs = kvmalloc_array(pipe->buffers, sizeof(struct pipe_buffer), |
1961 | GFP_KERNEL); | 1961 | GFP_KERNEL); |
1962 | if (!bufs) { | 1962 | if (!bufs) { |
1963 | pipe_unlock(pipe); | 1963 | pipe_unlock(pipe); |
1964 | return -ENOMEM; | 1964 | return -ENOMEM; |
@@ -2017,7 +2017,7 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe, | |||
2017 | pipe_buf_release(pipe, &bufs[idx]); | 2017 | pipe_buf_release(pipe, &bufs[idx]); |
2018 | 2018 | ||
2019 | out: | 2019 | out: |
2020 | kfree(bufs); | 2020 | kvfree(bufs); |
2021 | return ret; | 2021 | return ret; |
2022 | } | 2022 | } |
2023 | 2023 | ||