introduce configfd as generalisation of fsconfig
Subsystems (22)
James Bottomley
maintainerv3 cover introduce configfd as generalisation of fsconfig
fsconfig is a very powerful configuration mechanism except that it only works for filesystems with superblocks. This patch series generalises the useful concept of a multiple step configurational mechanism carried by a file descriptor. The object of this patch series is to get bind mounts to be configurable in the same way that superblock based ones are, but it should have utility beyond the filesytem realm. Patch 4 also reimplements fsconfig in terms of configfd, but that's not a strictly necessary patch, it is merely a useful demonstration that configfd is a superset of the properties of fsconfig.
in v3, I swept up Al's prefix generalisation of the log that he expanded to use with ceph and rbd, because it's a nice extension to the original fsconfig log.
The main reason I'm strongly pushing this, is that by my background I dislike abstractions that aren't abstract enough (have unnecessary ties to concrete features like fsconfig does to the superblock), so the physicist in me likes to make them as abstract as possible. The objection, in the email replies to v2 is that making something so powerful too abstract is going to encourage incorrect reuse and thus cause problems because using an interface of huge power on something that doesn't need it damages the API confinement and makes unintended and unexpected uses easy. I still think this is a wrongheaded argument because we do have subsystems that need powerful config interfaces and we should have the taste to ensure the full power is only used there, but I think it's a useful debate to have. For instance, I think the entire annoying keyctl API could usefully deploy this.
Note: v1 of this patch series was originally sent as an rfc in reply to a thread about feature bugs with the new mount API:
https://lore.kernel.org/linux-fsdevel/[email protected]/
James
---
James Bottomley (6):
logger: add a limited buffer logging facility
configfd: add generic file descriptor based configuration parser
configfd: syscall: wire up configfd syscalls
fs: implement fsconfig via configfd
fs: expose internal interfaces open_detached_copy and
do_reconfigure_mount
fs: bind: add configfs type for bind mounts
arch/alpha/kernel/syscalls/syscall.tbl | 2 + arch/arm/tools/syscall.tbl | 2 + arch/arm64/include/asm/unistd.h | 2 +- arch/arm64/include/asm/unistd32.h | 4 + arch/ia64/kernel/syscalls/syscall.tbl | 2 + arch/m68k/kernel/syscalls/syscall.tbl | 2 + arch/microblaze/kernel/syscalls/syscall.tbl | 2 + arch/mips/kernel/syscalls/syscall_n32.tbl | 2 + arch/mips/kernel/syscalls/syscall_n64.tbl | 2 + arch/mips/kernel/syscalls/syscall_o32.tbl | 2 + arch/parisc/kernel/syscalls/syscall.tbl | 2 + arch/powerpc/kernel/syscalls/syscall.tbl | 2 + arch/s390/kernel/syscalls/syscall.tbl | 2 + arch/sh/kernel/syscalls/syscall.tbl | 2 + arch/sparc/kernel/syscalls/syscall.tbl | 2 + arch/x86/entry/syscalls/syscall_32.tbl | 2 + arch/x86/entry/syscalls/syscall_64.tbl | 2 + arch/xtensa/kernel/syscalls/syscall.tbl | 2 + drivers/block/rbd.c | 2 +- fs/Makefile | 3 +- fs/bind.c | 232 ++++++++++++ fs/ceph/super.c | 4 +- fs/configfd.c | 451 ++++++++++++++++++++++++ fs/filesystems.c | 8 +- fs/fs_context.c | 97 +---- fs/fs_parser.c | 24 +- fs/fsopen.c | 529 ++++++++++++++-------------- fs/internal.h | 7 + fs/namespace.c | 115 +++--- include/linux/ceph/libceph.h | 5 +- include/linux/configfd.h | 61 ++++ include/linux/fs.h | 2 + include/linux/fs_context.h | 58 ++- include/linux/fs_parser.h | 9 +- include/linux/logger.h | 45 +++ include/linux/syscalls.h | 5 + include/uapi/asm-generic/unistd.h | 9 +- include/uapi/linux/configfd.h | 20 ++ lib/Makefile | 3 +- lib/logger.c | 190 ++++++++++ net/ceph/ceph_common.c | 26 +- 41 files changed, 1457 insertions(+), 486 deletions(-) create mode 100644 fs/bind.c create mode 100644 fs/configfd.c create mode 100644 include/linux/configfd.h create mode 100644 include/linux/logger.h create mode 100644 include/uapi/linux/configfd.h create mode 100644 lib/logger.c
Signature · 1 line
2.16.4
James Bottomley
maintainerPATCH v3 1/6 logger: add a limited buffer logging facility
Can be used by anything that wants to add to a list of messages and then spit them back at a particular time. The current use case for this is the filesystem configuration descriptor, which can accumulate messages about config options which can then be read from the file descriptor later via a .read operation.
This code was based on fc_log originally written by David Howells in commit e7582e16a170 "vfs: Implement logging through fs_context" and subsequently extended to include a prefix logger by Al Viro in commit cc3c0b533ab9 "add prefix to fs_context->log".
---
v3: add prefix logger
--- include/linux/logger.h | 45 ++++++++++++ lib/Makefile | 3 +- lib/logger.c | 190 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 237 insertions(+), 1 deletion(-) create mode 100644 include/linux/logger.h create mode 100644 lib/logger.c
include/linux/logger.h new file +45 -0
@@ -0,0 +1,45 @@ +#ifndef _LINUX_LOGGER_H +#define _LINUX_LOGGER_H + +#include <stdarg.h> + +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/refcount.h> +#include <linux/types.h> + +struct logger { +const char *prefix; +refcount_t usage; +struct mutex mutex; +u8 head;/* Insertion index in buffer[] */ +u8 tail;/* Removal index in buffer[] */ +u8 need_free;/* Mask of kfree'able items in buffer[] */ +struct module *owner;/* Owner module for strings that don't then need freeing */ +const char *buffer[8 ]; +}; + +struct plogger { +const char *prefix; +struct logger *log; +}; + +extern __printf(4, 5) +void logger_log(struct logger *, const char *prefix, char level, + const char *fmt, ...); +extern __printf(4, 0) +void logger_valog(struct logger *, const char *prefix, char level, + const char *fmt, va_list va); +ssize_t logger_read(struct logger *log, char __user *_buf, size_t len); +struct logger *logger_alloc(struct module *owner); +void logger_put(struct logger **logp); +void logger_get(struct logger *log); + +#define logger_err(log, fmt, ...) ({ logger_log(log, NULL, 'e', fmt, ## __VA_ARGS__); }) +#define logger_warn(log, fmt, ...) ({ logger_log(log, NULL, 'w', fmt, ## __VA_ARGS__); }) +#define logger_info(log, fmt, ...) ({ logger_log(log, NULL, 'i', fmt, ## __VA_ARGS__); }) +#define plogger_err(plog, fmt, ...) ({ logger_log((plog)->log, (plog)->prefix, 'e', fmt, ## __VA_ARGS__); }) +#define plogger_warn(log, fmt, ...) ({ logger_log((plog)->log, (plog)->prefix, 'w', fmt, ## __VA_ARGS__); }) +#define plogger_info(log, fmt, ...) ({ logger_log((plog)->log, (plog)->prefix, 'i', fmt, ## __VA_ARGS__); }) + +#endif
lib/Makefile +2 -1
@@ -31,7 +31,8 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \ flex_proportions.o ratelimit.o show_mem.o \ is_single_threaded.o plist.o decompress.o kobject_uevent.o \ earlycpio.o seq_buf.o siphash.o dec_and_lock.o \ - nmi_backtrace.o nodemask.o win_minmax.o memcat_p.o + nmi_backtrace.o nodemask.o win_minmax.o memcat_p.o \ + logger.o lib-$(CONFIG_PRINTK) += dump_stack.o lib-$(CONFIG_MMU) += ioremap.o
lib/logger.c new file +190 -0
190 lines not on this page · raw message
Signature · 1 line
2.16.4
James Bottomley
maintainerPATCH v3 2/6 configfd: add generic file descriptor based configuration parser
In reply to James BottomleyThis code is based on the original filesystem context based configuration parser by David Howells, but lifted up so it can apply to anything rather than only filesystem contexts.
---
v3: use prefix logger
--- fs/Makefile | 3 +- fs/configfd.c | 451 ++++++++++++++++++++++++++++++++++++++++++ include/linux/configfd.h | 61 ++++++ include/uapi/linux/configfd.h | 20 ++ 4 files changed, 534 insertions(+), 1 deletion(-) create mode 100644 fs/configfd.c create mode 100644 include/linux/configfd.h create mode 100644 include/uapi/linux/configfd.h
fs/Makefile +2 -1
@@ -13,7 +13,8 @@ obj-y := open.o read_write.o file_table.o super.o \ seq_file.o xattr.o libfs.o fs-writeback.o \ pnode.o splice.o sync.o utimes.o d_path.o \ stack.o fs_struct.o statfs.o fs_pin.o nsfs.o \ - fs_types.o fs_context.o fs_parser.o fsopen.o + fs_types.o fs_context.o fs_parser.o fsopen.o \ + configfd.o ifeq ($(CONFIG_BLOCK),y) obj-y += buffer.o block_dev.o direct-io.o mpage.o
fs/configfd.c new file +451 -0
451 lines not on this page · raw message
include/linux/configfd.h new file +61 -0
61 lines not on this page · raw message
include/uapi/linux/configfd.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later WITH Linux-syscall-note */ + +#ifndef _UAPI_LINUX_CONFIGFD_H +#define _UAPI_LINUX_CONFIGFD_H + +enum configfd_cmd { +CONFIGFD_SET_FLAG =0 , +CONFIGFD_SET_STRING =1 , +CONFIGFD_SET_BINARY =2 , +CONFIGFD_SET_PATH =3 , +CONFIGFD_SET_PATH_EMPTY =4 , +CONFIGFD_SET_FD =5 , +CONFIGFD_CMD_CREATE =6 , +CONFIGFD_CMD_RECONFIGURE =7 , +/* gap for 30 other commands */ +CONFIGFD_SET_INT =38 , +CONFIGFD_GET_FD =39 , +}; + +#endif
Signature · 1 line
2.16.4
James Bottomley
maintainerPATCH v3 3/6 configfd: syscall: wire up configfd syscalls
In reply to James Bottomley---
v3: Changed numbering to avoid clash with pidfd calls
--- arch/alpha/kernel/syscalls/syscall.tbl | 2 ++ arch/arm/tools/syscall.tbl | 2 ++ arch/arm64/include/asm/unistd.h | 2 +- arch/arm64/include/asm/unistd32.h | 4 ++++ arch/ia64/kernel/syscalls/syscall.tbl | 2 ++ arch/m68k/kernel/syscalls/syscall.tbl | 2 ++ arch/microblaze/kernel/syscalls/syscall.tbl | 2 ++ arch/mips/kernel/syscalls/syscall_n32.tbl | 2 ++ arch/mips/kernel/syscalls/syscall_n64.tbl | 2 ++ arch/mips/kernel/syscalls/syscall_o32.tbl | 2 ++ arch/parisc/kernel/syscalls/syscall.tbl | 2 ++ arch/powerpc/kernel/syscalls/syscall.tbl | 2 ++ arch/s390/kernel/syscalls/syscall.tbl | 2 ++ arch/sh/kernel/syscalls/syscall.tbl | 2 ++ arch/sparc/kernel/syscalls/syscall.tbl | 2 ++ arch/x86/entry/syscalls/syscall_32.tbl | 2 ++ arch/x86/entry/syscalls/syscall_64.tbl | 2 ++ arch/xtensa/kernel/syscalls/syscall.tbl | 2 ++ include/linux/syscalls.h | 5 +++++ include/uapi/asm-generic/unistd.h | 9 +++++++-- 20 files changed, 49 insertions(+), 3 deletions(-)
arch/alpha/kernel/syscalls/syscall.tbl +2 -0
@@ -477,3 +477,5 @@ # 545 reserved for clone3 547 common openat2 sys_openat2 548 common pidfd_getfd sys_pidfd_getfd +549 common configfd_open configfd_open +550 common configfd_action configfd_action
arch/arm/tools/syscall.tbl +2 -0
@@ -451,3 +451,5 @@ 435 common clone3 sys_clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common configfd_open sys_configfd_open +440 common configfd_action sys_configfd_action
arch/arm64/include/asm/unistd.h +1 -1
@@ -38,7 +38,7 @@#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE + 5)#define __ARM_NR_COMPAT_END (__ARM_NR_COMPAT_BASE + 0x800) -#define __NR_compat_syscalls 439 +#define __NR_compat_syscalls 441#endif #define __ARCH_WANT_SYS_CLONE
arch/arm64/include/asm/unistd32.h +4 -0
@@ -883,6 +883,10 @@ __SYSCALL(__NR_clone3, sys_clone3) __SYSCALL(__NR_openat2, sys_openat2)#define __NR_pidfd_getfd 438 __SYSCALL(__NR_pidfd_getfd, sys_pidfd_getfd) +#define __NR_configfd_open 439 +__SYSCALL(__NR_configfd_open, sys_configfd_open) +#define __NR_configfd_action 440 +__SYSCALL (__NR_configfd_action, sys_configfd_action)/* * Please add new compat syscalls above this comment and update
arch/ia64/kernel/syscalls/syscall.tbl +2 -0
@@ -358,3 +358,5 @@ # 435 reserved for clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common configfd_open sys_configfd_open +440 common configfd_action sys_configfd_action
arch/m68k/kernel/syscalls/syscall.tbl +2 -0
@@ -437,3 +437,5 @@ 435 common clone3 __sys_clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common configfd_open sys_configfd_open +440 common configfd_action sys_configfd_action
arch/microblaze/kernel/syscalls/syscall.tbl +2 -0
@@ -443,3 +443,5 @@ 435 common clone3 sys_clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common configfd_open sys_configfd_open +440 common configfd_action sys_configfd_action
arch/mips/kernel/syscalls/syscall_n32.tbl +2 -0
@@ -376,3 +376,5 @@ 435 n32 clone3 __sys_clone3 437 n32 openat2 sys_openat2 438 n32 pidfd_getfd sys_pidfd_getfd +439 n32 configfd_open sys_configfd_open +440 n32 configfd_action sys_configfd_action
arch/mips/kernel/syscalls/syscall_n64.tbl +2 -0
@@ -352,3 +352,5 @@ 435 n64 clone3 __sys_clone3 437 n64 openat2 sys_openat2 438 n64 pidfd_getfd sys_pidfd_getfd +439 n64 configfd_open sys_configfd_open +440 n64 configfd_action sys_configfd_action
arch/mips/kernel/syscalls/syscall_o32.tbl +2 -0
@@ -425,3 +425,5 @@ 435 o32 clone3 __sys_clone3 437 o32 openat2 sys_openat2 438 o32 pidfd_getfd sys_pidfd_getfd +439 o32 configfd_open sys_configfd_open +440 o32 configfd_action sys_configfd_action
arch/parisc/kernel/syscalls/syscall.tbl +2 -0
@@ -435,3 +435,5 @@ 435 common clone3 sys_clone3_wrapper 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common configfd_open sys_configfd_open +440 common configfd_action sys_configfd_action
arch/powerpc/kernel/syscalls/syscall.tbl +2 -0
@@ -519,3 +519,5 @@ 435 nospu clone3 ppc_clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common configfd_open sys_configfd_open +440 common configfd_action sys_configfd_action
arch/s390/kernel/syscalls/syscall.tbl +2 -0
@@ -440,3 +440,5 @@ 435 common clone3 sys_clone3 sys_clone3 437 common openat2 sys_openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd sys_pidfd_getfd +439 common configfd_open sys_configfd_open sys_configfd_open +440 common configfd_action sys_configfd_action sys_configfd_action
arch/sh/kernel/syscalls/syscall.tbl +2 -0
@@ -440,3 +440,5 @@ # 435 reserved for clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common configfd_open sys_configfd_open +440 common configfd_action sys_configfd_action
arch/sparc/kernel/syscalls/syscall.tbl +2 -0
@@ -483,3 +483,5 @@ # 435 reserved for clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common configfd_open sys_configfd_open +440 common configfd_action sys_configfd_action
arch/x86/entry/syscalls/syscall_32.tbl +2 -0
@@ -442,3 +442,5 @@ 435 i386 clone3 sys_clone3 __ia32_sys_clone3 437 i386 openat2 sys_openat2 __ia32_sys_openat2 438 i386 pidfd_getfd sys_pidfd_getfd __ia32_sys_pidfd_getfd +436 i386 configfd_open sys_configfd_open __ia32_sys_configfd_open +437 i386 configfd_action sys_configfd_action __ia32_sys_configfd_action
arch/x86/entry/syscalls/syscall_64.tbl +2 -0
@@ -359,6 +359,8 @@ 435 common clone3 __x64_sys_clone3/ptregs 437 common openat2 __x64_sys_openat2 438 common pidfd_getfd __x64_sys_pidfd_getfd +439 common configfd_open __x64_sys_configfd_open +440 common configfd_action __x64_sys_configfd_action # # x32-specific system call numbers start at 512 to avoid cache impact
arch/xtensa/kernel/syscalls/syscall.tbl +2 -0
@@ -408,3 +408,5 @@ 435 common clone3 sys_clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common configfd_open sys_configfd_open +440 common configfd_action sys_configfd_action
include/linux/syscalls.h +5 -0
@@ -1003,6 +1003,11 @@ asmlinkage long sys_pidfd_send_signal(int pidfd, int sig,siginfo_t __user *info, unsigned int flags);asmlinkage long sys_pidfd_getfd (int pidfd,int fd,unsigned int flags); +asmlinkage long sys_configfd_open (const char __user *config_name, +unsigned int flags,unsigned int op); +asmlinkage long sys_configfd_action (int fd,unsigned int cmd, +const char __user *key,void __user *value, +int aux);/* * Architecture-specific system calls
include/uapi/asm-generic/unistd.h +7 -2
@@ -849,15 +849,20 @@ __SYSCALL(__NR_pidfd_open, sys_pidfd_open)#ifdef __ARCH_WANT_SYS_CLONE3#define __NR_clone3 435 __SYSCALL(__NR_clone3, sys_clone3) -#endif +#endif #define __NR_openat2 437 __SYSCALL(__NR_openat2, sys_openat2)#define __NR_pidfd_getfd 438 __SYSCALL(__NR_pidfd_getfd, sys_pidfd_getfd) +#define __NR_configfd_open 439 +__SYSCALL(__NR_configfd_open, sys_configfd_open) +#define __NR_configfd_action 440 +__SYSCALL(__NR_configfd_action, sys_configfd_action) +#undef __NR_syscalls -#define __NR_syscalls 439 +#define __NR_syscalls 441/* * 32 bit systems traditionally used different
Signature · 1 line
2.16.4
Re: [PATCH v3 3/6] configfd: syscall: wire up configfd syscalls
arch/x86/entry/syscalls/syscall_32.tbl line 446
Quoted 10 lines · James Bottomley
arch/x86/entry/syscalls/syscall_32.tbl +2
-0@@ -442,3 +442,5 @@ 435 i386 clone3 sys_clone3 __ia32_sys_clone3 437 i386 openat2 sys_openat2 __ia32_sys_openat2 438 i386 pidfd_getfd sys_pidfd_getfd __ia32_sys_pidfd_getfd +436 i386 configfd_open sys_configfd_open __ia32_sys_configfd_open +437 i386 configfd_action sys_configfd_action __ia32_sys_configfd_action
Did you mean:
+439 i386 configfd_open sys_configfd_open __ia32_sys_configfd_open
+440 i386 configfd_action sys_configfd_action __ia32_sys_configfd_action
Signature · 4 lines
Aleksa Sarai Senior Software Engineer (Containers) SUSE Linux GmbH <https://www.cyphar.com/>
James Bottomley
maintainerRe: [PATCH v3 3/6] configfd: syscall: wire up configfd syscalls
Quoted 21 lines · Aleksa Sarai
On 2020-02-15, James Bottomley <[email protected]
Quoted 13 lines
wrote:
arch/x86/entry/syscalls/syscall_32.tbl +0
-0@@ -442,3 +442,5 @@ 435 i386 clone3 sys_clone3 __ia32_sys_clone3 437 i386 openat2 sys_openat2__ia32_sys_openat2 438 i386 pidfd_getfd sys_pidfd_getfd __ia32_sys_pidfd_getfdQuoted 4 lines
+436 i386
configfd_opensys_configfd_o
pen__ia32_sys_configfd_open
+437 i386configfd_actionsys_configfd_action__ia32_sys_configfd_actionDid you mean:
Quoted 4 lines
+439 i386
configfd_opensys_configfd_ope
n__ia32_sys_configfd_open
+440 i386configfd_actionsys_configfd_a
ction__ia32_sys_configfd_action
Yes, I obviously screwed up the rebase on that one.
James
James Bottomley
maintainerPATCH v3 4/6 fs: implement fsconfig via configfd
In reply to James BottomleyThis changes the internal implementation of fsconfig, while keeping all the external system calls. However, it now becomes possible to all the same operations via configfd instead of fsconfig.
For example a filesystem remount read-only can be done:
fd = configfd_open("mount", O_CLOEXEC, CONFIGFD_CMD_RECONFIGURE); mntpnt = open("/path/to/mount", O_PATH); configfd_action(fd, CONFIGFD_SET_FD, "pathfd", NULL, mntpnt); configfd_action(fd, CONFIGFD_SET_FLAG, "ro", NULL, 0); configfd_action(fd, CONFIGFD_CMD_RECONFIGURE, NULL, NULL, 0);
And mounting a tmpfs filesystem nodev,noexec:
fd = configfd_open("tmpfs", O_CLOEXEC, CONFIGFD_CMD_CREATE); configfd_action(fd, CONFIGFD_SET_INT, "mount_attrs", NULL,
MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC);
configfd_action(fd, CONFIGFD_CMD_CREATE, NULL, NULL, 0); configfd_action(fd, CONFIGFD_GET_FD, "mountfd", &mfd, O_CLOEXEC); mount_move("", mfd, AT_FDCWD, "/mountpoint", MOVE_MOUNT_F_EMPTY_PATH);
---
v2: fix a log oops
v3: sweep up ceph/rdb p_log
--- drivers/block/rbd.c | 2 +- fs/ceph/super.c | 4 +- fs/filesystems.c | 8 +- fs/fs_context.c | 97 ++------ fs/fs_parser.c | 24 +- fs/fsopen.c | 529 +++++++++++++++++++++---------------------- fs/internal.h | 4 + fs/namespace.c | 111 ++++----- include/linux/ceph/libceph.h | 5 +- include/linux/fs.h | 2 + include/linux/fs_context.h | 58 +++-- include/linux/fs_parser.h | 9 +- net/ceph/ceph_common.c | 26 +-- 13 files changed, 400 insertions(+), 479 deletions(-)
drivers/block/rbd.c +1 -1
@@ -6348,7 +6348,7 @@ static int rbd_parse_param(struct fs_parameter *param, {struct rbd_options *opt = pctx->opts;struct fs_parse_result result; -struct p_log log = {.prefix ="rbd" }; +struct plogger log = {.prefix ="rbd" };int token, ret; ret =ceph_parse_param (param, pctx->copts,NULL );
fs/ceph/super.c +2 -2
@@ -246,7 +246,7 @@ static int ceph_parse_source(struct fs_parameter *param, struct fs_context *fc)dout ("server path '%s'\n" , fsopt->server_path); ret =ceph_parse_mon_ips (param->string, dev_name_end - dev_name, - pctx->copts, fc->log.log); + pctx->copts, &fc->cfc->log);if (ret)return ret;
@@ -264,7 +264,7 @@ static int ceph_parse_mount_param(struct fs_context *fc,unsigned int mode;int token, ret; - ret =ceph_parse_param (param, pctx->copts, fc->log.log); + ret =ceph_parse_param (param, pctx->copts, &fc->cfc->log);if (ret != -ENOPARAM )return ret;
fs/filesystems.c +6 -2
@@ -7,6 +7,7 @@* table of configured filesystems */ +#include <linux/configfd.h> #include <linux/syscalls.h> #include <linux/fs.h> #include <linux/proc_fs.h>
@@ -83,10 +84,12 @@ int register_filesystem(struct file_system_type * fs)return -EBUSY ;write_lock (&file_systems_lock); p =find_filesystem (fs->name,strlen (fs->name)); -if (*p) +if (*p) { res = -EBUSY ; -else + }else { *p = fs; + res =fs_context_register (fs); + }write_unlock (&file_systems_lock);return res; }
@@ -115,6 +118,7 @@ int unregister_filesystem(struct file_system_type * fs)if (fs == *tmp) { *tmp = fs->next; fs->next =NULL ; +fs_context_unregister (fs);write_unlock (&file_systems_lock);synchronize_rcu ();return 0 ;
fs/fs_context.c +16 -81
139 lines not on this page · raw message
fs/fs_parser.c +12 -12
@@ -100,7 +100,7 @@ static const struct fs_parameter_spec *fs_lookup_key(* unknown parameters are okay and -EINVAL if there was a conversion issue or * the parameter wasn't recognised and unknowns aren't okay. */ -int __fs_parse (struct p_log *log, +int __fs_parse (struct plogger *log,const struct fs_parameter_spec *desc,struct fs_parameter *param,struct fs_parse_result *result)
@@ -189,12 +189,12 @@ int fs_lookup_param(struct fs_context *fc, }EXPORT_SYMBOL (fs_lookup_param); -int fs_param_bad_value (struct p_log *log,struct fs_parameter *param) +int fs_param_bad_value (struct plogger *log,struct fs_parameter *param) {return inval_plog (log,"Bad value for '%s'" , param->key); } -int fs_param_is_bool (struct p_log *log,const struct fs_parameter_spec *p, +int fs_param_is_bool (struct plogger *log,const struct fs_parameter_spec *p,struct fs_parameter *param,struct fs_parse_result *result) {int b;
@@ -208,7 +208,7 @@ int fs_param_is_bool(struct p_log *log, const struct fs_parameter_spec *p, }EXPORT_SYMBOL (fs_param_is_bool); -int fs_param_is_u32 (struct p_log *log,const struct fs_parameter_spec *p, +int fs_param_is_u32 (struct plogger *log,const struct fs_parameter_spec *p,struct fs_parameter *param,struct fs_parse_result *result) {int base = (unsigned long )p->data;
@@ -219,7 +219,7 @@ int fs_param_is_u32(struct p_log *log, const struct fs_parameter_spec *p, }EXPORT_SYMBOL (fs_param_is_u32); -int fs_param_is_s32 (struct p_log *log,const struct fs_parameter_spec *p, +int fs_param_is_s32 (struct plogger *log,const struct fs_parameter_spec *p,struct fs_parameter *param,struct fs_parse_result *result) { if (param->type != fs_value_is_string ||
@@ -229,7 +229,7 @@ int fs_param_is_s32(struct p_log *log, const struct fs_parameter_spec *p, }EXPORT_SYMBOL (fs_param_is_s32); -int fs_param_is_u64 (struct p_log *log,const struct fs_parameter_spec *p, +int fs_param_is_u64 (struct plogger *log,const struct fs_parameter_spec *p,struct fs_parameter *param,struct fs_parse_result *result) { if (param->type != fs_value_is_string ||
@@ -239,7 +239,7 @@ int fs_param_is_u64(struct p_log *log, const struct fs_parameter_spec *p, }EXPORT_SYMBOL (fs_param_is_u64); -int fs_param_is_enum (struct p_log *log,const struct fs_parameter_spec *p, +int fs_param_is_enum (struct plogger *log,const struct fs_parameter_spec *p,struct fs_parameter *param,struct fs_parse_result *result) {const struct constant_table *c;
@@ -253,7 +253,7 @@ int fs_param_is_enum(struct p_log *log, const struct fs_parameter_spec *p, }EXPORT_SYMBOL (fs_param_is_enum); -int fs_param_is_string (struct p_log *log,const struct fs_parameter_spec *p, +int fs_param_is_string (struct plogger *log,const struct fs_parameter_spec *p,struct fs_parameter *param,struct fs_parse_result *result) {if (param->type != fs_value_is_string || !*param->string)
@@ -262,7 +262,7 @@ int fs_param_is_string(struct p_log *log, const struct fs_parameter_spec *p, }EXPORT_SYMBOL (fs_param_is_string); -int fs_param_is_blob (struct p_log *log,const struct fs_parameter_spec *p, +int fs_param_is_blob (struct plogger *log,const struct fs_parameter_spec *p,struct fs_parameter *param,struct fs_parse_result *result) {if (param->type != fs_value_is_blob)
@@ -271,7 +271,7 @@ int fs_param_is_blob(struct p_log *log, const struct fs_parameter_spec *p, }EXPORT_SYMBOL (fs_param_is_blob); -int fs_param_is_fd (struct p_log *log,const struct fs_parameter_spec *p, +int fs_param_is_fd (struct plogger *log,const struct fs_parameter_spec *p,struct fs_parameter *param,struct fs_parse_result *result) {switch (param->type) {
@@ -293,14 +293,14 @@ int fs_param_is_fd(struct p_log *log, const struct fs_parameter_spec *p, }EXPORT_SYMBOL (fs_param_is_fd); -int fs_param_is_blockdev (struct p_log *log,const struct fs_parameter_spec *p, +int fs_param_is_blockdev (struct plogger *log,const struct fs_parameter_spec *p,struct fs_parameter *param,struct fs_parse_result *result) {return 0 ; }EXPORT_SYMBOL (fs_param_is_blockdev); -int fs_param_is_path (struct p_log *log,const struct fs_parameter_spec *p, +int fs_param_is_path (struct plogger *log,const struct fs_parameter_spec *p,struct fs_parameter *param,struct fs_parse_result *result) {return 0 ;
fs/fsopen.c +261 -268
604 lines not on this page · raw message
fs/internal.h +4 -0
@@ -91,6 +91,10 @@ extern int __mnt_want_write_file(struct file *);extern void __mnt_drop_write_file (struct file *);extern void dissolve_on_fput (struct vfsmount *); + +int fsopen_cf_get (const struct configfd_context *cfc, +struct configfd_param *p); +/* * fs_struct.c */
fs/namespace.c +47 -64
160 lines not on this page · raw message
include/linux/ceph/libceph.h +2 -3
@@ -281,12 +281,11 @@ extern int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid);extern void *ceph_kvmalloc (size_t size,gfp_t flags);struct fs_parameter ; -struct fc_log ;struct ceph_options *ceph_alloc_options (void );int ceph_parse_mon_ips (const char *buf,size_t len,struct ceph_options *opt, -struct fc_log *l); +struct plogger *l);int ceph_parse_param (struct fs_parameter *param,struct ceph_options *opt, -struct fc_log *l); +struct plogger *l);int ceph_print_client_options (struct seq_file *m,struct ceph_client *client,bool show_all);extern void ceph_destroy_options (struct ceph_options *opt);
include/linux/fs.h +2 -0
@@ -2,6 +2,7 @@#ifndef _LINUX_FS_H#define _LINUX_FS_H +#include <linux/configfd.h> #include <linux/linkage.h> #include <linux/wait_bit.h> #include <linux/kdev_t.h>
@@ -2251,6 +2252,7 @@ struct file_system_type {struct lock_class_key i_lock_key;struct lock_class_key i_mutex_key;struct lock_class_key i_mutex_dir_key; +struct configfd_type cft; };#define MODULE_ALIAS_FS (NAME ) MODULE_ALIAS("fs-" NAME)
include/linux/fs_context.h +28 -30
108 lines not on this page · raw message
include/linux/fs_parser.h +6 -3
@@ -19,7 +19,7 @@ struct constant_table {struct fs_parameter_spec ;struct fs_parse_result ; -typedef int fs_param_type (struct p_log *, +typedef int fs_param_type (struct plogger *,const struct fs_parameter_spec *,struct fs_parameter *,struct fs_parse_result *);
@@ -60,7 +60,7 @@ struct fs_parse_result { }; }; -extern int __fs_parse (struct p_log *log, +extern int __fs_parse (struct plogger *log,const struct fs_parameter_spec *desc,struct fs_parameter *value,struct fs_parse_result *result);
@@ -70,7 +70,7 @@ static inline int fs_parse(struct fs_context *fc,struct fs_parameter *param, struct fs_parse_result *result) { - return __fs_parse(&fc->log, desc, param, result); + return __fs_parse(&fc->cfc->log, desc, param, result); } extern int fs_lookup_param(struct fs_context *fc,
@@ -131,4 +131,7 @@ static inline bool fs_validate_description(const char *name,#define fsparam_path (NAME ,OPT ) __fsparam(fs_param_is_path, NAME, OPT, 0, NULL)#define fsparam_fd (NAME ,OPT ) __fsparam(fs_param_is_fd, NAME, OPT, 0, NULL) +int fs_context_register (struct file_system_type *fs); +void fs_context_unregister (struct file_system_type *fs); +#endif /* _LINUX_FS_PARSER_H */
net/ceph/ceph_common.c +13 -13
@@ -332,7 +332,7 @@ EXPORT_SYMBOL(ceph_destroy_options);/* get secret from key store */ static int get_secret (struct ceph_crypto_key *dst,const char *name, -struct p_log *log) +struct plogger *log) {struct key *ukey;int key_err;
@@ -378,16 +378,16 @@ static int get_secret(struct ceph_crypto_key *dst, const char *name, }int ceph_parse_mon_ips (const char *buf,size_t len,struct ceph_options *opt, -struct fc_log *l) +struct plogger *l) { -struct p_log log = {.prefix ="libceph" , .log = l};int ret; + l->prefix ="libceph" ;/* ip1[:port1][,ip2[:port2]...] */ ret =ceph_parse_ips (buf, buf + len, opt->mon_addr,CEPH_MAX_MON , &opt->num_mon);if (ret) { -error_plog (&log,"Failed to parse monitor IPs: %d" , ret); +error_plog (l,"Failed to parse monitor IPs: %d" , ret);return ret; }
@@ -396,13 +396,13 @@ int ceph_parse_mon_ips(const char *buf, size_t len, struct ceph_options *opt,EXPORT_SYMBOL (ceph_parse_mon_ips);int ceph_parse_param (struct fs_parameter *param,struct ceph_options *opt, -struct fc_log *l) +struct plogger *l) {struct fs_parse_result result;int token, err; -struct p_log log = {.prefix ="libceph" , .log = l}; - token =__fs_parse (&log, ceph_parameters, param, &result); + l->prefix ="libceph" ; + token =__fs_parse (l, ceph_parameters, param, &result);dout ("%s fs_parse '%s' token %d\n" , __func__, param->key, token);if (token <0 )return token;
@@ -414,7 +414,7 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt, &opt->my_addr, 1, NULL);if (err) { -error_plog (&log,"Failed to parse ip: %d" , err); +error_plog (l,"Failed to parse ip: %d" , err);return err; } opt->flags |=CEPH_OPT_MYIP ;
@@ -423,7 +423,7 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,case Opt_fsid: err =parse_fsid (param->string, &opt->fsid);if (err) { -error_plog (&log,"Failed to parse fsid: %d" , err); +error_plog (l,"Failed to parse fsid: %d" , err);return err; } opt->flags |=CEPH_OPT_FSID ;
@@ -442,7 +442,7 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,return -ENOMEM ; err =ceph_crypto_key_unarmor (opt->key, param->string);if (err) { -error_plog (&log,"Failed to parse secret: %d" , err); +error_plog (l,"Failed to parse secret: %d" , err);return err; }break ;
@@ -453,10 +453,10 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt, opt->key =kzalloc (sizeof (*opt->key),GFP_KERNEL );if (!opt->key)return -ENOMEM ; -return get_secret (opt->key, param->string, &log); +return get_secret (opt->key, param->string, l);case Opt_osdtimeout: -warn_plog (&log,"Ignoring osdtimeout" ); +warn_plog (l,"Ignoring osdtimeout" );break ;case Opt_osdkeepalivetimeout:/* 0 isn't well defined right now, reject it */
@@ -527,7 +527,7 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,return 0 ; out_of_range: -return inval_plog (&log,"%s out of range" , param->key); +return inval_plog (l,"%s out of range" , param->key); }EXPORT_SYMBOL (ceph_parse_param);
Signature · 1 line
2.16.4
James Bottomley
maintainerPATCH v3 5/6 fs: expose internal interfaces open_detached_copy and do_reconfigure_mount
In reply to James BottomleyThese are needed for the forthcoming bind configure type to work.
--- fs/internal.h | 3 +++ fs/namespace.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)
fs/internal.h +3 -0
@@ -95,6 +95,9 @@ extern void dissolve_on_fput(struct vfsmount *);int fsopen_cf_get (const struct configfd_context *cfc,struct configfd_param *p); +extern int do_reconfigure_mnt (struct path *path,unsigned int mnt_flags); +extern struct file *open_detached_copy (struct path *path,bool recursive); +/* * fs_struct.c */
fs/namespace.c +2 -2
@@ -2318,7 +2318,7 @@ static int do_loopback(struct path *path, const char *old_name,return err; } -static struct file *open_detached_copy (struct path *path,bool recursive) +struct file *open_detached_copy (struct path *path,bool recursive) {struct user_namespace *user_ns = current->nsproxy->mnt_ns->user_ns;struct mnt_namespace *ns =alloc_mnt_ns (user_ns, true);
@@ -2494,7 +2494,7 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount ** superblock it refers to. This is triggered by specifying MS_REMOUNT|MS_BIND * to mount(2). */ -static int do_reconfigure_mnt (struct path *path,unsigned int mnt_flags) +int do_reconfigure_mnt (struct path *path,unsigned int mnt_flags) {struct super_block *sb = path->mnt->mnt_sb;struct mount *mnt =real_mount (path->mnt);
Signature · 1 line
2.16.4
James Bottomley
maintainerPATCH v3 6/6 fs: bind: add configfs type for bind mounts
In reply to James BottomleyThis can do the equivalent of open_tree and also do bind mount reconfiguration from ro to rw and vice versa.
To get the equvalent of open tree you need to do
mnt = open("/path/to/tree", O_PATH);
fd = configfs_open(bind, O_CLOEXEC);
configfs_action(fd, CONFIGFD_SET_FD, "pathfd", NULL, mnt);
configfs_action(fd, CONFIGFD_SET_FLAG, "detached", NULL, 0);
configfs_action(fd, CONFIGFD_SET_FLAG, "recursive", NULL, 0);
configfs_action(fd, CONFIGFD_CMD_CREATE, NULL, NULL, 0);
configfs_action(fd, CONFIGFD_GET_FD, "bindfd", &bfd, NULL, O_CLOEXEC);And bfd will now contain the file descriptor to pass to move_tree. There is a deficiency over the original implementation in that the open system call has no way of clearing the LOOKUP_AUTOMOUNT path, but that's fixable.
To do a mount reconfigure to change the bind mount to readonly do
mnt = open("/path/to/tree", O_PATH);
fd = configfs_open(bind, O_CLOEXEC);
configfs_action(fd, CONFIGFD_SET_FD, "pathfd", NULL, mnt);
configfs_action(fd, CONFIGFD_SET_FLAG, "ro", NULL, 0);
configfs_action(fd, CONFIGFD_CMD_RECONFIGURE, NULL, NULL, 0);And the bind properties will be changed. You can also pass the "rw" flag to reset the read only.
---
v2: add nodev and noexec mount reconfigurations
--- fs/Makefile | 2 +- fs/bind.c | 232 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 233 insertions(+), 1 deletion(-) create mode 100644 fs/bind.c
fs/Makefile +1 -1
@@ -14,7 +14,7 @@ obj-y := open.o read_write.o file_table.o super.o \ pnode.o splice.o sync.o utimes.o d_path.o \ stack.o fs_struct.o statfs.o fs_pin.o nsfs.o \ fs_types.o fs_context.o fs_parser.o fsopen.o \ - configfd.o + configfd.o bind.o ifeq ($(CONFIG_BLOCK),y) obj-y += buffer.o block_dev.o direct-io.o mpage.o
fs/bind.c new file +232 -0
232 lines not on this page · raw message
Signature · 1 line
2.16.4