Skip to contentSkip to conversation

constify lustre attribute_group structures

PATCH Superseded Arvind Yadav 2 participants 12 messages Jul 17, 2017 Staging

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover constify lustre attribute_group structures

attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by <linux/sysfs.h> work with const attribute_group. So mark the non-const structs as const.

Arvind Yadav (4):
[PATCH 1/4] staging: lustre: constify attribute_group structures. [PATCH 2/4] staging: lustre: ldlm: constify attribute_group structures. [PATCH 3/4] staging: lustre: obdclass: linux: constify attribute_group structures. [PATCH 4/4] staging: lustre: obdclass: constify attribute_group structures.

 drivers/staging/lustre/lustre/include/lprocfs_status.h      | 4 ++--
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c             | 2 +-
 drivers/staging/lustre/lustre/lmv/lproc_lmv.c               | 2 +-
 drivers/staging/lustre/lustre/lov/lproc_lov.c               | 2 +-
 drivers/staging/lustre/lustre/mdc/lproc_mdc.c               | 2 +-
 drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 2 +-
 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c     | 2 +-
 drivers/staging/lustre/lustre/osc/lproc_osc.c               | 2 +-
 8 files changed, 9 insertions(+), 9 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/4 staging: lustre: constify attribute_group structures.

attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by <linux/sysfs.h> work with const attribute_group. So mark the non-const structs as const.

File size before:
text data bss dec hex filename

   9489	    992	     40	  10521	   2919	lustre/lustre/osc/lproc_osc.o
   1289	    288	      0	   1577	    629	lustre/lustre/lmv/lproc_lmv.o
   3794	    928	     40	   4762	   129a	lustre/lustre/lov/lproc_lov.o
   3802	    576	     40	   4418	   1142	lustre/lustre/mdc/lproc_mdc.o

File size After adding 'const':
text data bss dec hex filename

   9553	    928	     40	  10521	   2919	lustre/lustre/osc/lproc_osc.o
   1353	    224	      0	   1577	    629	lustre/lustre/lmv/lproc_lmv.o
   3858	    864	     40	   4762	   129a	lustre/lustre/lov/lproc_lov.o
   3866	    512	     40	   4418	   1142	lustre/lustre/mdc/lproc_mdc.o
---
 drivers/staging/lustre/lustre/include/lprocfs_status.h | 4 ++--
 drivers/staging/lustre/lustre/lmv/lproc_lmv.c          | 2 +-
 drivers/staging/lustre/lustre/lov/lproc_lov.c          | 2 +-
 drivers/staging/lustre/lustre/mdc/lproc_mdc.c          | 2 +-
 drivers/staging/lustre/lustre/osc/lproc_osc.c          | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)
drivers/staging/lustre/lustre/include/lprocfs_status.h +2 -2
index 915283c..9054d37 100644
@@ -59,7 +59,7 @@ struct lprocfs_vars {
 
 struct lprocfs_static_vars {
 	struct lprocfs_vars *obd_vars;
-	struct attribute_group *sysfs_vars;
+	const struct attribute_group *sysfs_vars;
 };
 
 /* if we find more consumers this could be generalized */
@@ -468,7 +468,7 @@ struct dentry *ldebugfs_register(const char *name,
 void ldebugfs_remove(struct dentry **entryp);
 
 int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
-		      struct attribute_group *attrs);
+		      const struct attribute_group *attrs);
 int lprocfs_obd_cleanup(struct obd_device *obd);
 
 int ldebugfs_seq_create(struct dentry *parent,
drivers/staging/lustre/lustre/lmv/lproc_lmv.c +1 -1
index bf25f88..4c13e39 100644
@@ -161,7 +161,7 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file)
 	NULL,
 };
 
-static struct attribute_group lmv_attr_group = {
+static const struct attribute_group lmv_attr_group = {
 	.attrs = lmv_attrs,
 };
 
drivers/staging/lustre/lustre/lov/lproc_lov.c +1 -1
index eb6d30d..ce46821 100644
@@ -279,7 +279,7 @@ static int lov_target_seq_open(struct inode *inode, struct file *file)
 	NULL,
 };
 
