diff options
| author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2025-11-23 22:05:15 +0000 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2025-11-25 10:07:42 +0100 |
| commit | 37d369fa97cc0774ea4eab726d16bcb5fbe3a104 (patch) | |
| tree | 6b5548ec93f0b63d897e3fbcc7f6d3b1a418f54c /mm | |
| parent | a77a59592febd4179efa6b59f2ef5bdfe9a5b895 (diff) | |
fs: Add uoff_t
In a recent commit, I inadvertently changed a comparison from being an
unsigned comparison (on 64-bit systems) to being a signed comparison
(which it had always been on 32-bit systems). This led to a sporadic
fstests failure.
To make sure this comparison is always unsigned, introduce a new type,
uoff_t which is the unsigned version of loff_t. Generally file sizes
are restricted to being a signed integer, but in these two places it is
convenient to pass -1 to indicate "up to the end of the file".
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://patch.msgid.link/20251123220518.1447261-1-willy@infradead.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'mm')
| -rw-r--r-- | mm/shmem.c | 6 | ||||
| -rw-r--r-- | mm/truncate.c | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index c819cecf1ed9..43b41a42c463 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1076,7 +1076,7 @@ static struct folio *shmem_get_partial_folio(struct inode *inode, pgoff_t index) * Remove range of pages and swap entries from page cache, and free them. * If !unfalloc, truncate or punch hole; if unfalloc, undo failed fallocate. */ -static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, +static void shmem_undo_range(struct inode *inode, loff_t lstart, uoff_t lend, bool unfalloc) { struct address_space *mapping = inode->i_mapping; @@ -1227,7 +1227,7 @@ whole_folios: shmem_recalc_inode(inode, 0, -nr_swaps_freed); } -void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) +void shmem_truncate_range(struct inode *inode, loff_t lstart, uoff_t lend) { shmem_undo_range(inode, lstart, lend, false); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); @@ -5776,7 +5776,7 @@ unsigned long shmem_get_unmapped_area(struct file *file, } #endif -void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) +void shmem_truncate_range(struct inode *inode, loff_t lstart, uoff_t lend) { truncate_inode_pages_range(inode->i_mapping, lstart, lend); } diff --git a/mm/truncate.c b/mm/truncate.c index a3d673533e32..fbe848fdc391 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -339,7 +339,7 @@ long mapping_evict_folio(struct address_space *mapping, struct folio *folio) * page aligned properly. */ void truncate_inode_pages_range(struct address_space *mapping, - loff_t lstart, loff_t lend) + loff_t lstart, uoff_t lend) { pgoff_t start; /* inclusive */ pgoff_t end; /* exclusive */ |
