linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] lockd: Change nsm_use_hostnames from bool to u32
@ 2016-12-11 14:49 Jia He
  2016-12-11 14:49 ` [PATCH 1/1] " Jia He
  0 siblings, 1 reply; 3+ messages in thread
From: Jia He @ 2016-12-11 14:49 UTC (permalink / raw)
  To: linux-nfs
  Cc: J. Bruce Fields, Jeff Layton, Trond Myklebust, Anna Schumaker,
	linux-kernel, Jia He

nsm_use_hostnames is a module parameter and it will be exported to sysctl
procfs. This is to let user sometimes change it from userspace. But the
minimal unit for sysctl procfs read/write it sizeof(int).
In big endian system, the converting from/to  bool to/from int will cause
error for proc items.

This patch changes the type definition of nsm_use_hostnames.

The test case I used:
/***************************************************************/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sysctl.h>

bool __read_mostly nsm_use_hostnames;
module_param(nsm_use_hostnames, bool, 0644);

static struct ctl_table my_sysctl[] = {
        {
                .procname       = "nsm_use_hostnames",
                .data           = &nsm_use_hostnames,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = &proc_dointvec,
        },
        {}
};

static struct ctl_table my_root[] = {
        {
        .procname       = "mysysctl",
        .mode           = 0555,
        .child          = my_sysctl,
        },
        {}
};

static struct ctl_table_header * my_ctl_header;

static int __init sysctl_exam_init(void)
{
        my_ctl_header = register_sysctl_table(&my_root);
        if (my_ctl_header == NULL)
                printk("error regiester sysctl");

        return 0;
}

static void __exit sysctl_exam_exit(void)
{
        unregister_sysctl_table(my_ctl_header);
}

module_init(sysctl_exam_init);
module_exit(sysctl_exam_exit);
MODULE_LICENSE("GPL");
/****************************************************************/

[root@bigendian my]# insmod -f /root/my/hello.ko nsm_use_hostnames=1   
[root@bigendian my]# cat /proc/sys/mysysctl/nsm_use_hostnames 
16777216

After I change the bool to int:
[root@bigendian my]# insmod -f /root/my/hello.ko nsm_use_hostnames=1
[root@bigendian my]# cat /proc/sys/mysysctl/nsm_use_hostnames
1

In little endian system, there is no such issue.

Jia He (1):
  lockd: Change nsm_use_hostnames from bool to u32

 fs/lockd/mon.c | 2 +-
 fs/lockd/svc.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] lockd: Change nsm_use_hostnames from bool to u32
  2016-12-11 14:49 [PATCH 0/1] lockd: Change nsm_use_hostnames from bool to u32 Jia He
@ 2016-12-11 14:49 ` Jia He
  2016-12-11 15:04   ` kbuild test robot
  0 siblings, 1 reply; 3+ messages in thread
From: Jia He @ 2016-12-11 14:49 UTC (permalink / raw)
  To: linux-nfs
  Cc: J. Bruce Fields, Jeff Layton, Trond Myklebust, Anna Schumaker,
	linux-kernel, Jia He

nsm_use_hostnames is a module parameter and it will be exported to sysctl
procfs. This is to let user sometimes change it from userspace. But the
minimal unit for sysctl procfs read/write it sizeof(int).
In big endian system, the converting from/to  bool to/from int will cause
error for proc items.

This patch changes the type definition of nsm_use_hostnames.

Signed-off-by: Jia He <hejianet@gmail.com>
---
 fs/lockd/mon.c | 2 +-
 fs/lockd/svc.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 19166d4..3e7ff4d 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -57,7 +57,7 @@ static				DEFINE_SPINLOCK(nsm_lock);
  * Local NSM state
  */
 u32	__read_mostly		nsm_local_state;
-bool	__read_mostly		nsm_use_hostnames;
+u32	__read_mostly		nsm_use_hostnames;
 
 static inline struct sockaddr *nsm_addr(const struct nsm_handle *nsm)
 {
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index fc4084e..308033d 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -658,7 +658,7 @@ module_param_call(nlm_udpport, param_set_port, param_get_int,
 		  &nlm_udpport, 0644);
 module_param_call(nlm_tcpport, param_set_port, param_get_int,
 		  &nlm_tcpport, 0644);
-module_param(nsm_use_hostnames, bool, 0644);
+module_param(nsm_use_hostnames, u32, 0644);
 module_param(nlm_max_connections, uint, 0644);
 
 static int lockd_init_net(struct net *net)
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] lockd: Change nsm_use_hostnames from bool to u32
  2016-12-11 14:49 ` [PATCH 1/1] " Jia He
