Some cleanups and updates for sunrpc
Subsystems (3)
cover Some cleanups and updates for sunrpc
The first one is an bugfix of checking register_shrinker's result, the following sixes are codes cleanup and updates.
Kinglong Mee (7):
sunrpc: error out if register_shrinker fail sunrpc/nfs: cleanup procfs/pipefs entry in cache_detail
sunrpc: rename NFS_NGROUPS to UNX_NGROUPS for auth unix
sunrpc: remove dead codes of cr_magic in rpc_cred
sunrpc: update the comments of sunrpc proc path
sunrpc: record rpc client pointer in seq->private directly
sunrpc: use simple_read_from_buffer for reading cache flush
fs/nfs/cache_lib.c | 3 +- include/linux/sunrpc/auth.h | 6 +--- include/linux/sunrpc/cache.h | 15 ++-------- net/sunrpc/auth.c | 9 +++--- net/sunrpc/auth_null.c | 3 -- net/sunrpc/auth_unix.c | 18 ++++++------ net/sunrpc/cache.c | 68 ++++++++++++++------------------------------ net/sunrpc/debugfs.c | 35 +++++++---------------- net/sunrpc/svcauth_unix.c | 4 +-- 9 files changed, 52 insertions(+), 109 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/7 sunrpc: error out if register_shrinker fail
register_shrinker may return error when register fail, error out.
--- net/sunrpc/auth.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/sunrpc/auth.c +5 -1
@@ -873,8 +873,12 @@ int __init rpcauth_init_module(void) err =rpc_init_generic_auth ();if (err <0 ) goto out2; -register_shrinker (&rpc_cred_shrinker); + err =register_shrinker (&rpc_cred_shrinker); +if (err <0 ) + goto out3;return 0 ; +out3: +rpc_destroy_generic_auth (); out2:rpc_destroy_authunix (); out1:
Signature · 1 line
2.9.3
PATCH 2/7 sunrpc/nfs: cleanup procfs/pipefs entry in cache_detail
In reply to Kinglong MeeRecord flush/channel/content entries is useless, remove them.
--- fs/nfs/cache_lib.c | 3 +-- include/linux/sunrpc/cache.h | 15 +++----------- net/sunrpc/cache.c | 49 +++++++++++++++----------------------------- 3 files changed, 21 insertions(+), 46 deletions(-)
fs/nfs/cache_lib.c +1 -2
@@ -141,8 +141,7 @@ int nfs_cache_register_net(struct net *net, struct cache_detail *cd)void nfs_cache_unregister_sb (struct super_block *sb,struct cache_detail *cd) { -if (cd->u.pipefs.dir) -sunrpc_cache_unregister_pipefs (cd); +sunrpc_cache_unregister_pipefs (cd); }void nfs_cache_unregister_net (struct net *net,struct cache_detail *cd)
include/linux/sunrpc/cache.h +3 -12
@@ -63,15 +63,6 @@ struct cache_head {#define CACHE_NEW_EXPIRY 120/* keep new things pending confirmation for 120 seconds */ -struct cache_detail_procfs { -struct proc_dir_entry *proc_ent; -struct proc_dir_entry *flush_ent, *channel_ent, *content_ent; -}; - -struct cache_detail_pipefs { -struct dentry *dir; -}; -struct cache_detail {struct module * owner;int hash_size;
@@ -123,9 +114,9 @@ struct cache_detail {time_t last_warn;/* when we last warned about no readers */ union { -struct cache_detail_procfs procfs; -struct cache_detail_pipefs pipefs; - } u; +struct proc_dir_entry *procfs; +struct dentry *pipefs; + };struct net *net; };
net/sunrpc/cache.c +17 -32
98 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 3/7 sunrpc: rename NFS_NGROUPS to UNX_NGROUPS for auth unix
In reply to Kinglong MeeNFS_NGROUPS has been move to sunrpc, rename to UNX_NGROUPS.
--- include/linux/sunrpc/auth.h | 1 + net/sunrpc/auth_unix.c | 18 ++++++++---------- net/sunrpc/svcauth_unix.c | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-)
include/linux/sunrpc/auth.h +1 -0
@@ -32,6 +32,7 @@*/ #define UNX_MAXNODENAME __NEW_UTS_LEN#define UNX_CALLSLACK (21 + XDR_QUADLEN(UNX_MAXNODENAME)) +#define UNX_NGROUPS 16struct rpcsec_gss_info ;
net/sunrpc/auth_unix.c +8 -10
@@ -14,12 +14,10 @@#include <linux/sunrpc/auth.h> #include <linux/user_namespace.h> -#define NFS_NGROUPS 16 -struct unx_cred {struct rpc_cred uc_base;kgid_t uc_gid; -kgid_t uc_gids[NFS_NGROUPS ]; +kgid_t uc_gids[UNX_NGROUPS ]; };#define uc_uid uc_base.cr_uid
@@ -82,13 +80,13 @@ unx_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags, gfp_tif (acred->group_info !=NULL ) groups = acred->group_info->ngroups; -if (groups >NFS_NGROUPS ) - groups =NFS_NGROUPS ; +if (groups >UNX_NGROUPS ) + groups =UNX_NGROUPS ; cred->uc_gid = acred->gid;for (i =0 ; i < groups; i++) cred->uc_gids[i] = acred->group_info->gid[i]; -if (i <NFS_NGROUPS ) +if (i <UNX_NGROUPS ) cred->uc_gids[i] =INVALID_GID ;return &cred->uc_base;
@@ -132,12 +130,12 @@ unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags)if (acred->group_info !=NULL ) groups = acred->group_info->ngroups; -if (groups >NFS_NGROUPS ) - groups =NFS_NGROUPS ; +if (groups >UNX_NGROUPS ) + groups =UNX_NGROUPS ;for (i =0 ; i < groups ; i++)if (!gid_eq (cred->uc_gids[i], acred->group_info->gid[i]))return 0 ; -if (groups <NFS_NGROUPS &&gid_valid (cred->uc_gids[groups])) +if (groups <UNX_NGROUPS &&gid_valid (cred->uc_gids[groups]))return 0 ;return 1 ; }
@@ -166,7 +164,7 @@ unx_marshal(struct rpc_task *task, __be32 *p) *p++ =htonl ((u32 )from_kuid (&init_user_ns, cred->uc_uid)); *p++ =htonl ((u32 )from_kgid (&init_user_ns, cred->uc_gid)); hold = p++; -for (i =0 ; i <16 &&gid_valid (cred->uc_gids[i]); i++) +for (i =0 ; i <UNX_NGROUPS &&gid_valid (cred->uc_gids[i]); i++) *p++ =htonl ((u32 )from_kgid (&init_user_ns, cred->uc_gids[i])); *hold =htonl (p - hold -1 );/* gid array length */ *base =htonl ((p - base -1 ) <<2 );/* cred length */
net/sunrpc/svcauth_unix.c +2 -2
@@ -403,7 +403,7 @@ svcauth_unix_info_release(struct svc_xprt *xpt)/**************************************************************************** * auth.unix.gid cache * simple cache to map a UID to a list of GIDs -* because AUTH_UNIX aka AUTH_SYS has a max of 16 +* because AUTH_UNIX aka AUTH_SYS has a max of UNX_NGROUPS */ #define GID_HASHBITS 8#define GID_HASHMAX (1<<GID_HASHBITS)
@@ -810,7 +810,7 @@ svcauth_unix_accept(struct svc_rqst *rqstp, __be32 *authp) cred->cr_uid =make_kuid (&init_user_ns,svc_getnl (argv));/* uid */ cred->cr_gid =make_kgid (&init_user_ns,svc_getnl (argv));/* gid */ slen =svc_getnl (argv);/* gids length */ -if (slen >16 || (len -= (slen +2 )*4 ) <0 ) +if (slen >UNX_NGROUPS || (len -= (slen +2 )*4 ) <0 ) goto badcred; cred->cr_group_info =groups_alloc (slen);if (cred->cr_group_info ==NULL )
Signature · 1 line
2.9.3
PATCH 4/7 sunrpc: remove dead codes of cr_magic in rpc_cred
In reply to Kinglong MeeDon't found any place using the cr_magic.
--- include/linux/sunrpc/auth.h | 5 ----- net/sunrpc/auth.c | 3 --- net/sunrpc/auth_null.c | 3 --- 3 files changed, 11 deletions(-)
include/linux/sunrpc/auth.h +0 -5
@@ -64,9 +64,6 @@ struct rpc_cred {struct rcu_head cr_rcu;struct rpc_auth * cr_auth;const struct rpc_credops *cr_ops; -#if IS_ENABLED (CONFIG_SUNRPC_DEBUG ) -unsigned long cr_magic;/* 0x0f4aa4f0 */ -#endif unsigned long cr_expire;/* when to gc */ unsigned long cr_flags;/* various flags */ atomic_t cr_count;/* ref count */
@@ -80,8 +77,6 @@ struct rpc_cred {#define RPCAUTH_CRED_HASHED 2#define RPCAUTH_CRED_NEGATIVE 3 -#define RPCAUTH_CRED_MAGIC 0x0f4aa4f0 -/* rpc_auth au_flags */ #define RPCAUTH_AUTH_NO_CRKEY_TIMEOUT 0x0001/* underlying cred has no key timeout */
net/sunrpc/auth.c +0 -3
@@ -646,9 +646,6 @@ rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred, cred->cr_auth = auth; cred->cr_ops = ops; cred->cr_expire = jiffies; -#if IS_ENABLED (CONFIG_SUNRPC_DEBUG ) - cred->cr_magic =RPCAUTH_CRED_MAGIC ; -#endif cred->cr_uid = acred->uid; }EXPORT_SYMBOL_GPL (rpcauth_init_cred);
net/sunrpc/auth_null.c +0 -3
@@ -139,7 +139,4 @@ struct rpc_cred null_cred = { .cr_ops = &null_credops, .cr_count = ATOMIC_INIT(1), .cr_flags = 1UL << RPCAUTH_CRED_UPTODATE, -#if IS_ENABLED (CONFIG_SUNRPC_DEBUG ) - .cr_magic = RPCAUTH_CRED_MAGIC, -#endif };
Signature · 1 line
2.9.3
PATCH 5/7 sunrpc: update the comments of sunrpc proc path
In reply to Kinglong Mee--- net/sunrpc/cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sunrpc/cache.c +2 -2
@@ -717,7 +717,7 @@ void cache_clean_deferred(void *owner)/* * communicate with user-space * -* We have a magic /proc file - /proc/sunrpc/<cachename>/channel. +* We have a magic /proc file - /proc/net/rpc/<cachename>/channel. * On read, you get a full request, or block. * On write, an update request is processed. * Poll works if anything to read, and always allows write.
@@ -1272,7 +1272,7 @@ EXPORT_SYMBOL_GPL(qword_get);/* -* support /proc/sunrpc/cache/$CACHENAME/content +* support /proc/net/rpc/$CACHENAME/content * as a seqfile. * We call ->cache_show passing NULL for the item to * get a header, then pass each real item in the cache
Signature · 1 line
2.9.3
PATCH 6/7 sunrpc: record rpc client pointer in seq->private directly
In reply to Kinglong Meepos in rpc_clnt_iter is useless, drop it and record clnt in seq_private.
--- net/sunrpc/debugfs.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-)
net/sunrpc/debugfs.c +10 -25
@@ -16,11 +16,6 @@ static struct dentry *rpc_xprt_dir;unsigned int rpc_inject_disconnect; -struct rpc_clnt_iter { -struct rpc_clnt *clnt; -loff_t pos; -}; -static int tasks_show (struct seq_file *f,void *v) {
@@ -47,12 +42,10 @@ static void * tasks_start(struct seq_file *f, loff_t *ppos) __acquires(&clnt->cl_lock) { - struct rpc_clnt_iter *iter = f->private; + struct rpc_clnt *clnt = f->private;loff_t pos = *ppos; -struct rpc_clnt *clnt = iter->clnt;struct rpc_task *task; - iter->pos = pos +1 ;spin_lock (&clnt->cl_lock);list_for_each_entry (task, &clnt->cl_tasks, tk_task)if (pos-- ==0 )
@@ -63,12 +56,10 @@ tasks_start(struct seq_file *f, loff_t *ppos)static void *tasks_next (struct seq_file *f,void *v,loff_t *pos) { -struct rpc_clnt_iter *iter = f->private; -struct rpc_clnt *clnt = iter->clnt; +struct rpc_clnt *clnt = f->private;struct rpc_task *task = v;struct list_head *next = task->tk_task.next; - ++iter->pos; ++*pos;/* If there's another task on list, return it */
@@ -81,9 +72,7 @@ static void tasks_stop(struct seq_file *f, void *v) __releases(&clnt->cl_lock) { - struct rpc_clnt_iter *iter = f->private; -struct rpc_clnt *clnt = iter->clnt; - + struct rpc_clnt *clnt = f->private;spin_unlock (&clnt->cl_lock); }
@@ -96,17 +85,13 @@ static const struct seq_operations tasks_seq_operations = {static int tasks_open (struct inode *inode,struct file *filp) { -int ret =seq_open_private (filp, &tasks_seq_operations, -sizeof (struct rpc_clnt_iter )); - +int ret =seq_open (filp, &tasks_seq_operations);if (!ret) {struct seq_file *seq = filp->private_data; -struct rpc_clnt_iter *iter = seq->private; - - iter->clnt = inode->i_private; +struct rpc_clnt *clnt = seq->private = inode->i_private; -if (!atomic_inc_not_zero (&iter->clnt->cl_count)) { -seq_release_private (inode, filp); +if (!atomic_inc_not_zero (&clnt->cl_count)) { +seq_release (inode, filp); ret = -EINVAL ; } }
@@ -118,10 +103,10 @@ static int tasks_release(struct inode *inode, struct file *filp) { struct seq_file *seq = filp->private_data; -struct rpc_clnt_iter *iter = seq->private; +struct rpc_clnt *clnt = seq->private; -rpc_release_client (iter->clnt); -return seq_release_private (inode, filp); +rpc_release_client (clnt); +return seq_release (inode, filp); } static const struct file_operations tasks_fops = {
Signature · 1 line
2.9.3
PATCH 7/7 sunrpc: use simple_read_from_buffer for reading cache flush
In reply to Kinglong Mee--- net/sunrpc/cache.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
net/sunrpc/cache.c +3 -12
@@ -1427,20 +1427,11 @@ static ssize_t read_flush(struct file *file, char __user *buf, struct cache_detail *cd) {char tbuf[22 ]; -unsigned long p = *ppos;size_t len; -snprintf (tbuf,sizeof (tbuf),"%lu\n" ,convert_to_wallclock (cd->flush_time)); - len =strlen (tbuf); -if (p >= len) -return 0 ; - len -= p; -if (len > count) - len = count; -if (copy_to_user (buf, (void *)(tbuf+p), len)) -return -EFAULT ; - *ppos += len; -return len; + len =snprintf (tbuf,sizeof (tbuf),"%lu\n" , +convert_to_wallclock (cd->flush_time)); +return simple_read_from_buffer (buf, count, ppos, tbuf, len); } static ssize_t write_flush(struct file *file, const char __user *buf,
Signature · 1 line
2.9.3
Thanks, these look fine to me.
It's really a mixture of client- and server- side stuff, but seems unlikely to have serious conflicts with either. For simplicity's sake I think I'll just take them, unless Trond tells me he has.
--b.
Quoted 26 lines · Kinglong Mee
The first one is an bugfix of checking register_shrinker's result, the following sixes are codes cleanup and updates.
Kinglong Mee (7):
sunrpc: error out ifregister_shrinkerfail sunrpc/nfs: cleanup procfs/pipefs entry incache_detail
sunrpc: renameNFS_NGROUPStoUNX_NGROUPSfor auth unix
sunrpc: remove dead codes ofcr_magicinrpc_cred
sunrpc: update the comments of sunrpc proc path
sunrpc: record rpc client pointer inseq->privatedirectly
sunrpc: usesimple_read_from_bufferfor reading cache flushfs/nfs/cache_lib.c | 3 +- include/linux/sunrpc/auth.h | 6 +--- include/linux/sunrpc/cache.h | 15 ++-------- net/sunrpc/auth.c | 9 +++--- net/sunrpc/auth_null.c | 3 -- net/sunrpc/auth_unix.c | 18 ++++++------ net/sunrpc/cache.c | 68 ++++++++++++++------------------------------ net/sunrpc/debugfs.c | 35 +++++++---------------- net/sunrpc/svcauth_unix.c | 4 +-- 9 files changed, 52 insertions(+), 109 deletions(-)Signature · 1 line
2.9.3
T24gRnJpLCAyMDE3LTAyLTE3IGF0IDEyOjAzIC0wNTAwLCBKLiBCcnVjZSBGaWVsZHMgd3JvdGU6 DQo+IFRoYW5rcywgdGhlc2UgbG9vayBmaW5lIHRvIG1lLg0KPiANCj4gSXQncyByZWFsbHkgYSBt aXh0dXJlIG9mIGNsaWVudC0gYW5kIHNlcnZlci0gc2lkZSBzdHVmZiwgYnV0IHNlZW1zDQo+IHVu bGlrZWx5IHRvIGhhdmUgc2VyaW91cyBjb25mbGljdHMgd2l0aCBlaXRoZXIuwqDCoEZvciBzaW1w bGljaXR5J3MNCj4gc2FrZSBJDQo+IHRoaW5rIEknbGwganVzdCB0YWtlIHRoZW0sIHVubGVzcyBU cm9uZCB0ZWxscyBtZSBoZSBoYXMuDQo+IA0KDQpBbm5hIGlzIG1hbmFnaW5nIHRoZSBtZXJnZSB3 aW5kb3cgZm9yIHRoZSBvZGQtbnVtYmVyZWQga2VybmVsIHJlbGVhc2VzDQooQ2NlZCkuDQoNCi0t IA0KVHJvbmQgTXlrbGVidXN0DQpMaW51eCBORlMgY2xpZW50IG1haW50YWluZXIsIFByaW1hcnlE YXRhDQp0cm9uZC5teWtsZWJ1c3RAcHJpbWFyeWRhdGEuY29tDQo=
Quoted 11 lines · Trond Myklebust
Quoted 7 lines · J. Bruce Fields
Thanks, these look fine to me.
It's really a mixture of client- and server- side stuff, but seems unlikely to have serious conflicts with either. For simplicity's sake I
think I'll just take them, unless Trond tells me he has.Anna is managing the merge window for the odd-numbered kernel releases (Cced).
Got it, thanks. Anna, I've currently got this queued up in my tree, but let me know if that's a problem.
(This every-other-kernel scheme would be easier for me to remember if only one of you was clearly odder than the other. But I think you're about equally odd.)
--b.
Hi Bruce,
Quoted 10 lines · On 02/17/2017 02:09 PM, [email protected] wrote:
Quoted 9 lines · Trond Myklebust
Quoted 7 lines · J. Bruce Fields
Thanks, these look fine to me.
It's really a mixture of client- and server- side stuff, but seems unlikely to have serious conflicts with either. For simplicity's sake I
think I'll just take them, unless Trond tells me he has.
Quoted 5 lines
Quoted 2 lines
Anna is managing the merge window for the odd-numbered kernel releases (Cced).
Got it, thanks. Anna, I've currently got this queued up in my tree, but let me know if that's a problem.
I have everything applied to my tree, but I don't mind if you want to take all the patches :)
Quoted 4 lines
(This every-other-kernel scheme would be easier for me to remember if only one of you was clearly odder than the other. But I think you're about equally odd.)
Well, I guess I could try to find even more weird hobbies ...
Quoted 3 lines
--b.
Quoted 13 lines · Anna Schumaker
Hi Bruce,
Quoted 10 lines · On 02/17/2017 02:09 PM, [email protected] wrote:
Quoted 9 lines · Trond Myklebust
Quoted 7 lines · J. Bruce Fields
Thanks, these look fine to me.
It's really a mixture of client- and server- side stuff, but seems unlikely to have serious conflicts with either. For simplicity's sake I
think I'll just take them, unless Trond tells me he has.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Anna is managing the merge window for the odd-numbered kernel releases (Cced).
Got it, thanks. Anna, I've currently got this queued up in my tree, but let me know if that's a problem.
I have everything applied to my tree, but I don't mind if you want to take all the patches :)
I'll leave them to you--I've dropped these 7 patches.
Quoted 5 lines
Quoted 3 lines
(This every-other-kernel scheme would be easier for me to remember if only one of you was clearly odder than the other. But I think you're about equally odd.)
Well, I guess I could try to find even more weird hobbies ...
I'll look forward to hearing more.
--b.
T24gRnJpLCAyMDE3LTAyLTE3IGF0IDE0OjA5IC0wNTAwLCBiZmllbGRzQGZpZWxkc2VzLm9yZyB3 cm90ZToNCj4gKFRoaXMgZXZlcnktb3RoZXIta2VybmVsIHNjaGVtZSB3b3VsZCBiZSBlYXNpZXIg Zm9yIG1lIHRvIHJlbWVtYmVyIGlmDQo+IG9ubHkgb25lIG9mIHlvdSB3YXMgY2xlYXJseSBvZGRl ciB0aGFuIHRoZSBvdGhlci7CoMKgQnV0IEkgdGhpbmsgeW91J3JlDQo+IGFib3V0IGVxdWFsbHkg b2RkLikNCj4gDQoNClNvIHlvdSdyZSBzYXlpbmcgd2UncmUgZXZlbj8NCg0KLS0gDQpUcm9uZCBN eWtsZWJ1c3QNCkxpbnV4IE5GUyBjbGllbnQgbWFpbnRhaW5lciwgUHJpbWFyeURhdGENCnRyb25k Lm15a2xlYnVzdEBwcmltYXJ5ZGF0YS5jb20NCg==