linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Kleikamp <dave.kleikamp@oracle.com>
To: Christoph Hellwig <hch@lst.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-rtc@vger.kernel.org,
	Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	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 <jslaby@suse.com>,
	linux-ext4@vger.kernel.org, Alexey Dobriyan <adobriyan@gmail.com>,
	megaraidlinux.pdl@broadcom.com, drbd-dev@lists.linbit.com
Subject: Re: [Jfs-discussion] [PATCH 25/42] jfs: simplify procfs code
Date: Wed, 16 May 2018 08:15:52 -0500	[thread overview]
Message-ID: <6e2593f4-6456-7a43-4af5-f3fdd9e78ab7@oracle.com> (raw)
In-Reply-To: <20180516094346.20506-26-hch@lst.de>

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 <hch@lst.de>

Acked-by:  Dave Kleikamp <dave.kleikamp@oracle.com>

> ---
>  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
> 

  reply	other threads:[~2018-05-16 13:17 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-16  9:43 simplify procfs code for seq_file instances V3 Christoph Hellwig
2018-05-16  9:43 ` [PATCH 01/42] net/can: single_open_net needs to be paired with single_release_net Christoph Hellwig
2018-05-16  9:43 ` [PATCH 02/42] proc: introduce a proc_pid_ns helper Christoph Hellwig
2018-05-16  9:43 ` [PATCH 03/42] proc: don't detour through seq->private to get the inode Christoph Hellwig
2018-05-16  9:43 ` [PATCH 04/42] proc: simplify proc_register calling conventions Christoph Hellwig
2018-05-16  9:43 ` [PATCH 05/42] proc: add a proc_create_reg helper Christoph Hellwig
2018-05-16  9:43 ` [PATCH 06/42] proc: introduce proc_create_seq{,_data} Christoph Hellwig
2018-05-16  9:43 ` [PATCH 07/42] proc: introduce proc_create_seq_private Christoph Hellwig
2018-05-16  9:43 ` [PATCH 08/42] proc: introduce proc_create_single{,_data} Christoph Hellwig
2018-05-16  9:43 ` [PATCH 09/42] ipv{4,6}/udp{,lite}: simplify proc registration Christoph Hellwig
2018-05-16  9:43 ` [PATCH 10/42] ipv{4,6}/tcp: simplify procfs registration Christoph Hellwig
2018-05-16  9:43 ` [PATCH 11/42] ipv{4,6}/ping: simplify proc file creation Christoph Hellwig
2018-05-16  9:43 ` [PATCH 12/42] ipv{4,6}/raw: simplify ѕeq_file code Christoph Hellwig
2018-05-16  9:43 ` [PATCH 13/42] ipv6/flowlabel: simplify pid namespace lookup Christoph Hellwig
2018-05-16  9:43 ` [PATCH 14/42] net/kcm: simplify proc registration Christoph Hellwig
2018-05-16  9:43 ` [PATCH 15/42] netfilter/x_tables: simplify ѕeq_file code Christoph Hellwig
2018-05-16  9:43 ` [PATCH 16/42] net: move seq_file_single_net to <linux/seq_file_net.h> Christoph Hellwig
2018-05-16  9:43 ` [PATCH 17/42] proc: introduce proc_create_net{,_data} Christoph Hellwig
2018-05-16  9:43 ` [PATCH 18/42] proc: introduce proc_create_net_single Christoph Hellwig
2018-05-16  9:43 ` [PATCH 19/42] acpi/battery: simplify procfs code Christoph Hellwig
2018-05-16  9:43 ` [PATCH 20/42] sgi-gru: " Christoph Hellwig
2018-05-16  9:43 ` [PATCH 21/42] megaraid: " Christoph Hellwig
2018-05-16  9:43 ` [PATCH 22/42] sg: " Christoph Hellwig
2018-05-16  9:43 ` [PATCH 23/42] afs: " Christoph Hellwig
2018-05-16  9:43 ` [PATCH 24/42] ext4: " Christoph Hellwig
2018-05-16  9:43 ` [PATCH 25/42] jfs: " Christoph Hellwig
2018-05-16 13:15   ` Dave Kleikamp [this message]
2018-05-16  9:43 ` [PATCH 26/42] staging/rtl8192u: " Christoph Hellwig
2018-05-16  9:43 ` [PATCH 27/42] resource: switch to proc_create_seq_data Christoph Hellwig
2018-05-16  9:43 ` [PATCH 28/42] drbd: switch to proc_create_single Christoph Hellwig
2018-05-18 12:55   ` [Drbd-dev] " Lars Ellenberg
2018-05-16  9:43 ` [PATCH 29/42] rtc/proc: switch to proc_create_single_data Christoph Hellwig
2018-05-16  9:43 ` [PATCH 30/42] bonding: switch to proc_create_seq_data Christoph Hellwig
2018-05-16  9:43 ` [PATCH 31/42] hostap: switch to proc_create_{seq,single}_data Christoph Hellwig
2018-05-16  9:43 ` [PATCH 32/42] neigh: switch to proc_create_seq_data Christoph Hellwig
2018-05-16  9:43 ` [PATCH 33/42] netfilter/xt_hashlimit: switch to proc_create_{seq,single}_data Christoph Hellwig
2018-05-16  9:43 ` [PATCH 34/42] netfilter/x_tables: switch to proc_create_seq_private Christoph Hellwig
2018-05-16  9:43 ` [PATCH 35/42] bluetooth: switch to proc_create_seq_data Christoph Hellwig
2018-05-16  9:43 ` [PATCH 36/42] atm: simplify procfs code Christoph Hellwig
2018-05-16  9:43 ` [PATCH 37/42] atm: switch to proc_create_seq_private Christoph Hellwig
2018-05-16  9:43 ` [PATCH 38/42] isdn: replace ->proc_fops with ->proc_show Christoph Hellwig
2018-05-18  8:43   ` Paul Bolle
2018-05-18  8:58     ` Christoph Hellwig
2018-05-16  9:43 ` [PATCH 39/42] ide: remove ide_driver_proc_write Christoph Hellwig
2018-05-16  9:43 ` [PATCH 40/42] ide: replace ->proc_fops with ->proc_show Christoph Hellwig
2018-05-16  9:43 ` [PATCH 41/42] tty: " Christoph Hellwig
2018-05-16  9:58   ` Greg Kroah-Hartman
2018-05-16  9:43 ` [PATCH 42/42] proc: update SIZEOF_PDE_INLINE_NAME for the new pde fields Christoph Hellwig
2018-05-16 13:28 ` simplify procfs code for seq_file instances V3 Al Viro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6e2593f4-6456-7a43-4af5-f3fdd9e78ab7@oracle.com \
    --to=dave.kleikamp@oracle.com \
    --cc=a.zummo@towertech.it \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=drbd-dev@lists.linbit.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=jslaby@suse.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=megaraidlinux.pdl@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).