super.c (fa3cacf544636b2dc48cfb2f277a2071f14d66a2) super.c (195c52bdd5d5ecfdabf5a7c6159efe299e534f84)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 *
4 * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved.
5 *
6 *
7 * terminology
8 *

--- 454 unchanged lines hidden (view full) ---

463 struct ntfs_inode *ni = foo;
464
465 inode_init_once(&ni->vfs_inode);
466}
467
468/* noinline to reduce binary size*/
469static noinline void put_ntfs(struct ntfs_sb_info *sbi)
470{
1// SPDX-License-Identifier: GPL-2.0
2/*
3 *
4 * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved.
5 *
6 *
7 * terminology
8 *

--- 454 unchanged lines hidden (view full) ---

463 struct ntfs_inode *ni = foo;
464
465 inode_init_once(&ni->vfs_inode);
466}
467
468/* noinline to reduce binary size*/
469static noinline void put_ntfs(struct ntfs_sb_info *sbi)
470{
471 ntfs_free(sbi->new_rec);
472 ntfs_vfree(ntfs_put_shared(sbi->upcase));
473 ntfs_free(sbi->def_table);
471 kfree(sbi->new_rec);
472 kvfree(ntfs_put_shared(sbi->upcase));
473 kfree(sbi->def_table);
474
475 wnd_close(&sbi->mft.bitmap);
476 wnd_close(&sbi->used.bitmap);
477
478 if (sbi->mft.ni)
479 iput(&sbi->mft.ni->vfs_inode);
480
481 if (sbi->security.ni)

--- 9 unchanged lines hidden (view full) ---

491 iput(&sbi->volume.ni->vfs_inode);
492
493 ntfs_update_mftmirr(sbi, 0);
494
495 indx_clear(&sbi->security.index_sii);
496 indx_clear(&sbi->security.index_sdh);
497 indx_clear(&sbi->reparse.index_r);
498 indx_clear(&sbi->objid.index_o);
474
475 wnd_close(&sbi->mft.bitmap);
476 wnd_close(&sbi->used.bitmap);
477
478 if (sbi->mft.ni)
479 iput(&sbi->mft.ni->vfs_inode);
480
481 if (sbi->security.ni)

--- 9 unchanged lines hidden (view full) ---

491 iput(&sbi->volume.ni->vfs_inode);
492
493 ntfs_update_mftmirr(sbi, 0);
494
495 indx_clear(&sbi->security.index_sii);
496 indx_clear(&sbi->security.index_sdh);
497 indx_clear(&sbi->reparse.index_r);
498 indx_clear(&sbi->objid.index_o);
499 ntfs_free(sbi->compress.lznt);
499 kfree(sbi->compress.lznt);
500#ifdef CONFIG_NTFS3_LZX_XPRESS
501 xpress_free_decompressor(sbi->compress.xpress);
502 lzx_free_decompressor(sbi->compress.lzx);
503#endif
504 clear_mount_options(&sbi->options);
505
500#ifdef CONFIG_NTFS3_LZX_XPRESS
501 xpress_free_decompressor(sbi->compress.xpress);
502 lzx_free_decompressor(sbi->compress.lzx);
503#endif
504 clear_mount_options(&sbi->options);
505
506 ntfs_free(sbi);
506 kfree(sbi);
507}
508
509static void ntfs_put_super(struct super_block *sb)
510{
511 struct ntfs_sb_info *sbi = sb->s_fs_info;
512
513 /*mark rw ntfs as clear, if possible*/
514 ntfs_set_state(sbi, NTFS_DIRTY_CLEAR);

--- 328 unchanged lines hidden (view full) ---

843 goto out;
844 }
845#elif BITS_PER_LONG < 64
846#error "CONFIG_NTFS3_64BIT_CLUSTER incompatible in 32 bit OS"
847#endif
848
849 sbi->used.bitmap.nbits = clusters;
850
507}
508
509static void ntfs_put_super(struct super_block *sb)
510{
511 struct ntfs_sb_info *sbi = sb->s_fs_info;
512
513 /*mark rw ntfs as clear, if possible*/
514 ntfs_set_state(sbi, NTFS_DIRTY_CLEAR);

--- 328 unchanged lines hidden (view full) ---

843 goto out;
844 }
845#elif BITS_PER_LONG < 64
846#error "CONFIG_NTFS3_64BIT_CLUSTER incompatible in 32 bit OS"
847#endif
848
849 sbi->used.bitmap.nbits = clusters;
850
851 rec = ntfs_zalloc(record_size);
851 rec = kzalloc(record_size, GFP_NOFS);
852 if (!rec) {
853 err = -ENOMEM;
854 goto out;
855 }
856
857 sbi->new_rec = rec;
858 rec->rhdr.sign = NTFS_FILE_SIGNATURE;
859 rec->rhdr.fix_off = cpu_to_le16(MFTRECORD_FIXUP_OFFSET_1);

--- 50 unchanged lines hidden (view full) ---

910 struct ATTR_DEF_ENTRY *t;
911 u16 *upcase = NULL;
912 u16 *shared;
913 bool is_ro;
914 struct MFT_REF ref;
915
916 ref.high = 0;
917
852 if (!rec) {
853 err = -ENOMEM;
854 goto out;
855 }
856
857 sbi->new_rec = rec;
858 rec->rhdr.sign = NTFS_FILE_SIGNATURE;
859 rec->rhdr.fix_off = cpu_to_le16(MFTRECORD_FIXUP_OFFSET_1);

