btrfs: send: use vmalloc only as fallback for read_buf
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 b6e2c6ec4ee5a7e9c44363584c872b2547b80f6a..4e950ebbef5396f0825cc7b90f97390800e27064 100644 (file)
@@ -6037,10 +6037,13 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
                }
        }
 
-       sctx->read_buf = vmalloc(BTRFS_SEND_READ_SIZE);
+       sctx->read_buf = kmalloc(BTRFS_SEND_READ_SIZE, GFP_KERNEL | __GFP_NOWARN);
        if (!sctx->read_buf) {
-               ret = -ENOMEM;
-               goto out;
+               sctx->read_buf = vmalloc(BTRFS_SEND_READ_SIZE);
+               if (!sctx->read_buf) {
+                       ret = -ENOMEM;
+                       goto out;
+               }
        }
 
        sctx->pending_dir_moves = RB_ROOT;
@@ -6224,7 +6227,7 @@ out:
 
                vfree(sctx->clone_roots);
                kvfree(sctx->send_buf);
-               vfree(sctx->read_buf);
+               kvfree(sctx->read_buf);
 
                name_cache_free(sctx);