Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Matthew Wilcox (Oracle) and committed by
Christian Brauner
37d369fa a77a5959

+11 -9
+4 -4
include/linux/mm.h
··· 3495 3495 extern unsigned long vm_unmapped_area(struct vm_unmapped_area_info *info); 3496 3496 3497 3497 /* truncate.c */ 3498 - extern void truncate_inode_pages(struct address_space *, loff_t); 3499 - extern void truncate_inode_pages_range(struct address_space *, 3500 - loff_t lstart, loff_t lend); 3501 - extern void truncate_inode_pages_final(struct address_space *); 3498 + void truncate_inode_pages(struct address_space *mapping, loff_t lstart); 3499 + void truncate_inode_pages_range(struct address_space *mapping, loff_t lstart, 3500 + uoff_t lend); 3501 + void truncate_inode_pages_final(struct address_space *mapping); 3502 3502 3503 3503 /* generic vm_area_ops exported for stackable file systems */ 3504 3504 extern vm_fault_t filemap_fault(struct vm_fault *vmf);
+1 -1
include/linux/shmem_fs.h
··· 111 111 pgoff_t index, gfp_t gfp_mask); 112 112 int shmem_writeout(struct folio *folio, struct swap_iocb **plug, 113 113 struct list_head *folio_list); 114 - void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end); 114 + void shmem_truncate_range(struct inode *inode, loff_t start, uoff_t end); 115 115 int shmem_unuse(unsigned int type); 116 116 117 117 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
+1
include/linux/types.h
··· 50 50 51 51 #if defined(__GNUC__) 52 52 typedef __kernel_loff_t loff_t; 53 + typedef __kernel_uoff_t uoff_t; 53 54 #endif 54 55 55 56 /*
+1
include/uapi/asm-generic/posix_types.h
··· 86 86 */ 87 87 typedef __kernel_long_t __kernel_off_t; 88 88 typedef long long __kernel_loff_t; 89 + typedef unsigned long long __kernel_uoff_t; 89 90 typedef __kernel_long_t __kernel_old_time_t; 90 91 #ifndef __KERNEL__ 91 92 typedef __kernel_long_t __kernel_time_t;
+3 -3
mm/shmem.c
··· 1076 1076 * Remove range of pages and swap entries from page cache, and free them. 1077 1077 * If !unfalloc, truncate or punch hole; if unfalloc, undo failed fallocate. 1078 1078 */ 1079 - static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, 1079 + static void shmem_undo_range(struct inode *inode, loff_t lstart, uoff_t lend, 1080 1080 bool unfalloc) 1081 1081 { 1082 1082 struct address_space *mapping = inode->i_mapping; ··· 1227 1227 shmem_recalc_inode(inode, 0, -nr_swaps_freed); 1228 1228 } 1229 1229 1230 - void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) 1230 + void shmem_truncate_range(struct inode *inode, loff_t lstart, uoff_t lend) 1231 1231 { 1232 1232 shmem_undo_range(inode, lstart, lend, false); 1233 1233 inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); ··· 5776 5776 } 5777 5777 #endif 5778 5778 5779 - void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) 5779 + void shmem_truncate_range(struct inode *inode, loff_t lstart, uoff_t lend) 5780 5780 { 5781 5781 truncate_inode_pages_range(inode->i_mapping, lstart, lend); 5782 5782 }
+1 -1
mm/truncate.c
··· 339 339 * page aligned properly. 340 340 */ 341 341 void truncate_inode_pages_range(struct address_space *mapping, 342 - loff_t lstart, loff_t lend) 342 + loff_t lstart, uoff_t lend) 343 343 { 344 344 pgoff_t start; /* inclusive */ 345 345 pgoff_t end; /* exclusive */