--- 50 unchanged lines hidden (view full) ---

910 struct ATTR_DEF_ENTRY *t;
911 u16 *upcase = NULL;
912 u16 *shared;
913 bool is_ro;
914 struct MFT_REF ref;
915
916 ref.high = 0;
917
918 sbi = ntfs_zalloc(sizeof(struct ntfs_sb_info));
918 sbi = kzalloc(sizeof(struct ntfs_sb_info), GFP_NOFS);
919 if (!sbi)
920 return -ENOMEM;
921
922 sb->s_fs_info = sbi;
923 sbi->sb = sb;
924 sb->s_flags |= SB_NODIRATIME;
925 sb->s_magic = 0x7366746e; // "ntfs"
926 sb->s_op = &ntfs_sops;

--- 249 unchanged lines hidden (view full) ---

1176 goto out;
1177 }
1178
1179 if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY)) {
1180 err = -EINVAL;
1181 goto out;
1182 }
1183 bytes = inode->i_size;
919 if (!sbi)
920 return -ENOMEM;
921
922 sb->s_fs_info = sbi;
923 sbi->sb = sb;
924 sb->s_flags |= SB_NODIRATIME;
925 sb->s_magic = 0x7366746e; // "ntfs"
926 sb->s_op = &ntfs_sops;

--- 249 unchanged lines hidden (view full) ---

1176 goto out;
1177 }
1178
1179 if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY)) {
1180 err = -EINVAL;
1181 goto out;
1182 }
1183 bytes = inode->i_size;
1184 sbi->def_table = t = ntfs_malloc(bytes);
1184 sbi->def_table = t = kmalloc(bytes, GFP_NOFS);
1185 if (!t) {
1186 err = -ENOMEM;
1187 goto out;
1188 }
1189
1190 for (done = idx = 0; done < bytes; done += PAGE_SIZE, idx++) {
1191 unsigned long tail = bytes - done;
1192 struct page *page = ntfs_map_page(inode->i_mapping, idx);

--- 49 unchanged lines hidden (view full) ---

1242
1243 ni = ntfs_i(inode);
1244
1245 if (inode->i_size != 0x10000 * sizeof(short)) {
1246 err = -EINVAL;
1247 goto out;
1248 }
1249
1185 if (!t) {
1186 err = -ENOMEM;
1187 goto out;
1188 }
1189
1190 for (done = idx = 0; done < bytes; done += PAGE_SIZE, idx++) {
1191 unsigned long tail = bytes - done;
1192 struct page *page = ntfs_map_page(inode->i_mapping, idx);

--- 49 unchanged lines hidden (view full) ---

1242
1243 ni = ntfs_i(inode);
1244
1245 if (inode->i_size != 0x10000 * sizeof(short)) {
1246 err = -EINVAL;
1247 goto out;
1248 }
1249
1250 sbi->upcase = upcase = ntfs_vmalloc(0x10000 * sizeof(short));
1250 sbi->upcase = upcase = kvmalloc(0x10000 * sizeof(short), GFP_KERNEL);
1251 if (!upcase) {
1252 err = -ENOMEM;
1253 goto out;
1254 }
1255
1256 for (idx = 0; idx < (0x10000 * sizeof(short) >> PAGE_SHIFT); idx++) {
1257 const __le16 *src;
1258 u16 *dst = Add2Ptr(upcase, idx << PAGE_SHIFT);

--- 13 unchanged lines hidden (view full) ---

1272 memcpy(dst, src, PAGE_SIZE);
1273#endif
1274 ntfs_unmap_page(page);
1275 }
1276
1277 shared = ntfs_set_shared(upcase, 0x10000 * sizeof(short));
1278 if (shared && upcase != shared) {
1279 sbi->upcase = shared;
1251 if (!upcase) {
1252 err = -ENOMEM;
1253 goto out;
1254 }
1255
1256 for (idx = 0; idx < (0x10000 * sizeof(short) >> PAGE_SHIFT); idx++) {
1257 const __le16 *src;
1258 u16 *dst = Add2Ptr(upcase, idx << PAGE_SHIFT);

--- 13 unchanged lines hidden (view full) ---

1272 memcpy(dst, src, PAGE_SIZE);
1273#endif
1274 ntfs_unmap_page(page);
1275 }
1276
1277 shared = ntfs_set_shared(upcase, 0x10000 * sizeof(short));
1278 if (shared && upcase != shared) {
1279 sbi->upcase = shared;
1280 ntfs_vfree(upcase);
1280 kvfree(upcase);
1281 }
1282
1283 iput(inode);
1284 inode = NULL;
1285
1286 if (is_ntfs3(sbi)) {
1287 /* Load $Secure */
1288 err = ntfs_security_init(sbi);

--- 217 unchanged lines hidden ---
1281 }
1282
1283 iput(inode);
1284 inode = NULL;
1285
1286 if (is_ntfs3(sbi)) {
1287 /* Load $Secure */
1288 err = ntfs_security_init(sbi);

--- 217 unchanged lines hidden ---