From 99471fdd69ea569964b178820d7e1e10da011e1b Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Sun, 6 Dec 2020 16:32:57 +0900 Subject: [PATCH 1/3] exfat: fix build error with i_blocksize Signed-off-by: Namjae Jeon --- file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/file.c b/file.c index db10146c53b1..44c41c9b5308 100644 --- a/file.c +++ b/file.c @@ -244,7 +244,11 @@ void exfat_truncate(struct inode *inode, loff_t size) { struct super_block *sb = inode->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) unsigned int blocksize = i_blocksize(inode); +#else + unsigned int blocksize = 1 << inode->i_blkbits; +#endif loff_t aligned_size; int err; From 779f03e9676d7cb54dfcad34570b42db2bb27aea Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Tue, 8 Dec 2020 12:50:28 +0900 Subject: [PATCH 2/3] exfat: Avoid allocating upcase table using kcalloc() The table for Unicode upcase conversion requires an order-5 allocation, which may fail on a highly-fragmented system: pool-udisksd: page allocation failure: order:5, mode:0x40dc0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), nodemask=(null), cpuset=/,mems_allowed=0 CPU: 4 PID: 3756880 Comm: pool-udisksd Tainted: G U 5.8.10-200.fc32.x86_64 #1 Hardware name: Dell Inc. XPS 13 9360/0PVG6D, BIOS 2.13.0 11/14/2019 Call Trace: dump_stack+0x6b/0x88 warn_alloc.cold+0x75/0xd9 ? _cond_resched+0x16/0x40 ? __alloc_pages_direct_compact+0x144/0x150 __alloc_pages_slowpath.constprop.0+0xcfa/0xd30 ? __schedule+0x28a/0x840 ? __wait_on_bit_lock+0x92/0xa0 __alloc_pages_nodemask+0x2df/0x320 kmalloc_order+0x1b/0x80 kmalloc_order_trace+0x1d/0xa0 exfat_create_upcase_table+0x115/0x390 [exfat] exfat_fill_super+0x3ef/0x7f0 [exfat] ? sget_fc+0x1d0/0x240 ? exfat_init_fs_context+0x120/0x120 [exfat] get_tree_bdev+0x15c/0x250 vfs_get_tree+0x25/0xb0 do_mount+0x7c3/0xaf0 ? copy_mount_options+0xab/0x180 __x64_sys_mount+0x8e/0xd0 do_syscall_64+0x4d/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Make the driver use vzalloc() to eliminate the issue. Fixes: 370e812b3ec1 ("exfat: add nls operations") Cc: stable@vger.kernel.org # v5.7+ Signed-off-by: Artem Labazov <123321artyom@gmail.com> Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- nls.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/nls.c b/nls.c index 675d0e7058c5..58e434a5c330 100644 --- a/nls.c +++ b/nls.c @@ -3,9 +3,13 @@ * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd. */ +#include #include #include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0) +#include +#endif #include #include "exfat_raw.h" @@ -659,7 +663,11 @@ static int exfat_load_upcase_table(struct super_block *sb, unsigned char skip = false; unsigned short *upcase_table; - upcase_table = kcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) + upcase_table = kvcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); +#else + upcase_table = vzalloc(UTBL_COUNT * sizeof(unsigned short)); +#endif if (!upcase_table) return -ENOMEM; @@ -715,7 +723,11 @@ static int exfat_load_default_upcase_table(struct super_block *sb) unsigned short uni = 0, *upcase_table; unsigned int index = 0; - upcase_table = kcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) + upcase_table = kvcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); +#else + upcase_table = vzalloc(UTBL_COUNT * sizeof(unsigned short)); +#endif if (!upcase_table) return -ENOMEM; @@ -803,5 +815,9 @@ load_default: void exfat_free_upcase_table(struct exfat_sb_info *sbi) { - kfree(sbi->vol_utbl); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) + kvfree(sbi->vol_utbl); +#else + vfree(sbi->vol_utbl); +#endif } From aff434e63c57739df1ee06f406beaa2078bdd5f5 Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Wed, 6 Jan 2021 18:03:00 +0900 Subject: [PATCH 3/3] exfat: release 5.11.1 version Major changes are: - Avoid page allocation failure from upcase table allocation. Signed-off-by: Namjae Jeon --- exfat_fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exfat_fs.h b/exfat_fs.h index 00f3cd631bac..89ea4942f88f 100644 --- a/exfat_fs.h +++ b/exfat_fs.h @@ -11,7 +11,7 @@ #include #include -#define EXFAT_VERSION "5.10.1" +#define EXFAT_VERSION "5.11.1" #define EXFAT_SUPER_MAGIC 0x2011BAB0UL #define EXFAT_ROOT_INO 1