[Devel] [PATCH RHEL7 COMMIT] ve/binfmt_misc: do not use sb->s_fs_info

Konstantin Khorenko khorenko at virtuozzo.com
Fri Aug 28 05:42:43 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.6.3
------>
commit 17dd96483ff558d44c98c3f8bcb04a86aca843a5
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Fri Aug 28 16:42:43 2015 +0400

    ve/binfmt_misc: do not use sb->s_fs_info
    
    Patchset description:
    
    zap sb->s_ns + fix memleak in binfmt_misc
    
    Vladimir Davydov (6):
      binfmt_misc: do not use sb->s_fs_info
      Revert "VE/VFS: use sb->s_ns member to store namespace for mount_ns()
        calls"
      Revert "ve/sunrpc: use correct pointer to net_namespace in auth_gss.c"
      Revert "nfsd/sunrpc/mqueue: use sb->s_ns instead of data in
        fill_super"
      binfmt_misc: do not use s_ns
      binfmt_misc: destroy all nodes on ve stop
    
    https://jira.sw.ru/browse/PSBM-39154
    
    Reviewed-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
    
    ======================
    This patch description:
    
    When we virtualized binfmt_misc, we made sb->s_fs_info store a pointer
    to binfmt_misc struct. At the same time, we store a pointer to the owner
    ve_struct in sb->s_ns and a pointer to the same binfmt_misc struct in
    ve_struct->binfmt_misc. That said, we don't actually need to use
    s_fs_info, because we can get the binfmt_misc by dereferencing
    sb->s_ns->binfmt_misc.
    
    Using sb->s_fs_info instead of sb->s_ns will allow us to revert our
    patches introducing sb->s_ns.
    
    This could be merged to 0b0dbb644794 ("VE/BINFTM: virtualization").
    
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 fs/binfmt_misc.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 7e760d2..d0cb80c 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -65,6 +65,8 @@ struct binfmt_misc {
 	int entry_count;
 };
 
+#define BINFMT_MISC(sb)		(((struct ve_struct *)(sb)->s_ns)->binfmt_misc)
+
 /* 
  * Check if we support the binfmt
  * if we do, return the node, else NULL
@@ -541,7 +543,7 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
 	Node *e = file_inode(file)->i_private;
 	int res = parse_command(buffer, count);
 	struct super_block *sb = file->f_path.dentry->d_sb;
-	struct binfmt_misc *bm_data = sb->s_fs_info;
+	struct binfmt_misc *bm_data = BINFMT_MISC(sb);
 
 	switch (res) {
 		case 1: clear_bit(Enabled, &e->flags);
@@ -576,7 +578,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
 	struct inode *inode;
 	struct dentry *root, *dentry;
 	struct super_block *sb = file->f_path.dentry->d_sb;
-	struct binfmt_misc *bm_data = sb->s_fs_info;
+	struct binfmt_misc *bm_data = BINFMT_MISC(sb);
 	int err = 0;
 
 	e = create_entry(buffer, count);
@@ -641,7 +643,7 @@ static const struct file_operations bm_register_operations = {
 static ssize_t
 bm_status_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
 {
-	struct binfmt_misc *bm_data = file->f_dentry->d_sb->s_fs_info;
+	struct binfmt_misc *bm_data = BINFMT_MISC(file->f_dentry->d_sb);
 	char *s = bm_data->enabled ? "enabled\n" : "disabled\n";
 
 	return simple_read_from_buffer(buf, nbytes, ppos, s, strlen(s));
@@ -650,7 +652,7 @@ bm_status_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
 static ssize_t bm_status_write(struct file * file, const char __user * buffer,
 		size_t count, loff_t *ppos)
 {
-	struct binfmt_misc *bm_data = file->f_dentry->d_sb->s_fs_info;
+	struct binfmt_misc *bm_data = BINFMT_MISC(file->f_dentry->d_sb);
 	int res = parse_command(buffer, count);
 	struct dentry *root;
 
@@ -681,7 +683,7 @@ static const struct file_operations bm_status_operations = {
 
 static void bm_put_super(struct super_block *sb)
 {
-	struct binfmt_misc *bm_data = sb->s_fs_info;
+	struct binfmt_misc *bm_data = BINFMT_MISC(sb);
 	struct ve_struct *ve = sb->s_ns;
 
 	bm_data->enabled = 0;
@@ -723,7 +725,6 @@ static int bm_fill_super(struct super_block * sb, void * data, int silent)
 	}
 
 	sb->s_op = &s_ops;
-	sb->s_fs_info = bm_data;
 
 	bm_data->enabled = 1;
 	get_ve(ve);



More information about the Devel mailing list