From: NeilBrown <neilb@suse.com>
To: Kinglong Mee <kinglongmee@gmail.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>,
Al Viro <viro@zeniv.linux.org.uk>,
"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
linux-fsdevel@vger.kernel.org,
Trond Myklebust <trond.myklebust@primarydata.com>
Subject: Re: [PATCH 6/9 v8] sunrpc/nfsd: Remove redundant code by exports seq_operations functions
Date: Wed, 29 Jul 2015 12:15:22 +1000 [thread overview]
Message-ID: <20150729121522.2ac816de@noble> (raw)
In-Reply-To: <55B5A0F6.1040701@gmail.com>
On Mon, 27 Jul 2015 11:09:42 +0800 Kinglong Mee <kinglongmee@gmail.com>
wrote:
> Nfsd has implement a site of seq_operations functions as sunrpc's cache.
> Just exports sunrpc's codes, and remove nfsd's redundant codes.
>
> v8, same as v6
>
> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Reviewed-by: NeilBrown <neilb@suse.com>
This depends on the previous cleanup - together they are a very nice
improvement.
NeilBrown
> ---
> fs/nfsd/export.c | 73 ++------------------------------------------
> include/linux/sunrpc/cache.h | 5 +++
> net/sunrpc/cache.c | 15 +++++----
> 3 files changed, 17 insertions(+), 76 deletions(-)
>
> diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
> index f79521a..b4d84b5 100644
> --- a/fs/nfsd/export.c
> +++ b/fs/nfsd/export.c
> @@ -1075,73 +1075,6 @@ exp_pseudoroot(struct svc_rqst *rqstp, struct svc_fh *fhp)
> return rv;
> }
>
> -/* Iterator */
> -
> -static void *e_start(struct seq_file *m, loff_t *pos)
> - __acquires(((struct cache_detail *)m->private)->hash_lock)
> -{
> - loff_t n = *pos;
> - unsigned hash, export;
> - struct cache_head *ch;
> - struct cache_detail *cd = m->private;
> - struct cache_head **export_table = cd->hash_table;
> -
> - read_lock(&cd->hash_lock);
> - if (!n--)
> - return SEQ_START_TOKEN;
> - hash = n >> 32;
> - export = n & ((1LL<<32) - 1);
> -
> -
> - for (ch=export_table[hash]; ch; ch=ch->next)
> - if (!export--)
> - return ch;
> - n &= ~((1LL<<32) - 1);
> - do {
> - hash++;
> - n += 1LL<<32;
> - } while(hash < EXPORT_HASHMAX && export_table[hash]==NULL);
> - if (hash >= EXPORT_HASHMAX)
> - return NULL;
> - *pos = n+1;
> - return export_table[hash];
> -}
> -
> -static void *e_next(struct seq_file *m, void *p, loff_t *pos)
> -{
> - struct cache_head *ch = p;
> - int hash = (*pos >> 32);
> - struct cache_detail *cd = m->private;
> - struct cache_head **export_table = cd->hash_table;
> -
> - if (p == SEQ_START_TOKEN)
> - hash = 0;
> - else if (ch->next == NULL) {
> - hash++;
> - *pos += 1LL<<32;
> - } else {
> - ++*pos;
> - return ch->next;
> - }
> - *pos &= ~((1LL<<32) - 1);
> - while (hash < EXPORT_HASHMAX && export_table[hash] == NULL) {
> - hash++;
> - *pos += 1LL<<32;
> - }
> - if (hash >= EXPORT_HASHMAX)
> - return NULL;
> - ++*pos;
> - return export_table[hash];
> -}
> -
> -static void e_stop(struct seq_file *m, void *p)
> - __releases(((struct cache_detail *)m->private)->hash_lock)
> -{
> - struct cache_detail *cd = m->private;
> -
> - read_unlock(&cd->hash_lock);
> -}
> -
> static struct flags {
> int flag;
> char *name[2];
> @@ -1270,9 +1203,9 @@ static int e_show(struct seq_file *m, void *p)
> }
>
> const struct seq_operations nfs_exports_op = {
> - .start = e_start,
> - .next = e_next,
> - .stop = e_stop,
> + .start = cache_seq_start,
> + .next = cache_seq_next,
> + .stop = cache_seq_stop,
> .show = e_show,
> };
>
> diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
> index 437ddb6..04ee5a2 100644
> --- a/include/linux/sunrpc/cache.h
> +++ b/include/linux/sunrpc/cache.h
> @@ -224,6 +224,11 @@ extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *,
> umode_t, struct cache_detail *);
> extern void sunrpc_cache_unregister_pipefs(struct cache_detail *);
>
> +/* Must store cache_detail in seq_file->private if using next three functions */
> +extern void *cache_seq_start(struct seq_file *file, loff_t *pos);
> +extern void *cache_seq_next(struct seq_file *file, void *p, loff_t *pos);
> +extern void cache_seq_stop(struct seq_file *file, void *p);
> +
> extern void qword_add(char **bpp, int *lp, char *str);
> extern void qword_addhex(char **bpp, int *lp, char *buf, int blen);
> extern int qword_get(char **bpp, char *dest, int bufsize);
> diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
> index edec603..673c2fa 100644
> --- a/net/sunrpc/cache.c
> +++ b/net/sunrpc/cache.c
> @@ -1270,7 +1270,7 @@ EXPORT_SYMBOL_GPL(qword_get);
> * get a header, then pass each real item in the cache
> */
>
> -static void *c_start(struct seq_file *m, loff_t *pos)
> +void *cache_seq_start(struct seq_file *m, loff_t *pos)
> __acquires(cd->hash_lock)
> {
> loff_t n = *pos;
> @@ -1298,8 +1298,9 @@ static void *c_start(struct seq_file *m, loff_t *pos)
> *pos = n+1;
> return cd->hash_table[hash];
> }
> +EXPORT_SYMBOL_GPL(cache_seq_start);
>
> -static void *c_next(struct seq_file *m, void *p, loff_t *pos)
> +void *cache_seq_next(struct seq_file *m, void *p, loff_t *pos)
> {
> struct cache_head *ch = p;
> int hash = (*pos >> 32);
> @@ -1325,13 +1326,15 @@ static void *c_next(struct seq_file *m, void *p, loff_t *pos)
> ++*pos;
> return cd->hash_table[hash];
> }
> +EXPORT_SYMBOL_GPL(cache_seq_next);
>
> -static void c_stop(struct seq_file *m, void *p)
> +void cache_seq_stop(struct seq_file *m, void *p)
> __releases(cd->hash_lock)
> {
> struct cache_detail *cd = m->private;
> read_unlock(&cd->hash_lock);
> }
> +EXPORT_SYMBOL_GPL(cache_seq_stop);
>
> static int c_show(struct seq_file *m, void *p)
> {
> @@ -1359,9 +1362,9 @@ static int c_show(struct seq_file *m, void *p)
> }
>
> static const struct seq_operations cache_content_op = {
> - .start = c_start,
> - .next = c_next,
> - .stop = c_stop,
> + .start = cache_seq_start,
> + .next = cache_seq_next,
> + .stop = cache_seq_stop,
> .show = c_show,
> };
>
next prev parent reply other threads:[~2015-07-29 2:15 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-27 3:05 [PATCH 0/9 v8] NFSD: Pin to vfsmount for nfsd exports cache Kinglong Mee
2015-07-27 3:08 ` [PATCH 4/9 v8] fs: New helper legitimize_mntget() for getting a legitimize mnt Kinglong Mee
[not found] ` <55B5A0B0.7060604-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-07-29 2:06 ` NeilBrown
2015-07-30 13:17 ` Kinglong Mee
2015-07-27 3:09 ` [PATCH 5/9 v8] sunrpc: Store cache_detail in seq_file's private directly Kinglong Mee
2015-07-29 2:11 ` NeilBrown
[not found] ` <55B5A012.1030006-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-07-27 3:06 ` [PATCH 1/9 v8] fs_pin: Initialize value for fs_pin explicitly Kinglong Mee
2015-07-29 0:25 ` NeilBrown
2015-07-29 19:41 ` J. Bruce Fields
[not found] ` <20150729194155.GC21949-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2015-07-29 21:48 ` NeilBrown
2015-07-30 0:36 ` J. Bruce Fields
2015-07-30 12:28 ` Kinglong Mee
2015-07-27 3:07 ` [PATCH 2/9 v8] fs_pin: Export functions for specific filesystem Kinglong Mee
2015-07-29 0:30 ` NeilBrown
2015-07-30 12:31 ` Kinglong Mee
2015-07-27 3:07 ` [PATCH 3/9 v8] path: New helpers path_get_pin/path_put_unpin for path pin Kinglong Mee
2015-07-27 3:09 ` [PATCH 6/9 v8] sunrpc/nfsd: Remove redundant code by exports seq_operations functions Kinglong Mee
2015-07-29 2:15 ` NeilBrown [this message]
2015-07-27 3:12 ` [PATCH 9/9 v8] nfsd: Allows user un-mounting filesystem where nfsd exports base on Kinglong Mee
[not found] ` <55B5A186.7040004-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-07-29 3:56 ` NeilBrown
2015-07-30 13:30 ` Kinglong Mee
2015-07-29 3:59 ` [PATCH] fs-pin: allow pin_remove() to be called other than from ->kill() NeilBrown
2015-08-10 11:37 ` Kinglong Mee
2015-08-18 6:07 ` Kinglong Mee
2015-08-18 6:21 ` NeilBrown
2015-08-18 6:37 ` Kinglong Mee
2015-07-27 3:10 ` [PATCH 7/9 v8] sunrpc: Switch to using hash list instead single list Kinglong Mee
2015-07-29 2:19 ` NeilBrown
2015-07-29 19:51 ` J. Bruce Fields
[not found] ` <20150729195151.GD21949-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2015-07-30 13:01 ` Kinglong Mee
2015-07-27 3:10 ` [PATCH 8/9 v8] sunrpc: New helper cache_delete_entry for deleting cache_head directly Kinglong Mee
[not found] ` <55B5A135.9050800-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-07-29 2:29 ` NeilBrown
2015-07-30 13:14 ` Kinglong Mee
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=20150729121522.2ac816de@noble \
--to=neilb@suse.com \
--cc=bfields@fieldses.org \
--cc=kinglongmee@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@primarydata.com \
--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