[PATCH 1/3] fs/9p: remove unecessary and overrestrictive check

Eric Van Hensbergen posted 3 patches 2 years, 6 months ago
There is a newer version of this series
[PATCH 1/3] fs/9p: remove unecessary and overrestrictive check
Posted by Eric Van Hensbergen 2 years, 6 months ago
This eliminates a check for shared that was overrestrictive and
duplicated a check in generic_file_readonly_mmap.

Signed-off-by: Eric Van Hensbergen <ericvh@kernel.org>
---
 fs/9p/vfs_file.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 2996fb00387fa..bda3abd6646b8 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -506,8 +506,6 @@ v9fs_file_mmap(struct file *filp, struct vm_area_struct *vma)
 
 	if (!(v9ses->cache & CACHE_WRITEBACK)) {
 		p9_debug(P9_DEBUG_CACHE, "(no mmap mode)");
-		if (vma->vm_flags & VM_MAYSHARE)
-			return -ENODEV;
 		invalidate_inode_pages2(filp->f_mapping);
 		return generic_file_readonly_mmap(filp, vma);
 	}

-- 
2.39.2
Re: [PATCH 1/3] fs/9p: remove unecessary and overrestrictive check
Posted by Dominique Martinet 2 years, 6 months ago
Eric Van Hensbergen wrote on Mon, Jul 17, 2023 at 04:29:00PM +0000:
> This eliminates a check for shared that was overrestrictive and
> duplicated a check in generic_file_readonly_mmap.

generic_file_readonly_mmap checks for VM_SHARED + VM_MAYWRITE,
so it isn't exactly "duplicating" the check.. But I agree we don't need
it; we used to have the mmap op be generic_file_readonly_mmap directly
previously.

I'd argue we don't need to invalidate inode pages either if there is no
writeback cache, there shouldn't be anything in it? but that can be done
separately, and extra invalidation won't bring harm anyway.

Reviewed-by: Dominique Martinet <asmadeus@codewreck.org>

> 
> Signed-off-by: Eric Van Hensbergen <ericvh@kernel.org>
> ---
>  fs/9p/vfs_file.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
> index 2996fb00387fa..bda3abd6646b8 100644
> --- a/fs/9p/vfs_file.c
> +++ b/fs/9p/vfs_file.c
> @@ -506,8 +506,6 @@ v9fs_file_mmap(struct file *filp, struct vm_area_struct *vma)
>  
>  	if (!(v9ses->cache & CACHE_WRITEBACK)) {
>  		p9_debug(P9_DEBUG_CACHE, "(no mmap mode)");
> -		if (vma->vm_flags & VM_MAYSHARE)
> -			return -ENODEV;
>  		invalidate_inode_pages2(filp->f_mapping);
>  		return generic_file_readonly_mmap(filp, vma);
>  	}
> 

-- 
Dominique Martinet | Asmadeus
Re: [PATCH 1/3] fs/9p: remove unecessary and overrestrictive check
Posted by Christian Schoenebeck 2 years, 6 months ago
On Tuesday, July 18, 2023 4:45:25 AM CEST Dominique Martinet wrote:
> Eric Van Hensbergen wrote on Mon, Jul 17, 2023 at 04:29:00PM +0000:
> > This eliminates a check for shared that was overrestrictive and
> > duplicated a check in generic_file_readonly_mmap.
> 
> generic_file_readonly_mmap checks for VM_SHARED + VM_MAYWRITE,
> so it isn't exactly "duplicating" the check.. But I agree we don't need
> it; we used to have the mmap op be generic_file_readonly_mmap directly
> previously.

It should be removed from the commit log then though.

> I'd argue we don't need to invalidate inode pages either if there is no
> writeback cache, there shouldn't be anything in it? but that can be done
> separately, and extra invalidation won't bring harm anyway.

Unnecessary performance penalty? So I would drop that in a separate patch.

> Reviewed-by: Dominique Martinet <asmadeus@codewreck.org>

Feel free to add my RB as well:

Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com>

> > 
> > Signed-off-by: Eric Van Hensbergen <ericvh@kernel.org>
> > ---
> >  fs/9p/vfs_file.c | 2 --
> >  1 file changed, 2 deletions(-)
> > 
> > diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
> > index 2996fb00387fa..bda3abd6646b8 100644
> > --- a/fs/9p/vfs_file.c
> > +++ b/fs/9p/vfs_file.c
> > @@ -506,8 +506,6 @@ v9fs_file_mmap(struct file *filp, struct vm_area_struct *vma)
> >  
> >  	if (!(v9ses->cache & CACHE_WRITEBACK)) {
> >  		p9_debug(P9_DEBUG_CACHE, "(no mmap mode)");
> > -		if (vma->vm_flags & VM_MAYSHARE)
> > -			return -ENODEV;
> >  		invalidate_inode_pages2(filp->f_mapping);
> >  		return generic_file_readonly_mmap(filp, vma);
> >  	}
> > 
> 
>