* [PATCH] fs: Add uoff_t
@ 2025-11-18 15:29 Matthew Wilcox (Oracle)
2025-11-18 15:57 ` Darrick J. Wong
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-11-18 15:29 UTC (permalink / raw)
To: Christian Brauner
Cc: Matthew Wilcox (Oracle), Alexander Viro, Jan Kara, linux-fsdevel
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>
---
include/linux/mm.h | 8 ++++----
include/linux/shmem_fs.h | 2 +-
include/linux/types.h | 1 +
include/uapi/asm-generic/posix_types.h | 1 +
mm/shmem.c | 4 ++--
mm/truncate.c | 2 +-
6 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index fe995cc3ba5c..a69ab017c370 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3650,10 +3650,10 @@ struct vm_unmapped_area_info {
extern unsigned long vm_unmapped_area(struct vm_unmapped_area_info *info);
/* truncate.c */
-extern void truncate_inode_pages(struct address_space *, loff_t);
-extern void truncate_inode_pages_range(struct address_space *,
- loff_t lstart, loff_t lend);
-extern void truncate_inode_pages_final(struct address_space *);
+void truncate_inode_pages(struct address_space *mapping, loff_t lstart);
+void truncate_inode_pages_range(struct address_space *mapping, loff_t lstart,
+ uoff_t lend);
+void truncate_inode_pages_final(struct address_space *mapping);
/* generic vm_area_ops exported for stackable file systems */
extern vm_fault_t filemap_fault(struct vm_fault *vmf);
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 08f497673b06..94c6237acdc9 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -126,7 +126,7 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
pgoff_t index, gfp_t gfp_mask);
int shmem_writeout(struct folio *folio, struct swap_iocb **plug,
struct list_head *folio_list);
-void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end);
+void shmem_truncate_range(struct inode *inode, loff_t start, uoff_t end);
int shmem_unuse(unsigned int type);
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
diff --git a/include/linux/types.h b/include/linux/types.h
index 6dfdb8e8e4c3..d4437e9c452c 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -50,6 +50,7 @@ typedef __kernel_old_gid_t old_gid_t;
#if defined(__GNUC__)
typedef __kernel_loff_t loff_t;
+typedef __kernel_uoff_t uoff_t;
#endif
/*
diff --git a/include/uapi/asm-generic/posix_types.h b/include/uapi/asm-generic/posix_types.h
index b5f7594eee7a..0a90ad92dbf3 100644
--- a/include/uapi/asm-generic/posix_types.h
+++ b/include/uapi/asm-generic/posix_types.h
@@ -86,6 +86,7 @@ typedef struct {
*/
typedef __kernel_long_t __kernel_off_t;
typedef long long __kernel_loff_t;
+typedef unsigned long long __kernel_uoff_t;
typedef __kernel_long_t __kernel_old_time_t;
#ifndef __KERNEL__
typedef __kernel_long_t __kernel_time_t;
diff --git a/mm/shmem.c b/mm/shmem.c
index 0a25ee095b86..728f2e04911e 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1105,7 +1105,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;
@@ -1256,7 +1256,7 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
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));
diff --git a/mm/truncate.c b/mm/truncate.c
index d08340afc768..12467c1bd711 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -364,7 +364,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 */
--
2.47.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] fs: Add uoff_t
2025-11-18 15:29 [PATCH] fs: Add uoff_t Matthew Wilcox (Oracle)
@ 2025-11-18 15:57 ` Darrick J. Wong
2025-11-18 16:46 ` kernel test robot
2025-11-19 2:19 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2025-11-18 15:57 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Christian Brauner, Alexander Viro, Jan Kara, linux-fsdevel
On Tue, Nov 18, 2025 at 03:29:33PM +0000, Matthew Wilcox (Oracle) wrote:
> 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".
Soo... truncate_inode_pages passes 16EB as the lend parameter to
truncate_inode_pages_range now? I suppose that makes sense, though the
casting to loff_t by that caller no longer does...
--D
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> include/linux/mm.h | 8 ++++----
> include/linux/shmem_fs.h | 2 +-
> include/linux/types.h | 1 +
> include/uapi/asm-generic/posix_types.h | 1 +
> mm/shmem.c | 4 ++--
> mm/truncate.c | 2 +-
> 6 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index fe995cc3ba5c..a69ab017c370 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -3650,10 +3650,10 @@ struct vm_unmapped_area_info {
> extern unsigned long vm_unmapped_area(struct vm_unmapped_area_info *info);
>
> /* truncate.c */
> -extern void truncate_inode_pages(struct address_space *, loff_t);
> -extern void truncate_inode_pages_range(struct address_space *,
> - loff_t lstart, loff_t lend);
> -extern void truncate_inode_pages_final(struct address_space *);
> +void truncate_inode_pages(struct address_space *mapping, loff_t lstart);
> +void truncate_inode_pages_range(struct address_space *mapping, loff_t lstart,
> + uoff_t lend);
> +void truncate_inode_pages_final(struct address_space *mapping);
>
> /* generic vm_area_ops exported for stackable file systems */
> extern vm_fault_t filemap_fault(struct vm_fault *vmf);
> diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
> index 08f497673b06..94c6237acdc9 100644
> --- a/include/linux/shmem_fs.h
> +++ b/include/linux/shmem_fs.h
> @@ -126,7 +126,7 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
> pgoff_t index, gfp_t gfp_mask);
> int shmem_writeout(struct folio *folio, struct swap_iocb **plug,
> struct list_head *folio_list);
> -void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end);
> +void shmem_truncate_range(struct inode *inode, loff_t start, uoff_t end);
> int shmem_unuse(unsigned int type);
>
> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> diff --git a/include/linux/types.h b/include/linux/types.h
> index 6dfdb8e8e4c3..d4437e9c452c 100644
> --- a/include/linux/types.h
> +++ b/include/linux/types.h
> @@ -50,6 +50,7 @@ typedef __kernel_old_gid_t old_gid_t;
>
> #if defined(__GNUC__)
> typedef __kernel_loff_t loff_t;
> +typedef __kernel_uoff_t uoff_t;
> #endif
>
> /*
> diff --git a/include/uapi/asm-generic/posix_types.h b/include/uapi/asm-generic/posix_types.h
> index b5f7594eee7a..0a90ad92dbf3 100644
> --- a/include/uapi/asm-generic/posix_types.h
> +++ b/include/uapi/asm-generic/posix_types.h
> @@ -86,6 +86,7 @@ typedef struct {
> */
> typedef __kernel_long_t __kernel_off_t;
> typedef long long __kernel_loff_t;
> +typedef unsigned long long __kernel_uoff_t;
> typedef __kernel_long_t __kernel_old_time_t;
> #ifndef __KERNEL__
> typedef __kernel_long_t __kernel_time_t;
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 0a25ee095b86..728f2e04911e 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -1105,7 +1105,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;
> @@ -1256,7 +1256,7 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
> 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));
> diff --git a/mm/truncate.c b/mm/truncate.c
> index d08340afc768..12467c1bd711 100644
> --- a/mm/truncate.c
> +++ b/mm/truncate.c
> @@ -364,7 +364,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 */
> --
> 2.47.2
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fs: Add uoff_t
2025-11-18 15:29 [PATCH] fs: Add uoff_t Matthew Wilcox (Oracle)
2025-11-18 15:57 ` Darrick J. Wong
@ 2025-11-18 16:46 ` kernel test robot
2025-11-19 2:19 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-11-18 16:46 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Christian Brauner
Cc: oe-kbuild-all, Matthew Wilcox (Oracle), Alexander Viro, Jan Kara,
linux-fsdevel
Hi Matthew,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on arnd-asm-generic/master linus/master v6.18-rc6 next-20251118]
[cannot apply to brauner-vfs/vfs.all]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/fs-Add-uoff_t/20251118-233038
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20251118152935.3735484-1-willy%40infradead.org
patch subject: [PATCH] fs: Add uoff_t
config: sh-allnoconfig (https://download.01.org/0day-ci/archive/20251119/202511190058.bebeyFBx-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251119/202511190058.bebeyFBx-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511190058.bebeyFBx-lkp@intel.com/
All errors (new ones prefixed by >>):
>> mm/shmem.c:5810:6: error: conflicting types for 'shmem_truncate_range'; have 'void(struct inode *, loff_t, loff_t)' {aka 'void(struct inode *, long long int, long long int)'}
5810 | void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
| ^~~~~~~~~~~~~~~~~~~~
In file included from mm/shmem.c:36:
include/linux/shmem_fs.h:129:6: note: previous declaration of 'shmem_truncate_range' with type 'void(struct inode *, loff_t, uoff_t)' {aka 'void(struct inode *, long long int, long long unsigned int)'}
129 | void shmem_truncate_range(struct inode *inode, loff_t start, uoff_t end);
| ^~~~~~~~~~~~~~~~~~~~
In file included from include/linux/linkage.h:7,
from arch/sh/include/asm/bug.h:5,
from include/linux/bug.h:5,
from include/linux/vfsdebug.h:5,
from include/linux/fs.h:5,
from mm/shmem.c:24:
mm/shmem.c:5814:19: error: conflicting types for 'shmem_truncate_range'; have 'void(struct inode *, loff_t, loff_t)' {aka 'void(struct inode *, long long int, long long int)'}
5814 | EXPORT_SYMBOL_GPL(shmem_truncate_range);
| ^~~~~~~~~~~~~~~~~~~~
include/linux/export.h:76:28: note: in definition of macro '__EXPORT_SYMBOL'
76 | extern typeof(sym) sym; \
| ^~~
include/linux/export.h:90:41: note: in expansion of macro '_EXPORT_SYMBOL'
90 | #define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "GPL")
| ^~~~~~~~~~~~~~
mm/shmem.c:5814:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
5814 | EXPORT_SYMBOL_GPL(shmem_truncate_range);
| ^~~~~~~~~~~~~~~~~
include/linux/shmem_fs.h:129:6: note: previous declaration of 'shmem_truncate_range' with type 'void(struct inode *, loff_t, uoff_t)' {aka 'void(struct inode *, long long int, long long unsigned int)'}
129 | void shmem_truncate_range(struct inode *inode, loff_t start, uoff_t end);
| ^~~~~~~~~~~~~~~~~~~~
mm/shmem.c: In function '__shmem_file_setup':
mm/shmem.c:5838:23: warning: unused variable 'flags' [-Wunused-variable]
5838 | unsigned long flags = (vm_flags & VM_NORESERVE) ? SHMEM_F_NORESERVE : 0;
| ^~~~~
vim +5810 mm/shmem.c
c01d5b300774d1 Hugh Dickins 2016-07-26 5809
41ffe5d5ceef7f Hugh Dickins 2011-08-03 @5810 void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
94c1e62df4494b Hugh Dickins 2011-06-27 5811 {
41ffe5d5ceef7f Hugh Dickins 2011-08-03 5812 truncate_inode_pages_range(inode->i_mapping, lstart, lend);
94c1e62df4494b Hugh Dickins 2011-06-27 5813 }
94c1e62df4494b Hugh Dickins 2011-06-27 5814 EXPORT_SYMBOL_GPL(shmem_truncate_range);
94c1e62df4494b Hugh Dickins 2011-06-27 5815
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fs: Add uoff_t
2025-11-18 15:29 [PATCH] fs: Add uoff_t Matthew Wilcox (Oracle)
2025-11-18 15:57 ` Darrick J. Wong
2025-11-18 16:46 ` kernel test robot
@ 2025-11-19 2:19 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-11-19 2:19 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Christian Brauner
Cc: llvm, oe-kbuild-all, Matthew Wilcox (Oracle), Alexander Viro,
Jan Kara, linux-fsdevel
Hi Matthew,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on arnd-asm-generic/master linus/master v6.18-rc6 next-20251118]
[cannot apply to brauner-vfs/vfs.all]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/fs-Add-uoff_t/20251118-233038
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20251118152935.3735484-1-willy%40infradead.org
patch subject: [PATCH] fs: Add uoff_t
config: arm-allnoconfig (https://download.01.org/0day-ci/archive/20251119/202511190917.pXdJRhD8-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 0bba1e76581bad04e7d7f09f5115ae5e2989e0d9)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251119/202511190917.pXdJRhD8-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511190917.pXdJRhD8-lkp@intel.com/
All errors (new ones prefixed by >>):
>> mm/shmem.c:5810:6: error: conflicting types for 'shmem_truncate_range'
5810 | void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
| ^
include/linux/shmem_fs.h:129:6: note: previous declaration is here
129 | void shmem_truncate_range(struct inode *inode, loff_t start, uoff_t end);
| ^
mm/shmem.c:5838:16: warning: unused variable 'flags' [-Wunused-variable]
5838 | unsigned long flags = (vm_flags & VM_NORESERVE) ? SHMEM_F_NORESERVE : 0;
| ^~~~~
1 warning and 1 error generated.
vim +/shmem_truncate_range +5810 mm/shmem.c
c01d5b300774d13 Hugh Dickins 2016-07-26 5809
41ffe5d5ceef7f7 Hugh Dickins 2011-08-03 @5810 void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
94c1e62df4494b7 Hugh Dickins 2011-06-27 5811 {
41ffe5d5ceef7f7 Hugh Dickins 2011-08-03 5812 truncate_inode_pages_range(inode->i_mapping, lstart, lend);
94c1e62df4494b7 Hugh Dickins 2011-06-27 5813 }
94c1e62df4494b7 Hugh Dickins 2011-06-27 5814 EXPORT_SYMBOL_GPL(shmem_truncate_range);
94c1e62df4494b7 Hugh Dickins 2011-06-27 5815
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-19 2:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-18 15:29 [PATCH] fs: Add uoff_t Matthew Wilcox (Oracle)
2025-11-18 15:57 ` Darrick J. Wong
2025-11-18 16:46 ` kernel test robot
2025-11-19 2:19 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).