lkml.org 
[lkml]   [2018]   [Sep]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [PATCH 14/33] vfs: Implement a filesystem superblock creation/configuration context [ver #11]
Date
I think I need to include something like the attached change in this patch.
Changes also need to be made to proc and cgroup.

David
---
commit 1a336480a0f664b3e1988a581bccd4fa10d98764
Author: David Howells <dhowells@redhat.com>
Date: Tue Sep 18 17:25:23 2018 +0100

fix remount

diff --git a/fs/fs_context.c b/fs/fs_context.c
index a82679441031..1f36b72e3ee9 100644
--- a/fs/fs_context.c
+++ b/fs/fs_context.c
@@ -42,8 +42,6 @@ struct legacy_fs_context {
enum legacy_fs_param param_type;
};

-static int legacy_init_fs_context(struct fs_context *fc, struct dentry *dentry);
-
static const struct constant_table common_set_sb_flag[] = {
{ "dirsync", SB_DIRSYNC },
{ "lazytime", SB_LAZYTIME },
@@ -293,7 +291,6 @@ struct fs_context *vfs_new_fs_context(struct file_system_type *fs_type,
break;
}

-
/* TODO: Make all filesystems support this unconditionally */
init_fs_context = fc->fs_type->init_fs_context;
if (!init_fs_context)
@@ -662,12 +659,20 @@ const struct fs_context_operations legacy_fs_context_ops = {
* Initialise a legacy context for a filesystem that doesn't support
* fs_context.
*/
-static int legacy_init_fs_context(struct fs_context *fc, struct dentry *dentry)
+int legacy_init_fs_context(struct fs_context *fc, struct dentry *dentry)
{
+ switch (fc->purpose) {
+ default:
+ fc->fs_private = kzalloc(sizeof(struct legacy_fs_context),
+ GFP_KERNEL);
+ if (!fc->fs_private)
+ return -ENOMEM;
+ break;

- fc->fs_private = kzalloc(sizeof(struct legacy_fs_context), GFP_KERNEL);
- if (!fc->fs_private)
- return -ENOMEM;
+ case FS_CONTEXT_FOR_UMOUNT:
+ case FS_CONTEXT_FOR_EMERGENCY_RO:
+ break;
+ }

fc->ops = &legacy_fs_context_ops;
return 0;
diff --git a/fs/internal.h b/fs/internal.h
index d25cb82af69d..fc2da60abbcd 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -55,6 +55,7 @@ extern void __init chrdev_init(void);
* fs_context.c
*/
extern const struct fs_context_operations legacy_fs_context_ops;
+extern int legacy_init_fs_context(struct fs_context *fc, struct dentry *dentry);

/*
* fsopen.c
diff --git a/fs/namespace.c b/fs/namespace.c
index ddb2c3b88cd6..86b60566fcdf 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1429,9 +1429,19 @@ static int do_umount_root(struct super_block *sb)
};

down_write(&sb->s_umount);
- if (!sb_rdonly(sb))
- /* Might want to call ->init_fs_context(). */
- ret = reconfigure_super(&fc);
+ if (!sb_rdonly(sb)) {
+ int ret;
+
+ if (fc.fs_type->init_fs_context)
+ ret = fc.fs_type->init_fs_context(&fc, NULL);
+ else
+ ret = legacy_init_fs_context(&fc, NULL);
+
+ if (ret == 0) {
+ ret = reconfigure_super(&fc);
+ fc.ops->free(&fc);
+ }
+ }
up_write(&sb->s_umount);
return ret;
}
@@ -2396,7 +2406,7 @@ static int do_remount(struct path *path, int ms_flags, int sb_flags,

err = security_fs_context_validate(fc);
if (err)
- return err;
+ goto err_fc;

down_write(&sb->s_umount);
err = -EPERM;
diff --git a/fs/super.c b/fs/super.c
index e00b03249bfa..df8c4cebd000 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1026,12 +1026,20 @@ static void do_emergency_remount_callback(struct super_block *sb)

down_write(&sb->s_umount);
if (sb->s_root && sb->s_bdev && (sb->s_flags & SB_BORN) &&
- !sb_rdonly(sb))
- /* Might want to call ->init_fs_context(). */
+ !sb_rdonly(sb)) {
+ int ret;
+
+ if (fc.fs_type->init_fs_context)
+ ret = fc.fs_type->init_fs_context(&fc, NULL);
+ else
+ ret = legacy_init_fs_context(&fc, NULL);
+
/*
* What lock protects sb->s_flags??
*/
- reconfigure_super(&fc);
+ if (ret == 0)
+ reconfigure_super(&fc);
+ }
up_write(&sb->s_umount);
}

\
 
 \ /
  Last update: 2018-09-18 18:40    [W:0.279 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site