btrfs: send: use vmalloc only as fallback for clone_roots
authorDavid Sterba <dsterba@suse.com>
Mon, 11 Apr 2016 16:40:08 +0000 (18:40 +0200)
committerDavid Sterba <dsterba@suse.com>
Fri, 6 May 2016 13:22:49 +0000 (15:22 +0200)
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/send.c

index 4f85a47c2f55affc22fa75d9c3f0972db976b9dd..5a5d37b371508a7b39126e35b6b3f19581401c94 100644 (file)
@@ -6053,10 +6053,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);
@@ -6227,7 +6230,7 @@ out:
                if (sctx->send_filp)
                        fput(sctx->send_filp);
 
-               vfree(sctx->clone_roots);
+               kvfree(sctx->clone_roots);
                kvfree(sctx->send_buf);
                kvfree(sctx->read_buf);