diff mbox

[4/6] btrfs: send: use vmalloc only as fallback for clone_roots

Message ID 2ea3965276a002936e1fb75ae8af51da384d705a.1460394967.git.dsterba@suse.com (mailing list archive)
State Accepted
Headers show

Commit Message

David Sterba April 11, 2016, 5:31 p.m. UTC
Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/send.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index ab1b4d259836..02967374d0d9 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -6047,10 +6047,13 @@  long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
 
 	alloc_size = sizeof(struct clone_root) * (arg->clone_sources_count + 1);
 
-	sctx->clone_roots = vzalloc(alloc_size);
+	sctx->clone_roots = kzalloc(alloc_size, GFP_KERNEL | __GFP_NOWARN);
 	if (!sctx->clone_roots) {
-		ret = -ENOMEM;
-		goto out;
+		sctx->clone_roots = vzalloc(alloc_size);
+		if (!sctx->clone_roots) {
+			ret = -ENOMEM;
+			goto out;
+		}
 	}
 
 	alloc_size = arg->clone_sources_count * sizeof(*arg->clone_sources);
@@ -6221,7 +6224,7 @@  long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
 		if (sctx->send_filp)
 			fput(sctx->send_filp);
 
-		vfree(sctx->clone_roots);
+		kvfree(sctx->clone_roots);
 		kvfree(sctx->send_buf);
 		kvfree(sctx->read_buf);