This series attempts to fix a reported exception with mmap on newer kernels.
Fixes: 1543b4c5071c ("fs/9p: remove writeback fid and fix per-file modes") Link: https://lore.kernel.org/v9fs/ZK25XZ%2BGpR3KHIB%2F@pengutronix.de/ Reported-by: Robert Schwebel r.schwebel@pengutronix.de Signed-off-by: Eric Van Hensbergen ericvh@kernel.org --- Changes in v3: - Clarify debug print to read-only mmap mode versus no mmap mode in v9fs_file_mmap - Fix suggested regression tags and propagate across series - Link to v2: https://lore.kernel.org/r/20230716-fixes-overly-restrictive-mmap-v2-0-147d6b...
Changes in v2: - fix requested changes in commit messages - add patch to remove unnecessary invalidate_inode_pages in mmap readonly path - Link to v1: https://lore.kernel.org/r/20230716-fixes-overly-restrictive-mmap-v1-0-0683b2...
--- Eric Van Hensbergen (4): fs/9p: remove unnecessary and overrestrictive check fs/9p: fix typo in comparison logic for cache mode fs/9p: fix type mismatch in file cache mode helper fs/9p: remove unnecessary invalidate_inode_pages2
fs/9p/fid.h | 6 +++--- fs/9p/vfs_file.c | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) --- base-commit: 95f41d87810083d8b3dedcce46a4e356cf4a9673 change-id: 20230716-fixes-overly-restrictive-mmap-30a23501e787
Best regards,
This eliminates a check for shared that was overrestrictive and duplicated a check in generic_file_readonly_mmap.
Fixes: 1543b4c5071c ("fs/9p: remove writeback fid and fix per-file modes") Link: https://lore.kernel.org/v9fs/ZK25XZ%2BGpR3KHIB%2F@pengutronix.de/ Reviewed-by: Dominique Martinet asmadeus@codewreck.org Reviewed-by: Christian Schoenebeck linux_oss@crudebyte.com Signed-off-by: Eric Van Hensbergen ericvh@kernel.org --- fs/9p/vfs_file.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 2996fb00387f..9b61b480a9b0 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -505,9 +505,7 @@ v9fs_file_mmap(struct file *filp, struct vm_area_struct *vma) p9_debug(P9_DEBUG_MMAP, "filp :%p\n", filp);
if (!(v9ses->cache & CACHE_WRITEBACK)) { - p9_debug(P9_DEBUG_CACHE, "(no mmap mode)"); - if (vma->vm_flags & VM_MAYSHARE) - return -ENODEV; + p9_debug(P9_DEBUG_CACHE, "(read-only mmap mode)"); invalidate_inode_pages2(filp->f_mapping); return generic_file_readonly_mmap(filp, vma); }
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
Rule: 'Cc: stable@vger.kernel.org' or 'commit <sha1> upstream.' Subject: [PATCH v3 1/4] fs/9p: remove unnecessary and overrestrictive check Link: https://lore.kernel.org/stable/20230716-fixes-overly-restrictive-mmap-v3-1-7...
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
On Wed, Jul 19, 2023 at 03:17:05PM +0000, Eric Van Hensbergen wrote:
This eliminates a check for shared that was overrestrictive and duplicated a check in generic_file_readonly_mmap.
Fixes: 1543b4c5071c ("fs/9p: remove writeback fid and fix per-file modes") Link: https://lore.kernel.org/v9fs/ZK25XZ%2BGpR3KHIB%2F@pengutronix.de/ Reviewed-by: Dominique Martinet asmadeus@codewreck.org Reviewed-by: Christian Schoenebeck linux_oss@crudebyte.com Signed-off-by: Eric Van Hensbergen ericvh@kernel.org
fs/9p/vfs_file.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.
</formletter>
There appears to be a typo in the comparison statement for the logic which sets a file's cache mode based on mount flags.
Fixes: 1543b4c5071c ("fs/9p: remove writeback fid and fix per-file modes") Link: https://lore.kernel.org/v9fs/ZK25XZ%2BGpR3KHIB%2F@pengutronix.de/ Reviewed-by: Christian Schoenebeck linux_oss@crudebyte.com Reviewed-by: Dominique Martinet asmadeus@codewreck.org Signed-off-by: Eric Van Hensbergen ericvh@kernel.org --- fs/9p/fid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/9p/fid.h b/fs/9p/fid.h index 0c51889a60b3..297c2c377e3d 100644 --- a/fs/9p/fid.h +++ b/fs/9p/fid.h @@ -57,7 +57,7 @@ static inline void v9fs_fid_add_modes(struct p9_fid *fid, int s_flags, (s_flags & V9FS_DIRECT_IO) || (f_flags & O_DIRECT)) { fid->mode |= P9L_DIRECT; /* no read or write cache */ } else if ((!(s_cache & CACHE_WRITEBACK)) || - (f_flags & O_DSYNC) | (s_flags & V9FS_SYNC)) { + (f_flags & O_DSYNC) || (s_flags & V9FS_SYNC)) { fid->mode |= P9L_NOWRITECACHE; } }
On Wed, Jul 19, 2023 at 03:17:06PM +0000, Eric Van Hensbergen wrote:
There appears to be a typo in the comparison statement for the logic which sets a file's cache mode based on mount flags.
Fixes: 1543b4c5071c ("fs/9p: remove writeback fid and fix per-file modes") Link: https://lore.kernel.org/v9fs/ZK25XZ%2BGpR3KHIB%2F@pengutronix.de/ Reviewed-by: Christian Schoenebeck linux_oss@crudebyte.com Reviewed-by: Dominique Martinet asmadeus@codewreck.org Signed-off-by: Eric Van Hensbergen ericvh@kernel.org
fs/9p/fid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.
</formletter>
There were two flags (s_flags and s_cache) which had incorrect signed type in the parameters of the file cache mode helper function.
Fixes: 1543b4c5071c ("fs/9p: remove writeback fid and fix per-file modes") Link: https://lore.kernel.org/v9fs/ZK25XZ%2BGpR3KHIB%2F@pengutronix.de/ Reviewed-by: Dominique Martinet asmadeus@codewreck.org Signed-off-by: Eric Van Hensbergen ericvh@kernel.org --- fs/9p/fid.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/9p/fid.h b/fs/9p/fid.h index 297c2c377e3d..29281b7c3887 100644 --- a/fs/9p/fid.h +++ b/fs/9p/fid.h @@ -46,8 +46,8 @@ static inline struct p9_fid *v9fs_fid_clone(struct dentry *dentry) * NOTE: these are set after open so only reflect 9p client not * underlying file system on server. */ -static inline void v9fs_fid_add_modes(struct p9_fid *fid, int s_flags, - int s_cache, unsigned int f_flags) +static inline void v9fs_fid_add_modes(struct p9_fid *fid, unsigned int s_flags, + unsigned int s_cache, unsigned int f_flags) { if (fid->qid.type != P9_QTFILE) return;
On Wed, Jul 19, 2023 at 03:17:07PM +0000, Eric Van Hensbergen wrote:
There were two flags (s_flags and s_cache) which had incorrect signed type in the parameters of the file cache mode helper function.
Fixes: 1543b4c5071c ("fs/9p: remove writeback fid and fix per-file modes") Link: https://lore.kernel.org/v9fs/ZK25XZ%2BGpR3KHIB%2F@pengutronix.de/ Reviewed-by: Dominique Martinet asmadeus@codewreck.org Signed-off-by: Eric Van Hensbergen ericvh@kernel.org
fs/9p/fid.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.
</formletter>
There was an invalidate_inode_pages2 added to mmap that is unnecessary.
Fixes: 1543b4c5071c ("fs/9p: remove writeback fid and fix per-file modes") Link: https://lore.kernel.org/v9fs/ZK25XZ%2BGpR3KHIB%2F@pengutronix.de/ Reviewed-by: Christian Schoenebeck linux_oss@crudebyte.com Signed-off-by: Eric Van Hensbergen ericvh@kernel.org --- fs/9p/vfs_file.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 9b61b480a9b0..11cd8d23f6f2 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -506,7 +506,6 @@ v9fs_file_mmap(struct file *filp, struct vm_area_struct *vma)
if (!(v9ses->cache & CACHE_WRITEBACK)) { p9_debug(P9_DEBUG_CACHE, "(read-only mmap mode)"); - invalidate_inode_pages2(filp->f_mapping); return generic_file_readonly_mmap(filp, vma); }
On Wed, Jul 19, 2023 at 03:17:08PM +0000, Eric Van Hensbergen wrote:
There was an invalidate_inode_pages2 added to mmap that is unnecessary.
Fixes: 1543b4c5071c ("fs/9p: remove writeback fid and fix per-file modes") Link: https://lore.kernel.org/v9fs/ZK25XZ%2BGpR3KHIB%2F@pengutronix.de/ Reviewed-by: Christian Schoenebeck linux_oss@crudebyte.com Signed-off-by: Eric Van Hensbergen ericvh@kernel.org
fs/9p/vfs_file.c | 1 - 1 file changed, 1 deletion(-)
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.
</formletter>
Hi Eric,
On Wed, Jul 19, 2023 at 03:17:04PM +0000, Eric Van Hensbergen wrote:
This series attempts to fix a reported exception with mmap on newer kernels.
Fixes: 1543b4c5071c ("fs/9p: remove writeback fid and fix per-file modes") Link: https://lore.kernel.org/v9fs/ZK25XZ%2BGpR3KHIB%2F@pengutronix.de/ Reported-by: Robert Schwebel r.schwebel@pengutronix.de Signed-off-by: Eric Van Hensbergen ericvh@kernel.org
Changes in v3:
- Clarify debug print to read-only mmap mode versus no mmap mode in v9fs_file_mmap
- Fix suggested regression tags and propagate across series
- Link to v2: https://lore.kernel.org/r/20230716-fixes-overly-restrictive-mmap-v2-0-147d6b...
Changes in v2:
- fix requested changes in commit messages
- add patch to remove unnecessary invalidate_inode_pages in mmap readonly path
- Link to v1: https://lore.kernel.org/r/20230716-fixes-overly-restrictive-mmap-v1-0-0683b2...
I've tested this patch series with my qemu setup and it resolves the issue. Thanks for taking care!
Tested-by: Robert Schwebel r.schwebel@pengutronix.de
----------8<----------
rsc@dude05:~/work/DistroKit$ configs/platform-v7a/run Forwarding SSH port 127.0.0.1:24910 -> qemu:22 [ 0.000000] L2C: platform modifies aux control register: 0x02020000 -> 0x02420000 [ 0.000000] L2C: DT/platform modifies aux control register: 0x02020000 -> 0x02420000 [ 0.004896] smp_twd: clock not found -2 [ 0.726397] simple-pm-bus bus@40000000:motherboard-bus@40000000:iofpga@7,00000000: Failed to create device link (0x180) with dcc:tcrefclk [ 0.742338] simple-pm-bus bus@40000000:motherboard-bus@40000000:iofpga@7,00000000: Failed to create device link (0x180) with dcc:tcrefclk [ 0.809910] physmap-flash 48000000.psram: map_probe failed [ 1.201306] 9pnet_virtio: no channels available for device root
____ _ _ | _ \ ___ _ __ __ _ _ _| |_ _ __ ___ _ __ (_)_ __ | |_) / _ \ '_ \ / _` | | | | __| '__/ _ | '_ | \ / / | __/ __/ | | | (_| | |_| | |_| | | (_) | | | | |> < |_| ___|_| |_|__, |__,_|__|_| ___/|_| |_|_/_/_\ |___/
____ _ _ _ ___ _ | _ (_)___| |_ _ __ ___ | |/ (_) |_ | | | | / __| __| '__/ _ | ' /| | __| | |_| | __ \ |_| | | (_) | . | | |_ |____/|_|___/__|_| ___/|_|__|__|
OSELAS(R)-DistroKit-2019.12.0-00429-g57ffae760eb9 / v7a-2019.12.0-00429-g57ffae760eb9 ptxdist-2023.07.1/2023-07-11T19:56:50+0200
DistroKit login: root root@DistroKit:~ mount / -o remount,rw root@DistroKit:~ ldconfig root@DistroKit:~ uname -a Linux DistroKit 6.4.0 #1 SMP PREEMPT 2023-07-01T00:00:00+00:00 armv7l GNU/Linux
----------8<----------
rsc
Awesome, thanks for verifying Robert. Will send a pull request for this in a few days.
-eric
On Mon, Jul 24, 2023 at 4:17 PM Robert Schwebel r.schwebel@pengutronix.de wrote:
Hi Eric,
On Wed, Jul 19, 2023 at 03:17:04PM +0000, Eric Van Hensbergen wrote:
This series attempts to fix a reported exception with mmap on newer kernels.
Fixes: 1543b4c5071c ("fs/9p: remove writeback fid and fix per-file modes") Link: https://lore.kernel.org/v9fs/ZK25XZ%2BGpR3KHIB%2F@pengutronix.de/ Reported-by: Robert Schwebel r.schwebel@pengutronix.de Signed-off-by: Eric Van Hensbergen ericvh@kernel.org
Changes in v3:
- Clarify debug print to read-only mmap mode versus no mmap mode in v9fs_file_mmap
- Fix suggested regression tags and propagate across series
- Link to v2: https://lore.kernel.org/r/20230716-fixes-overly-restrictive-mmap-v2-0-147d6b...
Changes in v2:
- fix requested changes in commit messages
- add patch to remove unnecessary invalidate_inode_pages in mmap readonly path
- Link to v1: https://lore.kernel.org/r/20230716-fixes-overly-restrictive-mmap-v1-0-0683b2...
I've tested this patch series with my qemu setup and it resolves the issue. Thanks for taking care!
Tested-by: Robert Schwebel r.schwebel@pengutronix.de
----------8<----------
rsc@dude05:~/work/DistroKit$ configs/platform-v7a/run Forwarding SSH port 127.0.0.1:24910 -> qemu:22 [ 0.000000] L2C: platform modifies aux control register: 0x02020000 -> 0x02420000 [ 0.000000] L2C: DT/platform modifies aux control register: 0x02020000 -> 0x02420000 [ 0.004896] smp_twd: clock not found -2 [ 0.726397] simple-pm-bus bus@40000000:motherboard-bus@40000000:iofpga@7,00000000: Failed to create device link (0x180) with dcc:tcrefclk [ 0.742338] simple-pm-bus bus@40000000:motherboard-bus@40000000:iofpga@7,00000000: Failed to create device link (0x180) with dcc:tcrefclk [ 0.809910] physmap-flash 48000000.psram: map_probe failed [ 1.201306] 9pnet_virtio: no channels available for device root
| _ \ ___ _ __ __ _ _ _| |_ _ __ ___ _ __ (_)_ __ | |_) / _ \ '_ \ / _` | | | | __| '__/ _ | '_ | \ / / | __/ __/ | | | (_| | |_| | |_| | | (_) | | | | |> < |_| ___|_| |_|__, |__,_|__|_| ___/|_| |_|_/_/_\ |___/
| _ (_)___| |_ _ __ ___ | |/ (_) |_ | | | | / __| __| '__/ _ | ' /| | __| | |_| | __ \ |_| | | (_) | . | | |_ |____/|_|___/__|_| ___/|_|__|__|
OSELAS(R)-DistroKit-2019.12.0-00429-g57ffae760eb9 / v7a-2019.12.0-00429-g57ffae760eb9 ptxdist-2023.07.1/2023-07-11T19:56:50+0200
DistroKit login: root root@DistroKit:~ mount / -o remount,rw root@DistroKit:~ ldconfig root@DistroKit:~ uname -a Linux DistroKit 6.4.0 #1 SMP PREEMPT 2023-07-01T00:00:00+00:00 armv7l GNU/Linux
----------8<----------
rsc
Pengutronix e.K. | Dipl.-Ing. Robert Schwebel | Steuerwalder Str. 21 | https://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
linux-stable-mirror@lists.linaro.org