* [PATCH v2 1/2] fs/ntfs3: load ATTR_BITMAP run extents from $MFT extension records
[not found] <20260613201610.14467-1-senjin@hatchling.org>
@ 2026-06-13 20:16 ` Senjin
2026-06-13 20:16 ` [PATCH v2 2/2] fs/ntfs3: fix lseek EINVAL on sparse/compressed files with 64-bit clusters Senjin
` (2 subsequent siblings)
3 siblings, 0 replies; 4+ messages in thread
From: Senjin @ 2026-06-13 20:16 UTC (permalink / raw)
To: ntfs3; +Cc: almaz.alexandrovich, linux-kernel, Senjin
v2: fix malformed hunk header in patch (no code change)
When $MFT's ATTR_BITMAP attribute is heavily fragmented, its run list
can span multiple MFT extension records (attribute list entries with
vcn > 0). The non-primary segment handler in ntfs_read_mft() only
processed ATTR_DATA extension segments for MFT_REC_MFT, silently
skipping any ATTR_BITMAP segments. This left sbi->mft.bitmap.run
incomplete, causing wnd_init() to fail with -ENOENT when wnd_rescan()
tried to look up a VCN not covered by the truncated run list.
Observed on a 16 TB NTFS volume (0xFFFFFEFF total clusters) whose MFT
bitmap run list was split across 97 extents in extension records.
wnd_rescan() successfully looked up VCNs 0-122 from the runs loaded
from the base record, then failed at VCN 123 (the last cluster of the
bitmap) whose run was only present in an extension record.
Fix by extending the MFT_REC_MFT special case to also handle
ATTR_BITMAP extension segments, storing their runs into
sbi->mft.bitmap.run the same way the primary segment does.
Signed-off-by: Senjin <senjin@hatchling.org>
---
fs/ntfs3/inode.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index XXXXXXX..XXXXXXX 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -127,10 +127,16 @@ static struct inode *ntfs_read_mft(struct inode *inode,
if (le && le->vcn) {
/* This is non primary attribute segment. Ignore if not MFT. */
- if (ino != MFT_REC_MFT || attr->type != ATTR_DATA)
+ if (ino != MFT_REC_MFT)
goto next_attr;
- run = &ni->file.run;
+ if (attr->type == ATTR_DATA)
+ run = &ni->file.run;
+ else if (attr->type == ATTR_BITMAP)
+ run = &sbi->mft.bitmap.run;
+ else
+ goto next_attr;
+
asize = le32_to_cpu(attr->size);
goto attr_unpack_run;
}
--
2.x
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] fs/ntfs3: fix lseek EINVAL on sparse/compressed files with 64-bit clusters
[not found] <20260613201610.14467-1-senjin@hatchling.org>
2026-06-13 20:16 ` [PATCH v2 1/2] fs/ntfs3: load ATTR_BITMAP run extents from $MFT extension records Senjin
@ 2026-06-13 20:16 ` Senjin
2026-06-13 20:16 ` Senjin
2026-06-13 20:16 ` [PATCH v2 1/2] fs/ntfs3: load ATTR_BITMAP run extents from $MFT extension records Senjin
3 siblings, 0 replies; 4+ messages in thread
From: Senjin @ 2026-06-13 20:16 UTC (permalink / raw)
To: ntfs3; +Cc: almaz.alexandrovich, linux-kernel, Senjin
When CONFIG_NTFS3_64BIT_CLUSTER is enabled, sbi->maxbytes_sparse is set
to -1. As a signed loff_t this is -1LL, the most negative value. Any
lseek on a sparse or compressed file passes this as maxsize to
vfs_setpos(), which returns -EINVAL whenever offset > maxsize, and
since -1LL is less than any non-negative offset, every seek fails,
including lseek(fd, 0, SEEK_SET).
The intent of -1 here appears to be "no limit" (matching the spirit of
MAX_LFS_FILESIZE assigned to sbi->maxbytes and sb->s_maxbytes in the
same block), but the signed type makes it the minimum instead of the
maximum.
Fix by assigning MAX_LFS_FILESIZE to sbi->maxbytes_sparse in the
64-bit cluster path, consistent with the other two limits set there.
Observed on a 16 TB NTFS volume with 0xFFFFFEFF total clusters compiled
with CONFIG_NTFS3_64BIT_CLUSTER=y. Sequential reads via dd/cp worked
correctly; any lseek call on sparse files returned EINVAL, preventing
archive managers and other tools from random-accessing files on the
volume. The non-64-bit-cluster path correctly sets maxbytes_sparse to
(1ull << (cluster_bits + 32)) - 1, a large positive value.
Signed-off-by: Senjin <senjin@hatchling.org>
---
fs/ntfs3/super.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index XXXXXXX..XXXXXXX 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -1193,7 +1193,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
#ifdef CONFIG_NTFS3_64BIT_CLUSTER
if (clusters >= (1ull << (64 - cluster_bits)))
sbi->maxbytes = -1;
- sbi->maxbytes_sparse = -1;
+ sbi->maxbytes_sparse = MAX_LFS_FILESIZE;
sb->s_maxbytes = MAX_LFS_FILESIZE;
#else
/* Maximum size for sparse file. */
--
2.x
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] fs/ntfs3: load ATTR_BITMAP run extents from $MFT extension records
[not found] <20260613201610.14467-1-senjin@hatchling.org>
` (2 preceding siblings ...)
2026-06-13 20:16 ` Senjin
@ 2026-06-13 20:16 ` Senjin
3 siblings, 0 replies; 4+ messages in thread
From: Senjin @ 2026-06-13 20:16 UTC (permalink / raw)
To: ntfs3; +Cc: almaz.alexandrovich, linux-kernel, Senjin
v2: fix malformed hunk header in patch (no code change)
When $MFT's ATTR_BITMAP attribute is heavily fragmented, its run list
can span multiple MFT extension records (attribute list entries with
vcn > 0). The non-primary segment handler in ntfs_read_mft() only
processed ATTR_DATA extension segments for MFT_REC_MFT, silently
skipping any ATTR_BITMAP segments. This left sbi->mft.bitmap.run
incomplete, causing wnd_init() to fail with -ENOENT when wnd_rescan()
tried to look up a VCN not covered by the truncated run list.
Observed on a 16 TB NTFS volume (0xFFFFFEFF total clusters) whose MFT
bitmap run list was split across 97 extents in extension records.
wnd_rescan() successfully looked up VCNs 0-122 from the runs loaded
from the base record, then failed at VCN 123 (the last cluster of the
bitmap) whose run was only present in an extension record.
Fix by extending the MFT_REC_MFT special case to also handle
ATTR_BITMAP extension segments, storing their runs into
sbi->mft.bitmap.run the same way the primary segment does.
Signed-off-by: Senjin <senjin@hatchling.org>
---
fs/ntfs3/inode.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index XXXXXXX..XXXXXXX 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -127,10 +127,16 @@ static struct inode *ntfs_read_mft(struct inode *inode,
if (le && le->vcn) {
/* This is non primary attribute segment. Ignore if not MFT. */
- if (ino != MFT_REC_MFT || attr->type != ATTR_DATA)
+ if (ino != MFT_REC_MFT)
goto next_attr;
- run = &ni->file.run;
+ if (attr->type == ATTR_DATA)
+ run = &ni->file.run;
+ else if (attr->type == ATTR_BITMAP)
+ run = &sbi->mft.bitmap.run;
+ else
+ goto next_attr;
+
asize = le32_to_cpu(attr->size);
goto attr_unpack_run;
}
--
2.x
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] fs/ntfs3: fix lseek EINVAL on sparse/compressed files with 64-bit clusters
[not found] <20260613201610.14467-1-senjin@hatchling.org>
2026-06-13 20:16 ` [PATCH v2 1/2] fs/ntfs3: load ATTR_BITMAP run extents from $MFT extension records Senjin
2026-06-13 20:16 ` [PATCH v2 2/2] fs/ntfs3: fix lseek EINVAL on sparse/compressed files with 64-bit clusters Senjin
@ 2026-06-13 20:16 ` Senjin
2026-06-13 20:16 ` [PATCH v2 1/2] fs/ntfs3: load ATTR_BITMAP run extents from $MFT extension records Senjin
3 siblings, 0 replies; 4+ messages in thread
From: Senjin @ 2026-06-13 20:16 UTC (permalink / raw)
To: ntfs3; +Cc: almaz.alexandrovich, linux-kernel, Senjin
When CONFIG_NTFS3_64BIT_CLUSTER is enabled, sbi->maxbytes_sparse is set
to -1. As a signed loff_t this is -1LL, the most negative value. Any
lseek on a sparse or compressed file passes this as maxsize to
vfs_setpos(), which returns -EINVAL whenever offset > maxsize, and
since -1LL is less than any non-negative offset, every seek fails,
including lseek(fd, 0, SEEK_SET).
The intent of -1 here appears to be "no limit" (matching the spirit of
MAX_LFS_FILESIZE assigned to sbi->maxbytes and sb->s_maxbytes in the
same block), but the signed type makes it the minimum instead of the
maximum.
Fix by assigning MAX_LFS_FILESIZE to sbi->maxbytes_sparse in the
64-bit cluster path, consistent with the other two limits set there.
Observed on a 16 TB NTFS volume with 0xFFFFFEFF total clusters compiled
with CONFIG_NTFS3_64BIT_CLUSTER=y. Sequential reads via dd/cp worked
correctly; any lseek call on sparse files returned EINVAL, preventing
archive managers and other tools from random-accessing files on the
volume. The non-64-bit-cluster path correctly sets maxbytes_sparse to
(1ull << (cluster_bits + 32)) - 1, a large positive value.
Signed-off-by: Senjin <senjin@hatchling.org>
---
fs/ntfs3/super.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index XXXXXXX..XXXXXXX 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -1193,7 +1193,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
#ifdef CONFIG_NTFS3_64BIT_CLUSTER
if (clusters >= (1ull << (64 - cluster_bits)))
sbi->maxbytes = -1;
- sbi->maxbytes_sparse = -1;
+ sbi->maxbytes_sparse = MAX_LFS_FILESIZE;
sb->s_maxbytes = MAX_LFS_FILESIZE;
#else
/* Maximum size for sparse file. */
--
2.x
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-13 20:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260613201610.14467-1-senjin@hatchling.org>
2026-06-13 20:16 ` [PATCH v2 1/2] fs/ntfs3: load ATTR_BITMAP run extents from $MFT extension records Senjin
2026-06-13 20:16 ` [PATCH v2 2/2] fs/ntfs3: fix lseek EINVAL on sparse/compressed files with 64-bit clusters Senjin
2026-06-13 20:16 ` Senjin
2026-06-13 20:16 ` [PATCH v2 1/2] fs/ntfs3: load ATTR_BITMAP run extents from $MFT extension records Senjin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.