-static struct attribute_group lov_attr_group = {
+static const struct attribute_group lov_attr_group = {
 	.attrs = lov_attrs,
 };
 
drivers/staging/lustre/lustre/mdc/lproc_mdc.c +1 -1
index 9021c46..9fea535 100644
@@ -219,7 +219,7 @@ static ssize_t max_pages_per_rpc_show(struct kobject *kobj,
 	NULL,
 };
 
-static struct attribute_group mdc_attr_group = {
+static const struct attribute_group mdc_attr_group = {
 	.attrs = mdc_attrs,
 };
 
drivers/staging/lustre/lustre/osc/lproc_osc.c +1 -1
index 86f252d..6e0fd15 100644
@@ -831,7 +831,7 @@ int lproc_osc_attach_seqstat(struct obd_device *dev)
 	NULL,
 };
 
-static struct attribute_group osc_attr_group = {
+static const struct attribute_group osc_attr_group = {
 	.attrs = osc_attrs,
 };
 
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH 1/4] staging: lustre: constify attribute_group structures.

url: https://github.com/0day-ci/linux/commits/Arvind-Yadav/constify-lustre-attribute_group-structures/20170717-142957 config: sparc64-allyesconfig (attached as .config) compiler…

Hi Arvind,

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v4.13-rc1 next-20170717]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Arvind-Yadav/constify-lustre-attribute_group-structures/20170717-142957
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64

Note: the linux-review/Arvind-Yadav/constify-lustre-attribute_group-structures/20170717-142957 HEAD a6df15f5fc00a12dffbac94e0ccc52155118946e builds fine.
It only hurts bisectibility.

All error/warnings (new ones prefixed by >>):

>> drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:1033:5: error: conflicting types for 'lprocfs_obd_setup'
    int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
        ^~~~~~~~~~~~~~~~~
   In file included from drivers/staging/lustre/lustre/obdclass/../include/obd_support.h:41:0,
                    from drivers/staging/lustre/lustre/obdclass/../include/obd_class.h:35,
                    from drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:39:
   drivers/staging/lustre/lustre/obdclass/../include/lprocfs_status.h:470:5: note: previous declaration of 'lprocfs_obd_setup' was here
    int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
        ^~~~~~~~~~~~~~~~~
   In file included from include/linux/linkage.h:6:0,
                    from include/linux/kernel.h:6,
                    from include/asm-generic/bug.h:15,
                    from arch/sparc/include/asm/bug.h:20,
                    from include/linux/bug.h:4,
                    from include/linux/mmdebug.h:4,
                    from include/linux/gfp.h:4,
                    from include/linux/slab.h:14,
                    from drivers/staging/lustre/lustre/obdclass/../include/obd_support.h:36,
                    from drivers/staging/lustre/lustre/obdclass/../include/obd_class.h:35,
                    from drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:39:
   drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:1066:19: error: conflicting types for 'lprocfs_obd_setup'
    EXPORT_SYMBOL_GPL(lprocfs_obd_setup);
                      ^
   include/linux/export.h:65:21: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;      \
                        ^~~
>> drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:1066:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(lprocfs_obd_setup);
    ^~~~~~~~~~~~~~~~~

In file included from drivers/staging/lustre/lustre/obdclass/../include/obd_support.h:41:0,
from drivers/staging/lustre/lustre/obdclass/../include/obd_class.h:35,
from drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:39:
drivers/staging/lustre/lustre/obdclass/../include/lprocfs_status.h:470:5: note: previous declaration of 'lprocfs_obd_setup' was here
int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
^~~~~~~~~~~~~~~~~

vim +/lprocfs_obd_setup +1033 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c

