Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
f5c2187c
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
f5c2187c
编写于
6月 25, 2007
作者:
T
Trond Myklebust
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SUNRPC: Convert the credential garbage collector into a shrinker callback
Signed-off-by:
N
Trond Myklebust
<
Trond.Myklebust@netapp.com
>
上级
9499b434
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
52 addition
and
29 deletion
+52
-29
include/linux/sunrpc/auth.h
include/linux/sunrpc/auth.h
+3
-3
net/sunrpc/auth.c
net/sunrpc/auth.c
+45
-18
net/sunrpc/auth_gss/auth_gss.c
net/sunrpc/auth_gss/auth_gss.c
+1
-2
net/sunrpc/auth_unix.c
net/sunrpc/auth_unix.c
+1
-5
net/sunrpc/sunrpc_syms.c
net/sunrpc/sunrpc_syms.c
+2
-1
未找到文件。
include/linux/sunrpc/auth.h
浏览文件 @
f5c2187c
...
...
@@ -64,8 +64,6 @@ struct rpc_cred {
struct
rpc_cred_cache
{
struct
hlist_head
hashtable
[
RPC_CREDCACHE_NR
];
spinlock_t
lock
;
unsigned
long
nextgc
;
/* next garbage collection */
unsigned
long
expire
;
/* cache expiry interval */
};
struct
rpc_authops
;
...
...
@@ -128,6 +126,8 @@ extern const struct rpc_authops authunix_ops;
extern
const
struct
rpc_authops
authnull_ops
;
void
__init
rpc_init_authunix
(
void
);
void
__init
rpcauth_init_module
(
void
);
void
__exit
rpcauth_remove_module
(
void
);
int
rpcauth_register
(
const
struct
rpc_authops
*
);
int
rpcauth_unregister
(
const
struct
rpc_authops
*
);
...
...
@@ -147,7 +147,7 @@ int rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp,
int
rpcauth_refreshcred
(
struct
rpc_task
*
);
void
rpcauth_invalcred
(
struct
rpc_task
*
);
int
rpcauth_uptodatecred
(
struct
rpc_task
*
);
int
rpcauth_init_credcache
(
struct
rpc_auth
*
,
unsigned
long
);
int
rpcauth_init_credcache
(
struct
rpc_auth
*
);
void
rpcauth_destroy_credcache
(
struct
rpc_auth
*
);
void
rpcauth_clear_credcache
(
struct
rpc_cred_cache
*
);
...
...
net/sunrpc/auth.c
浏览文件 @
f5c2187c
...
...
@@ -26,6 +26,7 @@ static const struct rpc_authops *auth_flavors[RPC_AUTH_MAXFLAVOR] = {
};
static
LIST_HEAD
(
cred_unused
);
static
unsigned
long
number_cred_unused
;
static
u32
pseudoflavor_to_flavor
(
u32
flavor
)
{
...
...
@@ -136,7 +137,7 @@ rpcauth_unhash_cred(struct rpc_cred *cred)
* Initialize RPC credential cache
*/
int
rpcauth_init_credcache
(
struct
rpc_auth
*
auth
,
unsigned
long
expire
)
rpcauth_init_credcache
(
struct
rpc_auth
*
auth
)
{
struct
rpc_cred_cache
*
new
;
int
i
;
...
...
@@ -147,8 +148,6 @@ rpcauth_init_credcache(struct rpc_auth *auth, unsigned long expire)
for
(
i
=
0
;
i
<
RPC_CREDCACHE_NR
;
i
++
)
INIT_HLIST_HEAD
(
&
new
->
hashtable
[
i
]);
spin_lock_init
(
&
new
->
lock
);
new
->
expire
=
expire
;
new
->
nextgc
=
jiffies
+
(
expire
>>
1
);
auth
->
au_credcache
=
new
;
return
0
;
}
...
...
@@ -187,7 +186,11 @@ rpcauth_clear_credcache(struct rpc_cred_cache *cache)
while
(
!
hlist_empty
(
head
))
{
cred
=
hlist_entry
(
head
->
first
,
struct
rpc_cred
,
cr_hash
);
get_rpccred
(
cred
);
list_move_tail
(
&
cred
->
cr_lru
,
&
free
);
if
(
!
list_empty
(
&
cred
->
cr_lru
))
{
list_del
(
&
cred
->
cr_lru
);
number_cred_unused
--
;
}
list_add_tail
(
&
cred
->
cr_lru
,
&
free
);
rpcauth_unhash_cred_locked
(
cred
);
}
}
...
...
@@ -214,18 +217,16 @@ rpcauth_destroy_credcache(struct rpc_auth *auth)
/*
* Remove stale credentials. Avoid sleeping inside the loop.
*/
static
void
rpcauth_prune_expired
(
struct
list_head
*
free
)
static
int
rpcauth_prune_expired
(
struct
list_head
*
free
,
int
nr_to_scan
)
{
spinlock_t
*
cache_lock
;
struct
rpc_cred
*
cred
;
while
(
!
list_empty
(
&
cred_unused
))
{
cred
=
list_entry
(
cred_unused
.
next
,
struct
rpc_cred
,
cr_lru
);
if
(
time_after
(
jiffies
,
cred
->
cr_expire
+
cred
->
cr_auth
->
au_credcache
->
expire
))
break
;
list_del_init
(
&
cred
->
cr_lru
);
number_cred_unused
--
;
if
(
atomic_read
(
&
cred
->
cr_count
)
!=
0
)
continue
;
cache_lock
=
&
cred
->
cr_auth
->
au_credcache
->
lock
;
...
...
@@ -234,23 +235,32 @@ rpcauth_prune_expired(struct list_head *free)
get_rpccred
(
cred
);
list_add_tail
(
&
cred
->
cr_lru
,
free
);
rpcauth_unhash_cred_locked
(
cred
);
nr_to_scan
--
;
}
spin_unlock
(
cache_lock
);
if
(
nr_to_scan
==
0
)
break
;
}
return
nr_to_scan
;
}
/*
* Run
garbage collecto
r.
* Run
memory cache shrinke
r.
*/
static
void
rpcauth_
gc_credcache
(
struct
rpc_cred_cache
*
cache
,
struct
list_head
*
free
)
static
int
rpcauth_
cache_shrinker
(
int
nr_to_scan
,
gfp_t
gfp_mask
)
{
if
(
list_empty
(
&
cred_unused
)
||
time_before
(
jiffies
,
cache
->
nextgc
))
return
;
LIST_HEAD
(
free
);
int
res
;
if
(
list_empty
(
&
cred_unused
))
return
0
;
spin_lock
(
&
rpc_credcache_lock
);
cache
->
nextgc
=
jiffies
+
cache
->
expire
;
r
pcauth_prune_expired
(
free
)
;
nr_to_scan
=
rpcauth_prune_expired
(
&
free
,
nr_to_scan
)
;
r
es
=
(
number_cred_unused
/
100
)
*
sysctl_vfs_cache_pressure
;
spin_unlock
(
&
rpc_credcache_lock
);
rpcauth_destroy_credlist
(
&
free
);
return
res
;
}
/*
...
...
@@ -318,7 +328,6 @@ rpcauth_lookup_credcache(struct rpc_auth *auth, struct auth_cred * acred,
cred
=
ERR_PTR
(
res
);
}
}
rpcauth_gc_credcache
(
cache
,
&
free
);
rpcauth_destroy_credlist
(
&
free
);
out:
return
cred
;
...
...
@@ -408,13 +417,16 @@ put_rpccred(struct rpc_cred *cred)
need_lock:
if
(
!
atomic_dec_and_lock
(
&
cred
->
cr_count
,
&
rpc_credcache_lock
))
return
;
if
(
!
list_empty
(
&
cred
->
cr_lru
))
if
(
!
list_empty
(
&
cred
->
cr_lru
))
{
number_cred_unused
--
;
list_del_init
(
&
cred
->
cr_lru
);
}
if
(
test_bit
(
RPCAUTH_CRED_UPTODATE
,
&
cred
->
cr_flags
)
==
0
)
rpcauth_unhash_cred
(
cred
);
else
if
(
test_bit
(
RPCAUTH_CRED_HASHED
,
&
cred
->
cr_flags
)
!=
0
)
{
cred
->
cr_expire
=
jiffies
;
list_add_tail
(
&
cred
->
cr_lru
,
&
cred_unused
);
number_cred_unused
++
;
spin_unlock
(
&
rpc_credcache_lock
);
return
;
}
...
...
@@ -520,3 +532,18 @@ rpcauth_uptodatecred(struct rpc_task *task)
return
cred
==
NULL
||
test_bit
(
RPCAUTH_CRED_UPTODATE
,
&
cred
->
cr_flags
)
!=
0
;
}
static
struct
shrinker
*
rpc_cred_shrinker
;
void
__init
rpcauth_init_module
(
void
)
{
rpc_init_authunix
();
rpc_cred_shrinker
=
set_shrinker
(
DEFAULT_SEEKS
,
rpcauth_cache_shrinker
);
}
void
__exit
rpcauth_remove_module
(
void
)
{
if
(
rpc_cred_shrinker
!=
NULL
)
remove_shrinker
(
rpc_cred_shrinker
);
}
net/sunrpc/auth_gss/auth_gss.c
浏览文件 @
f5c2187c
...
...
@@ -64,7 +64,6 @@ static const struct rpc_credops gss_credops;
#define NFS_NGROUPS 16
#define GSS_CRED_EXPIRE (60 * HZ)
/* XXX: reasonable? */
#define GSS_CRED_SLACK 1024
/* XXX: unused */
/* length of a krb5 verifier (48), plus data added before arguments when
* using integrity (two 4-byte integers): */
...
...
@@ -643,7 +642,7 @@ gss_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor)
goto
err_put_mech
;
}
err
=
rpcauth_init_credcache
(
auth
,
GSS_CRED_EXPIRE
);
err
=
rpcauth_init_credcache
(
auth
);
if
(
err
)
goto
err_unlink_pipe
;
...
...
net/sunrpc/auth_unix.c
浏览文件 @
f5c2187c
...
...
@@ -21,8 +21,6 @@ struct unx_cred {
};
#define uc_uid uc_base.cr_uid
#define UNX_CRED_EXPIRE (60 * HZ)
#define UNX_WRITESLACK (21 + (UNX_MAXNODENAME >> 2))
#ifdef RPC_DEBUG
...
...
@@ -38,8 +36,7 @@ unx_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor)
{
dprintk
(
"RPC: creating UNIX authenticator for client %p
\n
"
,
clnt
);
if
(
atomic_inc_return
(
&
unix_auth
.
au_count
)
==
1
)
unix_cred_cache
.
nextgc
=
jiffies
+
(
unix_cred_cache
.
expire
>>
1
);
atomic_inc
(
&
unix_auth
.
au_count
);
return
&
unix_auth
;
}
...
...
@@ -232,7 +229,6 @@ const struct rpc_authops authunix_ops = {
static
struct
rpc_cred_cache
unix_cred_cache
=
{
.
expire
=
UNX_CRED_EXPIRE
,
};
static
...
...
net/sunrpc/sunrpc_syms.c
浏览文件 @
f5c2187c
...
...
@@ -152,7 +152,7 @@ init_sunrpc(void)
cache_register
(
&
ip_map_cache
);
cache_register
(
&
unix_gid_cache
);
init_socket_xprt
();
rpc
_init_authunix
();
rpc
auth_init_module
();
out:
return
err
;
}
...
...
@@ -160,6 +160,7 @@ init_sunrpc(void)
static
void
__exit
cleanup_sunrpc
(
void
)
{
rpcauth_remove_module
();
cleanup_socket_xprt
();
unregister_rpc_pipefs
();
rpc_destroy_mempool
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录