btrfs: use kvzalloc to allocate btrfs_fs_info
authorJeff Mahoney <jeffm@suse.com>
Fri, 16 Feb 2018 03:59:47 +0000 (22:59 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 May 2018 05:52:08 +0000 (07:52 +0200)
[ Upstream commit a8fd1f71749387c9a1053a83ff1c16287499a4e7 ]

The srcu_struct in btrfs_fs_info scales in size with NR_CPUS.  On
kernels built with NR_CPUS=8192, this can result in kmalloc failures
that prevent mounting.

There is work in progress to try to resolve this for every user of
srcu_struct but using kvzalloc will work around the failures until
that is complete.

As an example with NR_CPUS=512 on x86_64: the overall size of
subvol_srcu is 3460 bytes, fs_info is 6496.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/ctree.h
fs/btrfs/super.c

index c44703e21396aa5dc9883703bbe1bafdea455e83..588760c49fe28b8137d7a4136f035dd6d947e804 100644 (file)
@@ -2969,7 +2969,7 @@ static inline void free_fs_info(struct btrfs_fs_info *fs_info)
        kfree(fs_info->super_copy);
        kfree(fs_info->super_for_commit);
        security_free_mnt_opts(&fs_info->security_opts);
-       kfree(fs_info);
+       kvfree(fs_info);
 }
 
 /* tree mod log functions from ctree.c */
index e8f5e24325f338d5ab9770c9fa1c9aa50ef37ad2..8e3ce81d3f44c5da51b5efe31d61ea17f7fa6f1b 100644 (file)
@@ -1581,7 +1581,7 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags,
         * it for searching for existing supers, so this lets us do that and
         * then open_ctree will properly initialize everything later.
         */
-       fs_info = kzalloc(sizeof(struct btrfs_fs_info), GFP_KERNEL);
+       fs_info = kvzalloc(sizeof(struct btrfs_fs_info), GFP_KERNEL);
        if (!fs_info) {
                error = -ENOMEM;
                goto error_sec_opts;