9b8013023 Oleg Drokin   2015-05-21  1032  
9b8013023 Oleg Drokin   2015-05-21 @1033  int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
9b8013023 Oleg Drokin   2015-05-21  1034  		      struct attribute_group *attrs)
d7e09d039 Peng Tao      2013-05-02  1035  {
d7e09d039 Peng Tao      2013-05-02  1036  	int rc = 0;
d7e09d039 Peng Tao      2013-05-02  1037  
9b8013023 Oleg Drokin   2015-05-21  1038  	init_completion(&obd->obd_kobj_unregister);
9b8013023 Oleg Drokin   2015-05-21  1039  	rc = kobject_init_and_add(&obd->obd_kobj, &obd_ktype,
9b8013023 Oleg Drokin   2015-05-21  1040  				  obd->obd_type->typ_kobj,
9b8013023 Oleg Drokin   2015-05-21  1041  				  "%s", obd->obd_name);
9b8013023 Oleg Drokin   2015-05-21  1042  	if (rc)
9b8013023 Oleg Drokin   2015-05-21  1043  		return rc;
9b8013023 Oleg Drokin   2015-05-21  1044  
9b8013023 Oleg Drokin   2015-05-21  1045  	if (attrs) {
9b8013023 Oleg Drokin   2015-05-21  1046  		rc = sysfs_create_group(&obd->obd_kobj, attrs);
9b8013023 Oleg Drokin   2015-05-21  1047  		if (rc) {
9b8013023 Oleg Drokin   2015-05-21  1048  			kobject_put(&obd->obd_kobj);
9b8013023 Oleg Drokin   2015-05-21  1049  			return rc;
9b8013023 Oleg Drokin   2015-05-21  1050  		}
9b8013023 Oleg Drokin   2015-05-21  1051  	}
9b8013023 Oleg Drokin   2015-05-21  1052  
61e87ab0f Dmitry Eremin 2015-05-21  1053  	obd->obd_debugfs_entry = ldebugfs_register(obd->obd_name,
61e87ab0f Dmitry Eremin 2015-05-21  1054  						   obd->obd_type->typ_debugfs_entry,
d7e09d039 Peng Tao      2013-05-02  1055  						   list, obd);
61e87ab0f Dmitry Eremin 2015-05-21  1056  	if (IS_ERR_OR_NULL(obd->obd_debugfs_entry)) {
61e87ab0f Dmitry Eremin 2015-05-21  1057  		rc = obd->obd_debugfs_entry ? PTR_ERR(obd->obd_debugfs_entry)
61e87ab0f Dmitry Eremin 2015-05-21  1058  					    : -ENOMEM;
1d8cb70c7 Greg Donald   2014-08-25  1059  		CERROR("error %d setting up lprocfs for %s\n",
1d8cb70c7 Greg Donald   2014-08-25  1060  		       rc, obd->obd_name);
61e87ab0f Dmitry Eremin 2015-05-21  1061  		obd->obd_debugfs_entry = NULL;
d7e09d039 Peng Tao      2013-05-02  1062  	}
9b8013023 Oleg Drokin   2015-05-21  1063  
d7e09d039 Peng Tao      2013-05-02  1064  	return rc;
d7e09d039 Peng Tao      2013-05-02  1065  }

da33f1dd9 Oleg Drokin 2016-02-06 @1066 EXPORT_SYMBOL_GPL(lprocfs_obd_setup);
d7e09d039 Peng Tao 2013-05-02 1067

:::::: The code at line 1033 was first introduced by commit
:::::: 9b8013023cb62360b56c04313687e93a1c2bf3d6 staging/lustre/obdclass: Prepare for procfs to sysfs migration

:::::: TO: Oleg Drokin <[email protected]> :::::: CC: Greg Kroah-Hartman <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 51477 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20170717/00fbe1e3/attachment-0001.bin>

#3 lore raw

Re: [PATCH 1/4] staging: lustre: constify attribute_group structures.

Sorry for noise. Please ignore this. I will fix this error and push again.

~arvind

Quoted 104 lines · kbuild test robot

Hi Arvind,

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v4.13-rc1 next-20170717]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Arvind-Yadav/constify-lustre-attribute_group-structures/20170717-142957
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64

