* [PATCH] xfs: fix incorrect return type for fsdax fault handlers
@ 2022-10-24 21:32 Darrick J. Wong
2022-10-24 21:56 ` Matthew Wilcox
0 siblings, 1 reply; 6+ messages in thread
From: Darrick J. Wong @ 2022-10-24 21:32 UTC (permalink / raw)
To: xfs; +Cc: Shiyang Ruan, Andrew Morton, Linux Memory Management List
From: Darrick J. Wong <djwong@kernel.org>
The kernel robot complained about this:
>> fs/xfs/xfs_file.c:1266:31: sparse: sparse: incorrect type in return expression (different base types) @@ expected int @@ got restricted vm_fault_t @@
fs/xfs/xfs_file.c:1266:31: sparse: expected int
fs/xfs/xfs_file.c:1266:31: sparse: got restricted vm_fault_t
fs/xfs/xfs_file.c:1314:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted vm_fault_t [usertype] ret @@ got int @@
fs/xfs/xfs_file.c:1314:21: sparse: expected restricted vm_fault_t [usertype] ret
fs/xfs/xfs_file.c:1314:21: sparse: got int
Fix the incorrect return type for these two functions, and make the
!fsdax version return SIGBUS since there is no vm_fault_t that maps to
zero.
Fixes: ea6c49b784f0 ("xfs: support CoW in fsdax mode")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
fs/xfs/xfs_file.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index c6c80265c0b2..6b328ffaf629 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -1261,7 +1261,7 @@ xfs_file_llseek(
}
#ifdef CONFIG_FS_DAX
-static int
+static inline vm_fault_t
xfs_dax_fault(
struct vm_fault *vmf,
enum page_entry_size pe_size,
@@ -1274,14 +1274,14 @@ xfs_dax_fault(
&xfs_read_iomap_ops);
}
#else
-static int
+static inline vm_fault_t
xfs_dax_fault(
struct vm_fault *vmf,
enum page_entry_size pe_size,
bool write_fault,
pfn_t *pfn)
{
- return 0;
+ return VM_FAULT_SIGBUS;
}
#endif
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfs: fix incorrect return type for fsdax fault handlers
2022-10-24 21:32 [PATCH] xfs: fix incorrect return type for fsdax fault handlers Darrick J. Wong
@ 2022-10-24 21:56 ` Matthew Wilcox
2022-10-24 23:22 ` Darrick J. Wong
2022-10-25 0:18 ` Darrick J. Wong
0 siblings, 2 replies; 6+ messages in thread
From: Matthew Wilcox @ 2022-10-24 21:56 UTC (permalink / raw)
To: Darrick J. Wong
Cc: xfs, Shiyang Ruan, Andrew Morton, Linux Memory Management List
On Mon, Oct 24, 2022 at 02:32:18PM -0700, Darrick J. Wong wrote:
> Fix the incorrect return type for these two functions, and make the
> !fsdax version return SIGBUS since there is no vm_fault_t that maps to
> zero.
Hmm? You should be able to return 0 without sparse complaining.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfs: fix incorrect return type for fsdax fault handlers
2022-10-24 21:56 ` Matthew Wilcox
@ 2022-10-24 23:22 ` Darrick J. Wong
2022-10-25 0:18 ` Darrick J. Wong
1 sibling, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2022-10-24 23:22 UTC (permalink / raw)
To: Matthew Wilcox
Cc: xfs, Shiyang Ruan, Andrew Morton, Linux Memory Management List
On Mon, Oct 24, 2022 at 10:56:48PM +0100, Matthew Wilcox wrote:
> On Mon, Oct 24, 2022 at 02:32:18PM -0700, Darrick J. Wong wrote:
> > Fix the incorrect return type for these two functions, and make the
> > !fsdax version return SIGBUS since there is no vm_fault_t that maps to
> > zero.
>
> Hmm? You should be able to return 0 without sparse complaining.
What does (vm_fault_t)0 do? And why wouldn't we want to induce a
segfault if someone calls the fsdax fault function when fsdax isn't
supported?
--D
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfs: fix incorrect return type for fsdax fault handlers
2022-10-24 21:56 ` Matthew Wilcox
2022-10-24 23:22 ` Darrick J. Wong
@ 2022-10-25 0:18 ` Darrick J. Wong
2022-10-25 18:02 ` Matthew Wilcox
1 sibling, 1 reply; 6+ messages in thread
From: Darrick J. Wong @ 2022-10-25 0:18 UTC (permalink / raw)
To: Matthew Wilcox
Cc: xfs, Shiyang Ruan, Andrew Morton, Linux Memory Management List
On Mon, Oct 24, 2022 at 10:56:48PM +0100, Matthew Wilcox wrote:
> On Mon, Oct 24, 2022 at 02:32:18PM -0700, Darrick J. Wong wrote:
> > Fix the incorrect return type for these two functions, and make the
> > !fsdax version return SIGBUS since there is no vm_fault_t that maps to
> > zero.
>
> Hmm? You should be able to return 0 without sparse complaining.
Yes I know, but is that the correct return value for "someone is calling
the wrong function, everything is fubar, please stop the world now"?
--D
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfs: fix incorrect return type for fsdax fault handlers
2022-10-25 0:18 ` Darrick J. Wong
@ 2022-10-25 18:02 ` Matthew Wilcox
2022-10-25 22:30 ` Darrick J. Wong
0 siblings, 1 reply; 6+ messages in thread
From: Matthew Wilcox @ 2022-10-25 18:02 UTC (permalink / raw)
To: Darrick J. Wong
Cc: xfs, Shiyang Ruan, Andrew Morton, Linux Memory Management List
On Mon, Oct 24, 2022 at 05:18:33PM -0700, Darrick J. Wong wrote:
> On Mon, Oct 24, 2022 at 10:56:48PM +0100, Matthew Wilcox wrote:
> > On Mon, Oct 24, 2022 at 02:32:18PM -0700, Darrick J. Wong wrote:
> > > Fix the incorrect return type for these two functions, and make the
> > > !fsdax version return SIGBUS since there is no vm_fault_t that maps to
> > > zero.
> >
> > Hmm? You should be able to return 0 without sparse complaining.
>
> Yes I know, but is that the correct return value for "someone is calling
> the wrong function, everything is fubar, please stop the world now"?
No, it's "success, but I didn't bother to lock the page myself, please
do it for me", which doesn't really make any sense. I think in this
case, having not initialised vmf->page, we'd probably take a NULL
ptr dereference in lock_page().
From your changelog, it seemed like you were trying to come up with the
vm_fault_t equivalent of 0, rather than trying to change the semantics
of the !fsdax version.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfs: fix incorrect return type for fsdax fault handlers
2022-10-25 18:02 ` Matthew Wilcox
@ 2022-10-25 22:30 ` Darrick J. Wong
0 siblings, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2022-10-25 22:30 UTC (permalink / raw)
To: Matthew Wilcox
Cc: xfs, Shiyang Ruan, Andrew Morton, Linux Memory Management List
On Tue, Oct 25, 2022 at 07:02:53PM +0100, Matthew Wilcox wrote:
> On Mon, Oct 24, 2022 at 05:18:33PM -0700, Darrick J. Wong wrote:
> > On Mon, Oct 24, 2022 at 10:56:48PM +0100, Matthew Wilcox wrote:
> > > On Mon, Oct 24, 2022 at 02:32:18PM -0700, Darrick J. Wong wrote:
> > > > Fix the incorrect return type for these two functions, and make the
> > > > !fsdax version return SIGBUS since there is no vm_fault_t that maps to
> > > > zero.
> > >
> > > Hmm? You should be able to return 0 without sparse complaining.
> >
> > Yes I know, but is that the correct return value for "someone is calling
> > the wrong function, everything is fubar, please stop the world now"?
>
> No, it's "success, but I didn't bother to lock the page myself, please
> do it for me", which doesn't really make any sense. I think in this
> case, having not initialised vmf->page, we'd probably take a NULL
> ptr dereference in lock_page().
Yes, that's why I don't want to leave the !fsdax stub returning zero.
--D
> From your changelog, it seemed like you were trying to come up with the
> vm_fault_t equivalent of 0, rather than trying to change the semantics
> of the !fsdax version.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-10-25 22:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-24 21:32 [PATCH] xfs: fix incorrect return type for fsdax fault handlers Darrick J. Wong
2022-10-24 21:56 ` Matthew Wilcox
2022-10-24 23:22 ` Darrick J. Wong
2022-10-25 0:18 ` Darrick J. Wong
2022-10-25 18:02 ` Matthew Wilcox
2022-10-25 22:30 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox