[Devel] [PATCH RHEL7 COMMIT] ms/sysfs: create bin_attributes under the requested group

Konstantin Khorenko khorenko at virtuozzo.com
Thu Nov 5 05:36:24 PST 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.9.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.9.6
------>
commit 63dc5f4b1e6091dd7e7cd3a2fa0b20141fe45c74
Author: Vladimir Davydov <vdavydov at virtuozzo.com>
Date:   Thu Nov 5 17:36:24 2015 +0400

    ms/sysfs: create bin_attributes under the requested group
    
    https://jira.sw.ru/browse/PSBM-32460
    
    From: Cody P Schafer <cody at linux.vnet.ibm.com>
    
    bin_attributes created/updated in create_files() (such as those listed
    via (struct device).attribute_groups) were not placed under the
    specified group, and instead appeared in the base kobj directory.
    
    Fix this by making bin_attributes use creating code similar to normal
    attributes.
    
    A quick grep shows that no one is using bin_attrs in a named attribute
    group yet, so we can do this without breaking anything in usespace.
    
    Note that I do not add is_visible() support to
    bin_attributes, though that could be done as well.
    
    Signed-off-by: Cody P Schafer <cody at linux.vnet.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
    (cherry picked from commit aabaf4c2050d21d39fe11eec889c508e84d6a328)
    Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
    
    Conflicts:
    	fs/sysfs/cgroup.c
---
 fs/sysfs/group.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index 5f92cd2..c2f76a5 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -29,7 +29,8 @@ static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
 			sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name);
 	if (grp->bin_attrs)
 		for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++)
-			sysfs_remove_bin_file(kobj, *bin_attr);
+			sysfs_hash_and_remove(dir_sd, NULL,
+					      (*bin_attr)->attr.name);
 }
 
 static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
@@ -71,8 +72,10 @@ static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
 	if (grp->bin_attrs) {
 		for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++) {
 			if (update)
-				sysfs_remove_bin_file(kobj, *bin_attr);
-			error = sysfs_create_bin_file(kobj, *bin_attr);
+				sysfs_hash_and_remove(dir_sd, NULL,
+						      (*bin_attr)->attr.name);
+			error = sysfs_add_file(dir_sd, &(*bin_attr)->attr,
+					       SYSFS_KOBJ_BIN_ATTR);
 			if (error)
 				break;
 		}



More information about the Devel mailing list