2024-06-07 12:28:21

by Konstantin Komarov

[permalink] [raw]
Subject: [PATCH 00/18] Bugfix??? and refactoring

Fixed the type identification of directory elements during enumeration.
Fixed the behavior under edge cases.
Added attr checks in log replay.
Removed unused function, MACRO.

Konstantin Komarov (18):
fs/ntfs3: Remove unused function
fs/ntfs3: Simplify initialization of $AttrDef and $UpCase
fs/ntfs3: Fix transform resident to nonresident for compressed files
fs/ntfs3: Deny getting attr data block in compressed frame
fs/ntfs3: Missed NI_FLAG_UPDATE_PARENT setting
fs/ntfs3: Fix getting file type
fs/ntfs3: Add missing .dirty_folio in address_space_operations
fs/ntfs3: Fix attr_insert_range at end of file
fs/ntfs3: Replace inode_trylock with inode_lock
fs/ntfs3: One more reason to mark inode bad
fs/ntfs3: Correct undo if ntfs_create_inode failed
fs/ntfs3: Add a check for attr_names and oatbl
fs/ntfs3: Use macros NTFS_LABEL_MAX_LENGTH instead of hardcoded value
fs/ntfs3: Merge synonym COMPRESSION_UNIT and NTFS_LZNT_CUNIT
fs/ntfs3: Remove sync_blockdev_nowait()
fs/ntfs3: Remove unused macros MAXIMUM_REPARSE_DATA_BUFFER_SIZE
fs/ntfs3: Rename variables
fs/ntfs3: Add some comments

fs/ntfs3/attrib.c | 36 ++++++++++++++++++++-----
fs/ntfs3/dir.c | 3 ++-
fs/ntfs3/file.c | 5 +---
fs/ntfs3/frecord.c | 6 +++--
fs/ntfs3/fslog.c | 64 +++++++++++++++++++++++++++++++--------------
fs/ntfs3/fsntfs.c | 11 ++++----
fs/ntfs3/inode.c | 43 +++++++++++++++++-------------
fs/ntfs3/ntfs.h | 6 -----
fs/ntfs3/ntfs_fs.h | 18 +------------
fs/ntfs3/super.c | 65 ++++++++++++++++++----------------------------
10 files changed, 137 insertions(+), 120 deletions(-)

--
2.34.1



2024-06-07 12:39:11

by Konstantin Komarov

[permalink] [raw]
Subject: [PATCH 08/18] fs/ntfs3: Fix attr_insert_range at end of file

If the offset is equal to or greater than the end of
file, an error is returned. For such operations (i.e., inserting
a hole at the end of file), ftruncate(2) should be used.

Signed-off-by: Konstantin Komarov <[email protected]>
---
fs/ntfs3/attrib.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index 0d13da5523b1..68d1c61fe3b5 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -2373,8 +2373,13 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
mask = (sbi->cluster_size << attr_b->nres.c_unit) - 1;
}

- if (vbo > data_size) {
- /* Insert range after the file size is not allowed. */
+ if (vbo >= data_size) {
+ /*
+ * Insert range after the file size is not allowed.
+ * If the offset is equal to or greater than the end of
+ * file, an error is returned. For such operations (i.e., inserting
+ * a hole at the end of file), ftruncate(2) should be used.
+ */
return -EINVAL;
}

--
2.34.1


2024-06-07 12:40:56

by Konstantin Komarov

[permalink] [raw]
Subject: [PATCH 09/18] fs/ntfs3: Replace inode_trylock with inode_lock

The issue was detected due to xfstest 465 failing.

Fixes: 4342306f0f0d5i ("fs/ntfs3: Add file operations and implementation")
Signed-off-by: Konstantin Komarov <[email protected]>
---
fs/ntfs3/file.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index 2f903b6ce157..9ae202901f3c 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -299,10 +299,7 @@ static int ntfs_file_mmap(struct file *file, struct vm_area_struct *vma)
}

if (ni->i_valid < to) {
- if (!inode_trylock(inode)) {
- err = -EAGAIN;
- goto out;
- }
+ inode_lock(inode);
err = ntfs_extend_initialized_size(file, ni,
ni->i_valid, to);
inode_unlock(inode);
--
2.34.1