Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1989445imm; Wed, 16 May 2018 06:17:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpukJWvmtN9dJI/aPeefzEZntb+srErzGPjtQ2R09GLB4bbQHkzADiKS7pxyZo4m+Fh1MoM X-Received: by 2002:a17:902:bd46:: with SMTP id b6-v6mr958199plx.170.1526476669165; Wed, 16 May 2018 06:17:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526476669; cv=none; d=google.com; s=arc-20160816; b=dVZXNX5zeXXbav4KD3Y7PUbAM70Xg7RPqJZvOixxkhJxDBvEqF4joxVDsaOG1Q4VTY QgvUcMHFNUvsvu3SAFW9nYWpSjvbpgbLQVDKSsH6szHHTpkiB1Shn/wyTMwhIqE3pZQZ F3vpv6YzPOjFeVkGz2FGTGMPRnKU4pVs1hxniXdyeKpogj3EyApAx9ZMvigiIydpXYHq 2gel4MAE29HYkyxw36jqPxz+rHEUPlfhi5KHwzOOznnkqSxd+noEOVDDnjqCXI64cZD6 h2PIerDlWotKxTFINR4Grn+ykkvYLQWyKFvqIo1XCtUafq2q3Ec3Y2zVzIVMAra5bkwe kG+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=qQcPVuFqgs7U7N61pqYD7tvGkZTY8sJTWqs9liKjzAI=; b=ICAuosBR2GIFgfebO2jQjWr0c4T2xBmh+W14lm+XB22aG/0zo4hXeH6kWucNjXNqx8 6AR/Q9aKKOXgyhUpv65alXBHLkygHvn8/dIBlTqIh1ec9Hd6twJ50gLfjUtPN6ygr+GT yCfww2UqeMWCSzrXoUhD8RnMmjSYQ9ZjYnNzKOGY7yipJCoS7QublEaV3+EPt+oeacwK yVCHfOqxxr/H9g7M/lccingHCM0gjlRR+nCNwCdT5tEHiUGhwuEERvCF5WMj/Je2jkjR XPCRHKSfSNlzPJEaSulKm4+gHI8ZU74dS7Mk6G1xzxcIrhwkXsnYAVlurFfvHzbOoIzm 3c0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=h2IVWlTy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e92-v6si2507538pld.601.2018.05.16.06.17.34; Wed, 16 May 2018 06:17:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=h2IVWlTy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752573AbeEPNR2 (ORCPT + 99 others); Wed, 16 May 2018 09:17:28 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:44240 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751151AbeEPNRX (ORCPT ); Wed, 16 May 2018 09:17:23 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4GDFrRg030695; Wed, 16 May 2018 13:15:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=qQcPVuFqgs7U7N61pqYD7tvGkZTY8sJTWqs9liKjzAI=; b=h2IVWlTy7HAJb4V7XpzJhXHAOHCjUWBE1fOTsvvhL1gEbA09rV03P2gKV0VM41qio+s6 5JzJjeHBYeseaBfsB5yu1TZXQhdXujttrwaIM9JC5Oi90/bH0sCUs6EoTUMJb1DvY+3G 6t9IZw3tM+nLns9wfoqjiofWrcpiYr1GOae/1o4r+fM1rT37hQIwAe94XQ3Zc0QVK5AF lo30o2sp+cXyeRL7ONEa2zTPXesaUTtCVI9JnRHbc3apXziMN29RpkUoCh6SgvxerYQX P9yt4ylIPCW3JkNHVPTmFZOPJutEVs+zNtKplrc0+qx9Ri4RGsuxdCJywWpDjlF9+SPM cg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2hx29w4rr0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 May 2018 13:15:59 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w4GDFuQu022494 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 May 2018 13:15:57 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w4GDFr7E026808; Wed, 16 May 2018 13:15:54 GMT Received: from [192.168.1.93] (/99.156.91.244) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 16 May 2018 06:15:53 -0700 Subject: Re: [Jfs-discussion] [PATCH 25/42] jfs: simplify procfs code To: Christoph Hellwig , Andrew Morton , Alexander Viro Cc: linux-rtc@vger.kernel.org, Alessandro Zummo , Alexandre Belloni , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org, Greg Kroah-Hartman , jfs-discussion@lists.sourceforge.net, linux-afs@lists.infradead.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, Jiri Slaby , linux-ext4@vger.kernel.org, Alexey Dobriyan , megaraidlinux.pdl@broadcom.com, drbd-dev@lists.linbit.com References: <20180516094346.20506-1-hch@lst.de> <20180516094346.20506-26-hch@lst.de> From: Dave Kleikamp Openpgp: preference=signencrypt Message-ID: <6e2593f4-6456-7a43-4af5-f3fdd9e78ab7@oracle.com> Date: Wed, 16 May 2018 08:15:52 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180516094346.20506-26-hch@lst.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8894 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805160136 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/16/2018 04:43 AM, Christoph Hellwig wrote: > Use remove_proc_subtree to remove the whole subtree on cleanup, and > unwind the registration loop into individual calls. Switch to use > proc_create_seq where applicable. > > Signed-off-by: Christoph Hellwig Acked-by: Dave Kleikamp > --- > fs/jfs/jfs_debug.c | 43 ++++++++++++++----------------------------- > fs/jfs/jfs_debug.h | 10 +++++----- > fs/jfs/jfs_logmgr.c | 14 +------------- > fs/jfs/jfs_metapage.c | 14 +------------- > fs/jfs/jfs_txnmgr.c | 28 ++-------------------------- > fs/jfs/jfs_xtree.c | 14 +------------- > 6 files changed, 24 insertions(+), 99 deletions(-) > > diff --git a/fs/jfs/jfs_debug.c b/fs/jfs/jfs_debug.c > index a70907606025..35a5b2a81ae0 100644 > --- a/fs/jfs/jfs_debug.c > +++ b/fs/jfs/jfs_debug.c > @@ -29,7 +29,6 @@ > > #ifdef PROC_FS_JFS /* see jfs_debug.h */ > > -static struct proc_dir_entry *base; > #ifdef CONFIG_JFS_DEBUG > static int jfs_loglevel_proc_show(struct seq_file *m, void *v) > { > @@ -66,43 +65,29 @@ static const struct file_operations jfs_loglevel_proc_fops = { > }; > #endif > > -static struct { > - const char *name; > - const struct file_operations *proc_fops; > -} Entries[] = { > -#ifdef CONFIG_JFS_STATISTICS > - { "lmstats", &jfs_lmstats_proc_fops, }, > - { "txstats", &jfs_txstats_proc_fops, }, > - { "xtstat", &jfs_xtstat_proc_fops, }, > - { "mpstat", &jfs_mpstat_proc_fops, }, > -#endif > -#ifdef CONFIG_JFS_DEBUG > - { "TxAnchor", &jfs_txanchor_proc_fops, }, > - { "loglevel", &jfs_loglevel_proc_fops } > -#endif > -}; > -#define NPROCENT ARRAY_SIZE(Entries) > - > void jfs_proc_init(void) > { > - int i; > + struct proc_dir_entry *base; > > - if (!(base = proc_mkdir("fs/jfs", NULL))) > + base = proc_mkdir("fs/jfs", NULL); > + if (!base) > return; > > - for (i = 0; i < NPROCENT; i++) > - proc_create(Entries[i].name, 0, base, Entries[i].proc_fops); > +#ifdef CONFIG_JFS_STATISTICS > + proc_create_single("lmstats", 0, base, jfs_lmstats_proc_show); > + proc_create_single("txstats", 0, base, jfs_txstats_proc_show); > + proc_create_single("xtstat", 0, base, jfs_xtstat_proc_show); > + proc_create_single("mpstat", 0, base, jfs_mpstat_proc_show); > +#endif > +#ifdef CONFIG_JFS_DEBUG > + proc_create_single("TxAnchor", 0, base, jfs_txanchor_proc_show); > + proc_create("loglevel", 0, base, &jfs_loglevel_proc_fops); > +#endif > } > > void jfs_proc_clean(void) > { > - int i; > - > - if (base) { > - for (i = 0; i < NPROCENT; i++) > - remove_proc_entry(Entries[i].name, base); > - remove_proc_entry("fs/jfs", NULL); > - } > + remove_proc_subtree("fs/jfs", NULL); > } > > #endif /* PROC_FS_JFS */ > diff --git a/fs/jfs/jfs_debug.h b/fs/jfs/jfs_debug.h > index eafd1300a00b..0d9e35da8462 100644 > --- a/fs/jfs/jfs_debug.h > +++ b/fs/jfs/jfs_debug.h > @@ -62,7 +62,7 @@ extern void jfs_proc_clean(void); > > extern int jfsloglevel; > > -extern const struct file_operations jfs_txanchor_proc_fops; > +int jfs_txanchor_proc_show(struct seq_file *m, void *v); > > /* information message: e.g., configuration, major event */ > #define jfs_info(fmt, arg...) do { \ > @@ -105,10 +105,10 @@ extern const struct file_operations jfs_txanchor_proc_fops; > * ---------- > */ > #ifdef CONFIG_JFS_STATISTICS > -extern const struct file_operations jfs_lmstats_proc_fops; > -extern const struct file_operations jfs_txstats_proc_fops; > -extern const struct file_operations jfs_mpstat_proc_fops; > -extern const struct file_operations jfs_xtstat_proc_fops; > +int jfs_lmstats_proc_show(struct seq_file *m, void *v); > +int jfs_txstats_proc_show(struct seq_file *m, void *v); > +int jfs_mpstat_proc_show(struct seq_file *m, void *v); > +int jfs_xtstat_proc_show(struct seq_file *m, void *v); > > #define INCREMENT(x) ((x)++) > #define DECREMENT(x) ((x)--) > diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c > index 0e5d412c0b01..6b68df395892 100644 > --- a/fs/jfs/jfs_logmgr.c > +++ b/fs/jfs/jfs_logmgr.c > @@ -2493,7 +2493,7 @@ int lmLogFormat(struct jfs_log *log, s64 logAddress, int logSize) > } > > #ifdef CONFIG_JFS_STATISTICS > -static int jfs_lmstats_proc_show(struct seq_file *m, void *v) > +int jfs_lmstats_proc_show(struct seq_file *m, void *v) > { > seq_printf(m, > "JFS Logmgr stats\n" > @@ -2510,16 +2510,4 @@ static int jfs_lmstats_proc_show(struct seq_file *m, void *v) > lmStat.partial_page); > return 0; > } > - > -static int jfs_lmstats_proc_open(struct inode *inode, struct file *file) > -{ > - return single_open(file, jfs_lmstats_proc_show, NULL); > -} > - > -const struct file_operations jfs_lmstats_proc_fops = { > - .open = jfs_lmstats_proc_open, > - .read = seq_read, > - .llseek = seq_lseek, > - .release = single_release, > -}; > #endif /* CONFIG_JFS_STATISTICS */ > diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c > index 1a3b0cc22ad3..fa2c6824c7f2 100644 > --- a/fs/jfs/jfs_metapage.c > +++ b/fs/jfs/jfs_metapage.c > @@ -815,7 +815,7 @@ void __invalidate_metapages(struct inode *ip, s64 addr, int len) > } > > #ifdef CONFIG_JFS_STATISTICS > -static int jfs_mpstat_proc_show(struct seq_file *m, void *v) > +int jfs_mpstat_proc_show(struct seq_file *m, void *v) > { > seq_printf(m, > "JFS Metapage statistics\n" > @@ -828,16 +828,4 @@ static int jfs_mpstat_proc_show(struct seq_file *m, void *v) > mpStat.lockwait); > return 0; > } > - > -static int jfs_mpstat_proc_open(struct inode *inode, struct file *file) > -{ > - return single_open(file, jfs_mpstat_proc_show, NULL); > -} > - > -const struct file_operations jfs_mpstat_proc_fops = { > - .open = jfs_mpstat_proc_open, > - .read = seq_read, > - .llseek = seq_lseek, > - .release = single_release, > -}; > #endif > diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c > index 4d973524c887..a5663cb621d8 100644 > --- a/fs/jfs/jfs_txnmgr.c > +++ b/fs/jfs/jfs_txnmgr.c > @@ -2998,7 +2998,7 @@ int jfs_sync(void *arg) > } > > #if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_DEBUG) > -static int jfs_txanchor_proc_show(struct seq_file *m, void *v) > +int jfs_txanchor_proc_show(struct seq_file *m, void *v) > { > char *freewait; > char *freelockwait; > @@ -3032,22 +3032,10 @@ static int jfs_txanchor_proc_show(struct seq_file *m, void *v) > list_empty(&TxAnchor.unlock_queue) ? "" : "not "); > return 0; > } > - > -static int jfs_txanchor_proc_open(struct inode *inode, struct file *file) > -{ > - return single_open(file, jfs_txanchor_proc_show, NULL); > -} > - > -const struct file_operations jfs_txanchor_proc_fops = { > - .open = jfs_txanchor_proc_open, > - .read = seq_read, > - .llseek = seq_lseek, > - .release = single_release, > -}; > #endif > > #if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_STATISTICS) > -static int jfs_txstats_proc_show(struct seq_file *m, void *v) > +int jfs_txstats_proc_show(struct seq_file *m, void *v) > { > seq_printf(m, > "JFS TxStats\n" > @@ -3072,16 +3060,4 @@ static int jfs_txstats_proc_show(struct seq_file *m, void *v) > TxStat.txLockAlloc_freelock); > return 0; > } > - > -static int jfs_txstats_proc_open(struct inode *inode, struct file *file) > -{ > - return single_open(file, jfs_txstats_proc_show, NULL); > -} > - > -const struct file_operations jfs_txstats_proc_fops = { > - .open = jfs_txstats_proc_open, > - .read = seq_read, > - .llseek = seq_lseek, > - .release = single_release, > -}; > #endif > diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c > index 5cde6d2fcfca..2c200b5256a6 100644 > --- a/fs/jfs/jfs_xtree.c > +++ b/fs/jfs/jfs_xtree.c > @@ -3874,7 +3874,7 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size) > } > > #ifdef CONFIG_JFS_STATISTICS > -static int jfs_xtstat_proc_show(struct seq_file *m, void *v) > +int jfs_xtstat_proc_show(struct seq_file *m, void *v) > { > seq_printf(m, > "JFS Xtree statistics\n" > @@ -3887,16 +3887,4 @@ static int jfs_xtstat_proc_show(struct seq_file *m, void *v) > xtStat.split); > return 0; > } > - > -static int jfs_xtstat_proc_open(struct inode *inode, struct file *file) > -{ > - return single_open(file, jfs_xtstat_proc_show, NULL); > -} > - > -const struct file_operations jfs_xtstat_proc_fops = { > - .open = jfs_xtstat_proc_open, > - .read = seq_read, > - .llseek = seq_lseek, > - .release = single_release, > -}; > #endif >