Note: the linux-review/Arvind-Yadav/constify-lustre-attribute_group-structures/20170717-142957 HEAD a6df15f5fc00a12dffbac94e0ccc52155118946e builds fine.
It only hurts bisectibility.

All error/warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:1033:5: error: conflicting types for 'lprocfs_obd_setup'

int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
^~~~~~~~~~~~~~~~~
In file included from drivers/staging/lustre/lustre/obdclass/../include/obd_support.h:41:0,
from drivers/staging/lustre/lustre/obdclass/../include/obd_class.h:35,
from drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:39:
drivers/staging/lustre/lustre/obdclass/../include/lprocfs_status.h:470:5: note: previous declaration of 'lprocfs_obd_setup' was here
int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
^~~~~~~~~~~~~~~~~
In file included from include/linux/linkage.h:6:0,
from include/linux/kernel.h:6,
from include/asm-generic/bug.h:15,
from arch/sparc/include/asm/bug.h:20,
from include/linux/bug.h:4,
from include/linux/mmdebug.h:4,
from include/linux/gfp.h:4,
from include/linux/slab.h:14,
from drivers/staging/lustre/lustre/obdclass/../include/obd_support.h:36,
from drivers/staging/lustre/lustre/obdclass/../include/obd_class.h:35,
from drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:39:
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:1066:19: error: conflicting types for 'lprocfs_obd_setup'
EXPORT_SYMBOL_GPL(lprocfs_obd_setup);
^
include/linux/export.h:65:21: note: in definition of macro '___EXPORT_SYMBOL'
extern typeof(sym) sym; \
^~~

Quoted 1 line
Quoted 1 line

drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:1066:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'

EXPORT_SYMBOL_GPL(lprocfs_obd_setup);
^~~~~~~~~~~~~~~~~
In file included from drivers/staging/lustre/lustre/obdclass/../include/obd_support.h:41:0,
from drivers/staging/lustre/lustre/obdclass/../include/obd_class.h:35,
from drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:39:
drivers/staging/lustre/lustre/obdclass/../include/lprocfs_status.h:470:5: note: previous declaration of 'lprocfs_obd_setup' was here
int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
^~~~~~~~~~~~~~~~~

vim +/lprocfs_obd_setup +1033 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c

9b8013023 Oleg Drokin   2015-05-21  1032
9b8013023 Oleg Drokin   2015-05-21 @1033  int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
9b8013023 Oleg Drokin   2015-05-21  1034  		      struct attribute_group *attrs)
d7e09d039 Peng Tao      2013-05-02  1035  {
d7e09d039 Peng Tao      2013-05-02  1036  	int rc = 0;
d7e09d039 Peng Tao      2013-05-02  1037
9b8013023 Oleg Drokin   2015-05-21  1038  	init_completion(&obd->obd_kobj_unregister);
9b8013023 Oleg Drokin   2015-05-21  1039  	rc = kobject_init_and_add(&obd->obd_kobj, &obd_ktype,
9b8013023 Oleg Drokin   2015-05-21  1040  				  obd->obd_type->typ_kobj,
9b8013023 Oleg Drokin   2015-05-21  1041  				  "%s", obd->obd_name);
9b8013023 Oleg Drokin   2015-05-21  1042  	if (rc)
9b8013023 Oleg Drokin   2015-05-21  1043  		return rc;
9b8013023 Oleg Drokin   2015-05-21  1044
9b8013023 Oleg Drokin   2015-05-21  1045  	if (attrs) {
9b8013023 Oleg Drokin   2015-05-21  1046  		rc = sysfs_create_group(&obd->obd_kobj, attrs);
9b8013023 Oleg Drokin   2015-05-21  1047  		if (rc) {
9b8013023 Oleg Drokin   2015-05-21  1048  			kobject_put(&obd->obd_kobj);
9b8013023 Oleg Drokin   2015-05-21  1049  			return rc;
9b8013023 Oleg Drokin   2015-05-21  1050  		}
9b8013023 Oleg Drokin   2015-05-21  1051  	}
9b8013023 Oleg Drokin   2015-05-21  1052
61e87ab0f Dmitry Eremin 2015-05-21  1053  	obd->obd_debugfs_entry = ldebugfs_register(obd->obd_name,
61e87ab0f Dmitry Eremin 2015-05-21  1054  						   obd->obd_type->typ_debugfs_entry,
d7e09d039 Peng Tao      2013-05-02  1055  						   list, obd);
61e87ab0f Dmitry Eremin 2015-05-21  1056  	if (IS_ERR_OR_NULL(obd->obd_debugfs_entry)) {
61e87ab0f Dmitry Eremin 2015-05-21  1057  		rc = obd->obd_debugfs_entry ? PTR_ERR(obd->obd_debugfs_entry)
61e87ab0f Dmitry Eremin 2015-05-21  1058  					    : -ENOMEM;
1d8cb70c7 Greg Donald   2014-08-25  1059  		CERROR("error %d setting up lprocfs for %s\n",
1d8cb70c7 Greg Donald   2014-08-25  1060  		       rc, obd->obd_name);
61e87ab0f Dmitry Eremin 2015-05-21  1061  		obd->obd_debugfs_entry = NULL;
d7e09d039 Peng Tao      2013-05-02  1062  	}
9b8013023 Oleg Drokin   2015-05-21  1063
d7e09d039 Peng Tao      2013-05-02  1064  	return rc;
d7e09d039 Peng Tao      2013-05-02  1065  }

