Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1540039

[PATCH v2 0/1] lockd: Change nsm_use_hostnames from bool to u32

Path csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From Jia He <hejianet@gmail.com>
Newsgroups linux.kernel
Subject [PATCH v2 0/1] lockd: Change nsm_use_hostnames from bool to u32
Date Sun, 11 Dec 2016 16:40:02 +0100
Message-ID <sNeoh-OU-19@gated-at.bofh.it> (permalink)
X-Original-To linux-nfs@vger.kernel.org
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Ewi2XGNXRtBu452u746WVBF211C+4Uxwc93k0tWM+gI=; b=KZ5xIhy+gvXkXyZug1iGjVI723WhooSGbYV4FTTLpO9rauzGhVunBt9SJ5kdD5BdsJ 6yi2nl2PKscJk/I/0TnyObqyLQiP5dA/bxJ6huYtpnxeE6ABCrqJlmrsNyreZwdIwuaH RyKGWcqW6EO2uv0M476VA/KHOaydOY6sJVAChXLzydV0Fyo8HkCeYo6rca5DjLIzogfS XEr7D82/o+XU8EVNRQgE5GVLA9RzTET34USean/5HcwR7WfOxIygAtZEAf2fJbPJhlkC aMUVcvh1lDpbVVbkR71eQUfxyIW3gpJQA/T2GJPHlm5nszVIfu87/LJukAxf4PDwwBOa oAJg==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Ewi2XGNXRtBu452u746WVBF211C+4Uxwc93k0tWM+gI=; b=E9ajC3AwxymP/4Vm9ALRlL7m0J8sk7YxIRzlhhUEyWUpz5re5MFCHqxXR4qbfSnk1/ ziu41f4bnQHvB5wxMx4yMYIH5CG6RS81j/Y4x1jcqqVxxq0tSrYumOWqFQ5aW59vbabU GIXSd1hnLOKoYxbFT3xpiAxgAXZXcjiBTV7rq8aon1WmGqnvQ9dL0aQhRhd86emgi5ZN BBuT8SwwekOfaZdW6BYHYAm2eYMZGURaRiDgdQnuyyKYs2mLTbJrqdFio4c9okk3wDYA PcFX6FLX5YK0vtPxE2I70VsoGgIBi7gBco9MKphh1Wad+pun6XSjt87dO6Zq4T2lPxbn aedw==
X-Gm-Message-State AKaTC00Zavlh1hBXSSruyy87Pp2lOWg0WDlTXPYP880ATW4jbXWTatLOGpDR06Y5W/KNeg==
X-Received by 10.55.181.198 with SMTP id e189mr1542014qkf.231.1481470612229; Sun, 11 Dec 2016 07:36:52 -0800 (PST)
X-Mailer git-send-email 2.5.5
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 79
Organization linux.* mail to news gateway
X-Original-Cc "J. Bruce Fields" <bfields@fieldses.org>, Jeff Layton <jlayton@poochiereds.net>, Trond Myklebust <trond.myklebust@primarydata.com>, Anna Schumaker <anna.schumaker@netapp.com>, linux-kernel@vger.kernel.org, Jia He <hejianet@gmail.com>
X-Original-Date Sun, 11 Dec 2016 23:36:48 +0800
X-Original-Message-ID <1481470609-31488-1-git-send-email-hejianet@gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1540039

Show key headers only | View raw


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 +-
 include/linux/lockd/lockd.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.5.5

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/1] lockd: Change nsm_use_hostnames from bool to u32 Jia He <hejianet@gmail.com> - 2016-12-11 16:40 +0100
  Re: [PATCH v2 0/1] lockd: Change nsm_use_hostnames from bool to u32 Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-12-11 19:00 +0100

csiph-web