summaryrefslogtreecommitdiffstats
path: root/fs/ntfs3 (follow)
Commit message (Collapse)AuthorAgeFilesLines
* fs/ntfs3: Refactor ntfs_create_inodeKonstantin Komarov2021-10-111-3/+8
| | | | | | Set size for symlink, so we don't need to calculate it on the fly. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Refactor ntfs_readlink_hlpKonstantin Komarov2021-10-111-48/+43
| | | | | | | Rename some variables. Returned err by default is EINVAL. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Rework ntfs_utf16_to_nlsKonstantin Komarov2021-10-112-12/+9
| | | | | | | | | Now ntfs_utf16_to_nls takes length as one of arguments. If length of symlink > 255, then we tried to convert length of symlink +- some random number. Now 255 symbols limit was removed. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Fix memory leak if fill_super failedKonstantin Komarov2021-10-111-34/+56
| | | | | | | | | | In ntfs_init_fs_context we allocate memory in fc->s_fs_info. In case of failed mount we must free it in ntfs_fill_super. We can't do it in ntfs_fs_free, because ntfs_fs_free called with fc->s_fs_info == NULL. fc->s_fs_info became NULL in sget_fc. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Keep prealloc for all types of filesKonstantin Komarov2021-10-111-7/+1
| | | | | | | | | | | | Before we haven't kept prealloc for sparse files because we thought that it will speed up create / write operations. It lead to situation, when user reserved some space for sparse file, filled volume, and wasn't able to write in reserved file. With this commit we keep prealloc. Now xfstest generic/274 pass. Fixes: be71b5cba2e6 ("fs/ntfs3: Add attrib operations") Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Remove unnecessary functionsKonstantin Komarov2021-10-051-94/+0
| | | | | | | We don't need ntfs_xattr_get_acl and ntfs_xattr_set_acl. There are ntfs_get_acl_ex and ntfs_set_acl_ex. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Forbid FALLOC_FL_PUNCH_HOLE for normal filesKonstantin Komarov2021-10-051-2/+5
| | | | | | | | | | | FALLOC_FL_PUNCH_HOLE isn't allowed with normal files. Filesystem must remember info about hole, but for normal file we can only zero it and forget. Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation") Now xfstests generic/016 generic/021 generic/022 pass. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Refactoring of ntfs_set_eaKonstantin Komarov2021-10-051-14/+17
| | | | | | | | Make code more readable. Don't try to read zero bytes. Add warning when size of exteneded attribute exceeds limit. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Remove locked argument in ntfs_set_eaKonstantin Komarov2021-10-051-15/+14
| | | | | | | | We always need to lock now, because locks became smaller (see d562e901f25d "fs/ntfs3: Move ni_lock_dir and ni_unlock into ntfs_create_inode"). Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Use available posix_acl_release instead of ntfs_posix_acl_releaseKonstantin Komarov2021-10-051-8/+2
| | | | | | | We don't need to maintain ntfs_posix_acl_release. Reviewed-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Check for NULL if ATTR_EA_INFO is incorrectKonstantin Komarov2021-09-301-1/+3
| | | | | | | | | This can be reason for reported panic https://lore.kernel.org/ntfs3/f9de5807-2311-7374-afb0-bc5dffb522c0@gmail.com/ Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation") Reported-by: Mohammad Rasim <mohammad.rasim96@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Refactoring of ntfs_init_from_bootKonstantin Komarov2021-09-302-12/+9
| | | | | | | | Remove ntfs_sb_info members sector_size and sector_bits. Print details why mount failed. Reviewed-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Reject mount if boot's cluster size < media sector sizeKonstantin Komarov2021-09-301-1/+12
| | | | | | | | If we continue to work in this case, then we can corrupt fs. Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block"). Reviewed-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Refactoring lock in ntfs_init_aclKonstantin Komarov2021-09-241-41/+14
| | | | | | | This is possible because of moving lock into ntfs_create_inode. Reviewed-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Change posix_acl_equiv_mode to posix_acl_update_modeKonstantin Komarov2021-09-241-11/+4
| | | | | | | | Right now ntfs3 uses posix_acl_equiv_mode instead of posix_acl_update_mode like all other fs. Reviewed-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Pass flags to ntfs_set_ea in ntfs_set_acl_exKonstantin Komarov2021-09-241-2/+7
| | | | | | | | | In case of removing of xattr there must be XATTR_REPLACE flag and zero length. We already check XATTR_REPLACE in ntfs_set_ea, so now we pass XATTR_REPLACE to ntfs_set_ea. Reviewed-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Refactor ntfs_get_acl_ex for better readabilityKonstantin Komarov2021-09-241-3/+6
| | | | | | | We can safely move set_cached_acl because it works with NULL acl too. Reviewed-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Move ni_lock_dir and ni_unlock into ntfs_create_inodeKonstantin Komarov2021-09-242-23/+14
| | | | | | | | | | Now ntfs3 locks mutex for smaller time. Theoretically in successful cases those locks aren't needed at all. But proving the same for error cases is difficult. So instead of removing them we just move them. Reviewed-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Fix logical error in ntfs_create_inodeKonstantin Komarov2021-09-241-1/+1
| | | | | | | | We need to always call indx_delete_entry after indx_insert_entry if error occurred. Reviewed-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Remove deprecated mount options nlsKari Argillander2021-09-231-4/+0
| | | | | | | | | | | | | Some discussion has been spoken that this deprecated mount options should be removed before 5.15 lands. This driver is not never seen day light so it was decided that nls mount option has to be removed. We have always possibility to add this if needed. One possible need is example if current ntfs driver will be taken out of kernel and ntfs3 needs to support mount options what it has. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Remove a useless shadowing variableChristophe JAILLET2021-09-231-2/+1
| | | | | | | | | | | There is already a 'u8 mask' defined at the top of the function. There is no need to define a new one here. Remove the useless and shadowing new 'mask' variable. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Remove a useless test in 'indx_find()'Christophe JAILLET2021-09-231-3/+1
| | | | | | | | | | | | | 'fnd' has been dereferenced several time before, so testing it here is pointless. Moreover, all callers of 'indx_find()' already have some error handling code that makes sure that no NULL 'fnd' is passed. So, remove the useless test. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Add sync flag to ntfs_sb_write_run and al_updateKonstantin Komarov2021-09-218-17/+17
| | | | | | | This allows to wait only when it's requested. It speeds up creation of hardlinks. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Change max hardlinks limit to 4000Konstantin Komarov2021-09-211-3/+5
| | | | | | | | | | xfstest generic/041 works with 3003 hardlinks. Because of this we raise hardlinks limit to 4000. There are no drawbacks or regressions. Theoretically we can raise all the way up to ffff, but there is no practical use for this. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Fix insertion of attr in ni_ins_attr_extKonstantin Komarov2021-09-211-0/+7
| | | | | | | Do not try to insert attribute if there is no room in record. Reviewed-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Fix a memory leak on object optsColin Ian King2021-09-201-2/+2
| | | | | | | | | | | | | Currently a failed allocation on sbi->upcase will cause an exit via the label free_sbi causing a memory leak on object opts. Fix this by re-ordering the exit paths free_opts and free_sbi so that kfree's occur in the reverse allocation order. Addresses-Coverity: ("Resource leak") Fixes: 27fac77707a1 ("fs/ntfs3: Init spi more in init_fs_context than fill_super") Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Initiliaze sb blocksize only in one place + refactorKari Argillander2021-09-201-10/+3
| | | | | | | | | | | | | | Right now sb blocksize first get initiliazed in fill_super but in can be changed in helper function. It makes more sense to that this happened only in one place. Because we move this to helper function it makes more sense that s_maxbytes will also be there. I rather have every sb releted thing in fill_super, but because there is already sb releted stuff in this helper. This will have to do for now. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Initialize pointer before use place in fill_superKari Argillander2021-09-201-4/+3
| | | | | | | | | | | Initializing should be as close as possible when we use it so that we do not need to scroll up to see what is happening. Also bdev_get_queue() can never return NULL so we do not need to check for !rq. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Remove tmp pointer upcase in fill_superKari Argillander2021-09-201-7/+4
| | | | | | | | We can survive without this tmp point upcase. So remove it we don't have so many tmp pointer in this function. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Remove tmp pointer bd_inode in fill_superKari Argillander2021-09-201-2/+1
| | | | | | | | | Drop tmp pointer bd_inode because this is only used ones in fill_super. Also we have so many initializing happening at the beginning that it is already way too much to follow. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Remove tmp var is_ro in ntfs_fill_superKari Argillander2021-09-201-5/+2
| | | | | | | | | | We only use this in two places so we do not really need it. Also wrapper sb_rdonly() is pretty self explanatory. This will make little bit easier to read this super long variable list in the beginning of ntfs_fill_super(). Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Use sb instead of sbi->sb in fill_superKari Argillander2021-09-201-3/+3
| | | | | | | | Use sb instead of sbi->sb in fill_super. We have sb so why not use it. Also makes code more readable. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Remove unnecessary variable loading in fill_superKari Argillander2021-09-201-11/+1
| | | | | | | | Remove some unnecessary variable loading. These look like copy paste work and they are not used to anything. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Return straight without goto in fill_superKari Argillander2021-09-201-40/+16
| | | | | | | | | In many places it is not needed to use goto out. We can just return right away. This will make code little bit more cleaner as we won't need to check error path. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Remove impossible fault condition in fill_superKari Argillander2021-09-201-6/+0
| | | | | | | | Remove root drop when we fault out. This can never happened because when we allocate root we eather fault when no root or success. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Change EINVAL to ENOMEM when d_make_root failsKari Argillander2021-09-201-1/+1
| | | | | | | | Change EINVAL to ENOMEM when d_make_root fails because that is right errno. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Fix wrong error message $Logfile -> $UpCaseKari Argillander2021-09-201-1/+1
| | | | | | | | Fix wrong error message $Logfile -> $UpCase. Probably copy paste. Fixes: 203c2b3a406a ("fs/ntfs3: Add initialization of super block") Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Use min/max macros instated of ternary operatorsKari Argillander2021-09-163-9/+11
| | | | | | | | | We can make code little bit more readable by using min/max macros. These were found with Coccinelle. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Use clamp/max macros instead of comparisonsKari Argillander2021-09-161-5/+3
| | | | | | | | | We can make code little more readable by using kernel macros clamp/max. This were found with kernel included Coccinelle minmax script. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Remove always false condition checkKari Argillander2021-09-161-4/+1
| | | | | | | | | We do not need this check as this is same thing as NTFS_MIN_MFT_ZONE > zlen. We already check NTFS_MIN_MFT_ZONE <= zlen and exit because is too big request. Remove it so code is cleaner. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Fix ntfs_look_for_free_space() does only report -ENOSPCKari Argillander2021-09-161-24/+27
| | | | | | | | | If ntfs_refresh_zone() returns error it will be changed to -ENOSPC. It is not right. Also caller of this functions also check other errors. Fixes: 78ab59fee07f ("fs/ntfs3: Rework file operations") Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Remove tabs before spaces from commentKari Argillander2021-09-161-1/+1
| | | | | | | | Remove tabs before spaces from comment as recommended by kernel coding style. Checkpatch also warn about these. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Remove braces from single statment blockKari Argillander2021-09-161-2/+1
| | | | | | | | | Remove braces from single statment block as they are not needed. Also Linux kernel coding style guide recommend this and checkpatch warn about this. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Place Comparisons constant right side of the testKari Argillander2021-09-161-1/+1
| | | | | | | | For better code readability place constant always right side of the test. This will also address checkpatch warning. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Remove '+' before constant in ni_insert_resident()Kari Argillander2021-09-161-1/+1
| | | | | | | No need for plus sign here. So remove it. Checkpatch will also be happy. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Always use binary search with entry searchKari Argillander2021-09-132-47/+6
| | | | | | | | | | We do not have any reason to keep old linear search in. Before this was used for error path or if table was so big that it cannot be allocated. Current binary search implementation won't need error path. Remove old references to linear entry search. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Make binary search to search smaller chunks in beginningKari Argillander2021-09-131-2/+5
| | | | | | | | | | We could try to optimize algorithm to first fill just small table and after that use bigger table all the way up to ARRAY_SIZE(offs). This way we can use bigger search array, but not lose benefits with entry count smaller < ARRAY_SIZE(offs). Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Limit binary search table sizeKari Argillander2021-09-131-69/+41
| | | | | | | | | | | | | | Current binary search allocates memory for table and fill whole table before we start actual binary search. This is quite inefficient because table fill will always be O(n). Also if table is huge we need to reallocate memory which is costly. This implementation use just stack memory and always when table is full we will check if last element is <= and if not start table fill again. The idea was that it would be same cost as table reallocation. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Remove unneeded header files from c filesKari Argillander2021-09-1315-40/+0
| | | | | | | | We have lot of unnecessary headers in these files. Remove them so that we help compiler a little bit. Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
* fs/ntfs3: Change right headers to lznt.cKari Argillander2021-09-131-5/+5
| | | | | | | | | | | | | | | | | There is lot of headers which we do not need in this file. Delete them and add what we really need. Here is list which identify why we need this header. <linux/kernel.h> // min() <linux/slab.h> // kzalloc() <linux/stddef.h> // offsetof() <linux/string.h> // memcpy(), memset() <linux/types.h> // u8, size_t, etc. "debug.h" // PtrOffset() Signed-off-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>