da33f1dd9 Oleg Drokin 2016-02-06 @1066 EXPORT_SYMBOL_GPL(lprocfs_obd_setup);
d7e09d039 Peng Tao 2013-05-02 1067

:::::: The code at line 1033 was first introduced by commit
:::::: 9b8013023cb62360b56c04313687e93a1c2bf3d6 staging/lustre/obdclass: Prepare for procfs to sysfs migration

:::::: TO: Oleg Drokin <[email protected]> :::::: CC: Greg Kroah-Hartman <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#4 lore raw

PATCH 2/4 staging: lustre: ldlm: constify attribute_group structures.

In reply to Arvind Yadav

attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by <linux/sysfs.h> work with const attribute_group. So mark the non-const structs as const.

---
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +1 -1
index fff930f..e0c3e5d 100644
@@ -926,7 +926,7 @@ static ssize_t cancel_unused_locks_before_replay_store(struct kobject *kobj,
 	NULL,
 };
 
-static struct attribute_group ldlm_attr_group = {
+static const struct attribute_group ldlm_attr_group = {
 	.attrs = ldlm_attrs,
 };
 
Signature · 1 line
1.9.1
#5 lore raw

Re: [PATCH 2/4] staging: lustre: ldlm: constify attribute_group structures.

Sorry for noise. Please ignore this.

~arvind

Quoted 22 lines · Arvind Yadav

attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by <linux/sysfs.h> work with const attribute_group. So mark the non-const structs as const.

---
  drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +1 -1
index fff930f..e0c3e5d 100644
@@ -926,7 +926,7 @@ static ssize_t cancel_unused_locks_before_replay_store(struct kobject *kobj,
  	NULL,
  };
 
-static struct attribute_group ldlm_attr_group = {
+static const struct attribute_group ldlm_attr_group = {
  	.attrs = ldlm_attrs,
  };
 
#6 lore raw

PATCH 3/4 staging: lustre: obdclass: linux: constify attribute_group structures.

In reply to Arvind Yadav

attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by <linux/sysfs.h> work with const attribute_group. So mark the non-const structs as const.

---
 drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +1 -1
index 9f5e829..eb88bd9 100644
@@ -405,7 +405,7 @@ static int obd_device_list_open(struct inode *inode, struct file *file)
 struct kobject *lustre_kobj;
 EXPORT_SYMBOL_GPL(lustre_kobj);
 
-static struct attribute_group lustre_attr_group = {
+static const struct attribute_group lustre_attr_group = {
 	.attrs = lustre_attrs,
 };
 
Signature · 1 line
1.9.1
#7 lore raw

Re: [PATCH 3/4] staging: lustre: obdclass: linux: constify attribute_group structures.

Sorry for noise. Please ignore this.

~arvind

Quoted 22 lines · Arvind Yadav

attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by <linux/sysfs.h> work with const attribute_group. So mark the non-const structs as const.

---
  drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +1 -1
index 9f5e829..eb88bd9 100644
@@ -405,7 +405,7 @@ static int obd_device_list_open(struct inode *inode, struct file *file)
  struct kobject *lustre_kobj;
  EXPORT_SYMBOL_GPL(lustre_kobj);
 
-static struct attribute_group lustre_attr_group = {
+static const struct attribute_group lustre_attr_group = {
  	.attrs = lustre_attrs,
  };
 
#8 lore raw

Re: [PATCH 3/4] staging: lustre: obdclass: linux: constify attribute_group structures.

In reply to Arvind Yadav

Sorry for noise. Please ignore this.

~arvind

Quoted 22 lines · Arvind Yadav

attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by <linux/sysfs.h> work with const attribute_group. So mark the non-const structs as const.

---
  drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +1 -1
index 9f5e829..eb88bd9 100644
@@ -405,7 +405,7 @@ static int obd_device_list_open(struct inode *inode, struct file *file)
  struct kobject *lustre_kobj;
  EXPORT_SYMBOL_GPL(lustre_kobj);
 
-static struct attribute_group lustre_attr_group = {
+static const struct attribute_group lustre_attr_group = {
  	.attrs = lustre_attrs,
  };
 
#9 lore raw

PATCH 4/4 staging: lustre: obdclass: constify attribute_group structures.

In reply to Arvind Yadav

attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by <linux/sysfs.h> work with const attribute_group. So mark the non-const structs as const.

---
 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +1 -1
index bc19f19..ba41983 100644
@@ -1031,7 +1031,7 @@ static void obd_sysfs_release(struct kobject *kobj)
 };
 
 int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
-		      struct attribute_group *attrs)
+		      const struct attribute_group *attrs)
 {
 	int rc = 0;
 
Signature · 1 line
1.9.1
#10 lore raw

Re: [PATCH 4/4] staging: lustre: obdclass: constify attribute_group structures.

Sorry for noise. Please ignore this. This change should not be separate.

~arvind

Quoted 22 lines · Arvind Yadav

attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by <linux/sysfs.h> work with const attribute_group. So mark the non-const structs as const.

---
  drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +1 -1
index bc19f19..ba41983 100644
@@ -1031,7 +1031,7 @@ static void obd_sysfs_release(struct kobject *kobj)
  };
 
  int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
-		      struct attribute_group *attrs)
+		      const struct attribute_group *attrs)
  {
  	int rc = 0;
 
#11 lore raw
In reply to Arvind Yadav

Sorry for noise. Please ignore this. It's having build error. Again, I will push all changes.

~arvind

Quoted 20 lines · Arvind Yadav

attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by <linux/sysfs.h> work with const attribute_group. So mark the non-const structs as const.

Arvind Yadav (4):
[PATCH 1/4] staging: lustre: constify attribute_group structures. [PATCH 2/4] staging: lustre: ldlm: constify attribute_group structures. [PATCH 3/4] staging: lustre: obdclass: linux: constify attribute_group structures. [PATCH 4/4] staging: lustre: obdclass: constify attribute_group structures.

  drivers/staging/lustre/lustre/include/lprocfs_status.h      | 4 ++--
  drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c             | 2 +-
  drivers/staging/lustre/lustre/lmv/lproc_lmv.c               | 2 +-
  drivers/staging/lustre/lustre/lov/lproc_lov.c               | 2 +-
  drivers/staging/lustre/lustre/mdc/lproc_mdc.c               | 2 +-
  drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 2 +-
  drivers/staging/lustre/lustre/obdclass/lprocfs_status.c     | 2 +-
  drivers/staging/lustre/lustre/osc/lproc_osc.c               | 2 +-
  8 files changed, 9 insertions(+), 9 deletions(-)