Commit 27fac777 authored by Kari Argillander's avatar Kari Argillander Committed by Konstantin Komarov

fs/ntfs3: Init spi more in init_fs_context than fill_super

init_fs_context() is meant to initialize s_fs_info (spi). Move spi
initializing code there which we can initialize before fill_super().
Signed-off-by: default avatarKari Argillander <kari.argillander@gmail.com>
Signed-off-by: default avatarKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
parent 610f8f5a
...@@ -887,7 +887,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -887,7 +887,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
const struct VOLUME_INFO *info; const struct VOLUME_INFO *info;
u32 idx, done, bytes; u32 idx, done, bytes;
struct ATTR_DEF_ENTRY *t; struct ATTR_DEF_ENTRY *t;
u16 *upcase = NULL; u16 *upcase;
u16 *shared; u16 *shared;
bool is_ro; bool is_ro;
struct MFT_REF ref; struct MFT_REF ref;
...@@ -902,9 +902,6 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -902,9 +902,6 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
sb->s_time_gran = NTFS_TIME_GRAN; // 100 nsec sb->s_time_gran = NTFS_TIME_GRAN; // 100 nsec
sb->s_xattr = ntfs_xattr_handlers; sb->s_xattr = ntfs_xattr_handlers;
ratelimit_state_init(&sbi->msg_ratelimit, DEFAULT_RATELIMIT_INTERVAL,
DEFAULT_RATELIMIT_BURST);
sbi->options->nls = ntfs_load_nls(sbi->options->nls_name); sbi->options->nls = ntfs_load_nls(sbi->options->nls_name);
if (IS_ERR(sbi->options->nls)) { if (IS_ERR(sbi->options->nls)) {
sbi->options->nls = NULL; sbi->options->nls = NULL;
...@@ -934,12 +931,6 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -934,12 +931,6 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
sb->s_maxbytes = 0xFFFFFFFFull << sbi->cluster_bits; sb->s_maxbytes = 0xFFFFFFFFull << sbi->cluster_bits;
#endif #endif
mutex_init(&sbi->compress.mtx_lznt);
#ifdef CONFIG_NTFS3_LZX_XPRESS
mutex_init(&sbi->compress.mtx_xpress);
mutex_init(&sbi->compress.mtx_lzx);
#endif
/* /*
* Load $Volume. This should be done before $LogFile * Load $Volume. This should be done before $LogFile
* 'cause 'sbi->volume.ni' is used 'ntfs_set_state'. * 'cause 'sbi->volume.ni' is used 'ntfs_set_state'.
...@@ -1224,11 +1215,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -1224,11 +1215,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
goto out; goto out;
} }
sbi->upcase = upcase = kvmalloc(0x10000 * sizeof(short), GFP_KERNEL); upcase = sbi->upcase;
if (!upcase) {
err = -ENOMEM;
goto out;
}
for (idx = 0; idx < (0x10000 * sizeof(short) >> PAGE_SHIFT); idx++) { for (idx = 0; idx < (0x10000 * sizeof(short) >> PAGE_SHIFT); idx++) {
const __le16 *src; const __le16 *src;
...@@ -1440,10 +1427,21 @@ static int ntfs_init_fs_context(struct fs_context *fc) ...@@ -1440,10 +1427,21 @@ static int ntfs_init_fs_context(struct fs_context *fc)
goto ok; goto ok;
sbi = kzalloc(sizeof(struct ntfs_sb_info), GFP_NOFS); sbi = kzalloc(sizeof(struct ntfs_sb_info), GFP_NOFS);
if (!sbi) { if (!sbi)
kfree(opts); goto free_opts;
return -ENOMEM;
} sbi->upcase = kvmalloc(0x10000 * sizeof(short), GFP_KERNEL);
if (!sbi->upcase)
goto free_sbi;
ratelimit_state_init(&sbi->msg_ratelimit, DEFAULT_RATELIMIT_INTERVAL,
DEFAULT_RATELIMIT_BURST);
mutex_init(&sbi->compress.mtx_lznt);
#ifdef CONFIG_NTFS3_LZX_XPRESS
mutex_init(&sbi->compress.mtx_xpress);
mutex_init(&sbi->compress.mtx_lzx);
#endif
sbi->options = opts; sbi->options = opts;
fc->s_fs_info = sbi; fc->s_fs_info = sbi;
...@@ -1452,6 +1450,11 @@ static int ntfs_init_fs_context(struct fs_context *fc) ...@@ -1452,6 +1450,11 @@ static int ntfs_init_fs_context(struct fs_context *fc)
fc->ops = &ntfs_context_ops; fc->ops = &ntfs_context_ops;
return 0; return 0;
free_opts:
kfree(opts);
free_sbi:
kfree(sbi);
return -ENOMEM;
} }
// clang-format off // clang-format off
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment