From patchwork Sun Dec 11 17:43:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: xinhui X-Patchwork-Id: 9469833 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2E3CC60231 for ; Sun, 11 Dec 2016 17:44:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2985B282EC for ; Sun, 11 Dec 2016 17:44:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DE702831C; Sun, 11 Dec 2016 17:44:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECACA282EC for ; Sun, 11 Dec 2016 17:44:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753633AbcLKRnn (ORCPT ); Sun, 11 Dec 2016 12:43:43 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36810 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752978AbcLKRnn (ORCPT ); Sun, 11 Dec 2016 12:43:43 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uBBHd9cJ105940 for ; Sun, 11 Dec 2016 12:43:42 -0500 Received: from e28smtp04.in.ibm.com (e28smtp04.in.ibm.com [125.16.236.4]) by mx0a-001b2d01.pphosted.com with ESMTP id 278f3ddmh9-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Sun, 11 Dec 2016 12:43:42 -0500 Received: from localhost by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 11 Dec 2016 23:13:38 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp04.in.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 11 Dec 2016 23:13:36 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 96F0AE0024; Sun, 11 Dec 2016 23:14:09 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay01.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uBBHhZHs42401986; Sun, 11 Dec 2016 23:13:35 +0530 Received: from d28av03.in.ibm.com (localhost [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id uBBHhXAx021864; Sun, 11 Dec 2016 23:13:35 +0530 Received: from mmnipxh.local ([9.200.38.98]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id uBBHhUjD021829; Sun, 11 Dec 2016 23:13:31 +0530 Subject: Re: [PATCH v2 1/1] lockd: Change nsm_use_hostnames from bool to u32 To: Jia He , linux-nfs@vger.kernel.org References: <1481470609-31488-1-git-send-email-hejianet@gmail.com> <1481470609-31488-2-git-send-email-hejianet@gmail.com> Cc: "J. Bruce Fields" , Jeff Layton , Trond Myklebust , Anna Schumaker , linux-kernel@vger.kernel.org From: Pan Xinhui Date: Mon, 12 Dec 2016 01:43:35 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1481470609-31488-2-git-send-email-hejianet@gmail.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16121117-0012-0000-0000-0000037A5661 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16121117-0013-0000-0000-00001A6F0FE2 Message-Id: <819a5924-6fd4-adce-c03f-2a83c99d0a27@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-11_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1612110278 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP hi, jia nice catch! However I think we should fix it totally. This is because do_proc_dointvec_conv() try to get a int value from a bool *. something like below might help. pls. ignore the code style and this is tested :) > 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. > > V2: Changes extern type in lockd.h > Signed-off-by: Jia He > --- > fs/lockd/mon.c | 2 +- > fs/lockd/svc.c | 2 +- > include/linux/lockd/lockd.h | 2 +- > 3 files changed, 3 insertions(+), 3 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) > diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h > index c153738..db52152 100644 > --- a/include/linux/lockd/lockd.h > +++ b/include/linux/lockd/lockd.h > @@ -196,7 +196,7 @@ extern struct svc_procedure nlmsvc_procedures4[]; > #endif > extern int nlmsvc_grace_period; > extern unsigned long nlmsvc_timeout; > -extern bool nsm_use_hostnames; > +extern u32 nsm_use_hostnames; > extern u32 nsm_local_state; > > /* > --- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index fc4084e..7eeaee4 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -519,6 +519,8 @@ EXPORT_SYMBOL_GPL(lockd_down); * Sysctl parameters (same as module parameters, different interface). */ +int proc_dou8vec(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos); static struct ctl_table nlm_sysctls[] = { { .procname = "nlm_grace_period", @@ -561,7 +563,7 @@ static struct ctl_table nlm_sysctls[] = { .data = &nsm_use_hostnames, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = proc_dou8vec, }, { .procname = "nsm_local_state", diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 706309f..6307737 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2112,6 +2112,30 @@ static int proc_put_char(void __user **buf, size_t *size, char c) return 0; } + +static int do_proc_dou8vec_conv(bool *negp, unsigned long *lvalp, + u8 *valp, + int write, void *data) +{ + if (write) { + if (*negp) { + *valp = -*lvalp; + } else { + *valp = *lvalp; + } + } else { + int val = *valp; + if (val < 0) { + *negp = true; + *lvalp = -(unsigned long)val; + } else { + *negp = false; + *lvalp = (unsigned long)val; + } + } + return 0; +} + static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, int *valp, int write, void *data) @@ -2296,6 +2320,14 @@ int proc_douintvec(struct ctl_table *table, int write, do_proc_douintvec_conv, NULL); } +int proc_dou8vec(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return do_proc_dointvec(table, write, buffer, lenp, ppos, + do_proc_dou8vec_conv, NULL); +} + + 在 2016/12/11 23:36, Jia He 写道: > nsm_use_hostnames is a module paramter and it will be exported to sysctl