@ 2016-12-11 15:04   ` kbuild test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2016-12-11 15:04 UTC (permalink / raw)
  To: Jia He
  Cc: kbuild-all, linux-nfs, J. Bruce Fields, Jeff Layton,
	Trond Myklebust, Anna Schumaker, linux-kernel, Jia He

[-- Attachment #1: Type: text/plain, Size: 2880 bytes --]

Hi Jia,

[auto build test ERROR on nfsd/nfsd-next]
[also build test ERROR on v4.9-rc8 next-20161209]
[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/Jia-He/lockd-Change-nsm_use_hostnames-from-bool-to-u32/20161211-225133
base:   git://linux-nfs.org/~bfields/linux.git nfsd-next
config: i386-randconfig-x006-201650 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

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

   In file included from include/linux/module.h:18:0,
                    from fs/lockd/svc.c:15:
>> include/linux/moduleparam.h:146:27: error: expected ')' before '&' token
     param_check_##type(name, &(value));       \
                              ^
>> include/linux/moduleparam.h:126:2: note: in expansion of macro 'module_param_named'
     module_param_named(name, name, type, perm)
     ^~~~~~~~~~~~~~~~~~
>> fs/lockd/svc.c:661:1: note: in expansion of macro 'module_param'
    module_param(nsm_use_hostnames, u32, 0644);
    ^~~~~~~~~~~~
>> include/linux/moduleparam.h:147:25: error: 'param_ops_u32' undeclared here (not in a function)
     module_param_cb(name, &param_ops_##type, &value, perm);     \
                            ^
   include/linux/moduleparam.h:224:39: note: in definition of macro '__module_param_call'
     = { __param_str_##name, THIS_MODULE, ops,   \
                                          ^~~
>> include/linux/moduleparam.h:147:2: note: in expansion of macro 'module_param_cb'
     module_param_cb(name, &param_ops_##type, &value, perm);     \
     ^~~~~~~~~~~~~~~
>> include/linux/moduleparam.h:126:2: note: in expansion of macro 'module_param_named'
     module_param_named(name, name, type, perm)
     ^~~~~~~~~~~~~~~~~~
>> fs/lockd/svc.c:661:1: note: in expansion of macro 'module_param'
    module_param(nsm_use_hostnames, u32, 0644);
    ^~~~~~~~~~~~
--
>> fs/lockd/mon.c:60:20: error: conflicting types for 'nsm_use_hostnames'
    u32 __read_mostly  nsm_use_hostnames;
                       ^~~~~~~~~~~~~~~~~
   In file included from fs/lockd/mon.c:18:0:
   include/linux/lockd/lockd.h:199:15: note: previous declaration of 'nsm_use_hostnames' was here
    extern bool   nsm_use_hostnames;
                  ^~~~~~~~~~~~~~~~~

vim +/nsm_use_hostnames +60 fs/lockd/mon.c

    54	static				DEFINE_SPINLOCK(nsm_lock);
    55	
    56	/*
    57	 * Local NSM state
    58	 */
    59	u32	__read_mostly		nsm_local_state;
  > 60	u32	__read_mostly		nsm_use_hostnames;
    61	
    62	static inline struct sockaddr *nsm_addr(const struct nsm_handle *nsm)
    63	{

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 27053 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-11 15:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-11 14:49 [PATCH 0/1] lockd: Change nsm_use_hostnames from bool to u32 Jia He
2016-12-11 14:49 ` [PATCH 1/1] " Jia He
2016-12-11 15:04   ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).