From bc69fdde0ae1aff595590d802b6ef39114f2b260 Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Fri, 22 Sep 2023 12:12:08 +0800 Subject: autofs: refactor autofs_prepare_pipe() Refactor autofs_prepare_pipe() by seperating out a check function to be used later. Signed-off-by: Ian Kent Reviewed-by: Bill O'Donnell Message-Id: <20230922041215.13675-2-raven@themaw.net> Signed-off-by: Christian Brauner --- fs/autofs/autofs_i.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'fs/autofs/autofs_i.h') diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h index d5a44fa88acf..c24d32be7937 100644 --- a/fs/autofs/autofs_i.h +++ b/fs/autofs/autofs_i.h @@ -209,12 +209,20 @@ int autofs_fill_super(struct super_block *, void *, int); struct autofs_info *autofs_new_ino(struct autofs_sb_info *); void autofs_clean_ino(struct autofs_info *); -static inline int autofs_prepare_pipe(struct file *pipe) +static inline int autofs_check_pipe(struct file *pipe) { if (!(pipe->f_mode & FMODE_CAN_WRITE)) return -EINVAL; if (!S_ISFIFO(file_inode(pipe)->i_mode)) return -EINVAL; + return 0; +} + +static inline int autofs_prepare_pipe(struct file *pipe) +{ + int ret = autofs_check_pipe(pipe); + if (ret < 0) + return ret; /* We want a packet pipe */ pipe->f_flags |= O_DIRECT; /* We don't expect -EAGAIN */ -- cgit v1.2.3 From e6ec453bd0f03a60a80f00f95ae2eaa260faa3c2 Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Fri, 22 Sep 2023 12:12:14 +0800 Subject: autofs: convert autofs to use the new mount api Convert the autofs filesystem to use the mount API. The conversion patch was originally written by David Howells. I have taken that patch and broken it into several patches in an effort to make the change easier to review. Signed-off-by: Ian Kent Reviewed-by: Bill O'Donnell Message-Id: <20230922041215.13675-8-raven@themaw.net> Signed-off-by: Christian Brauner --- fs/autofs/autofs_i.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'fs/autofs/autofs_i.h') diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h index c24d32be7937..244f18cdf23c 100644 --- a/fs/autofs/autofs_i.h +++ b/fs/autofs/autofs_i.h @@ -25,6 +25,8 @@ #include #include #include +#include +#include /* This is the range of ioctl() numbers we claim as ours */ #define AUTOFS_IOC_FIRST AUTOFS_IOC_READY @@ -205,7 +207,8 @@ static inline void managed_dentry_clear_managed(struct dentry *dentry) /* Initializing function */ -int autofs_fill_super(struct super_block *, void *, int); +extern const struct fs_parameter_spec autofs_param_specs[]; +int autofs_init_fs_context(struct fs_context *fc); struct autofs_info *autofs_new_ino(struct autofs_sb_info *); void autofs_clean_ino(struct autofs_info *); -- cgit v1.2.3 From d3c50061765d4b5616dc97f5804fc18122598a9b Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Mon, 23 Oct 2023 17:33:59 +0800 Subject: autofs: fix add autofs_parse_fd() We are seeing systemd hang on its autofs direct mount at /proc/sys/fs/binfmt_misc. Historically this was due to a mismatch in the communication structure size between a 64 bit kernel and a 32 bit user space and was fixed by making the pipe communication record oriented. During autofs v5 development I decided to stay with the existing usage instead of changing to a packed structure for autofs <=> user space communications which turned out to be a mistake on my part. Problems arose and they were fixed by allowing for the 64 bit to 32 bit size difference in the automount(8) code. Along the way systemd started to use autofs and eventually encountered this problem too. systemd refused to compensate for the length difference insisting it be fixed in the kernel. Fortunately Linus implemented the packetized pipe which resolved the problem in a straight forward and simple way. In the autofs mount api conversion series I inadvertatly dropped the packet pipe flag settings when adding the autofs_parse_fd() function. This patch fixes that omission. Fixes: 546694b8f658 ("autofs: add autofs_parse_fd()") Signed-off-by: Ian Kent Link: https://lore.kernel.org/r/20231023093359.64265-1-raven@themaw.net Tested-by: Anders Roxell Cc: Bill O'Donnell Cc: Christian Brauner Cc: Arnd Bergmann Cc: Dan Carpenter Cc: Anders Roxell Cc: Naresh Kamboju Cc: Stephen Rothwell Reported-by: Linux Kernel Functional Testing Reported-by: Anders Roxell Signed-off-by: Christian Brauner --- fs/autofs/autofs_i.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'fs/autofs/autofs_i.h') diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h index 244f18cdf23c..8c1d587b3eef 100644 --- a/fs/autofs/autofs_i.h +++ b/fs/autofs/autofs_i.h @@ -221,15 +221,20 @@ static inline int autofs_check_pipe(struct file *pipe) return 0; } -static inline int autofs_prepare_pipe(struct file *pipe) +static inline void autofs_set_packet_pipe_flags(struct file *pipe) { - int ret = autofs_check_pipe(pipe); - if (ret < 0) - return ret; /* We want a packet pipe */ pipe->f_flags |= O_DIRECT; /* We don't expect -EAGAIN */ pipe->f_flags &= ~O_NONBLOCK; +} + +static inline int autofs_prepare_pipe(struct file *pipe) +{ + int ret = autofs_check_pipe(pipe); + if (ret < 0) + return ret; + autofs_set_packet_pipe_flags(pipe); return 0; } -- cgit v1.2.3