Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
3a498026
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3a498026
编写于
12月 14, 2007
作者:
T
Trond Myklebust
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
NFS: Clean up the nfs_client initialisation
Signed-off-by:
N
Trond Myklebust
<
Trond.Myklebust@netapp.com
>
上级
bfc69a45
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
20 deletion
+31
-20
fs/nfs/client.c
fs/nfs/client.c
+31
-20
未找到文件。
fs/nfs/client.c
浏览文件 @
3a498026
...
@@ -93,22 +93,26 @@ struct rpc_program nfsacl_program = {
...
@@ -93,22 +93,26 @@ struct rpc_program nfsacl_program = {
};
};
#endif
/* CONFIG_NFS_V3_ACL */
#endif
/* CONFIG_NFS_V3_ACL */
struct
nfs_client_initdata
{
const
char
*
hostname
;
const
struct
sockaddr_in
*
addr
;
int
version
;
};
/*
/*
* Allocate a shared client record
* Allocate a shared client record
*
*
* Since these are allocated/deallocated very rarely, we don't
* Since these are allocated/deallocated very rarely, we don't
* bother putting them in a slab cache...
* bother putting them in a slab cache...
*/
*/
static
struct
nfs_client
*
nfs_alloc_client
(
const
char
*
hostname
,
static
struct
nfs_client
*
nfs_alloc_client
(
const
struct
nfs_client_initdata
*
cl_init
)
const
struct
sockaddr_in
*
addr
,
int
nfsversion
)
{
{
struct
nfs_client
*
clp
;
struct
nfs_client
*
clp
;
if
((
clp
=
kzalloc
(
sizeof
(
*
clp
),
GFP_KERNEL
))
==
NULL
)
if
((
clp
=
kzalloc
(
sizeof
(
*
clp
),
GFP_KERNEL
))
==
NULL
)
goto
error_0
;
goto
error_0
;
if
(
nfs
version
==
4
)
{
if
(
cl_init
->
version
==
4
)
{
if
(
nfs_callback_up
()
<
0
)
if
(
nfs_callback_up
()
<
0
)
goto
error_2
;
goto
error_2
;
__set_bit
(
NFS_CS_CALLBACK
,
&
clp
->
cl_res_state
);
__set_bit
(
NFS_CS_CALLBACK
,
&
clp
->
cl_res_state
);
...
@@ -117,11 +121,11 @@ static struct nfs_client *nfs_alloc_client(const char *hostname,
...
@@ -117,11 +121,11 @@ static struct nfs_client *nfs_alloc_client(const char *hostname,
atomic_set
(
&
clp
->
cl_count
,
1
);
atomic_set
(
&
clp
->
cl_count
,
1
);
clp
->
cl_cons_state
=
NFS_CS_INITING
;
clp
->
cl_cons_state
=
NFS_CS_INITING
;
clp
->
cl_nfsversion
=
nfs
version
;
clp
->
cl_nfsversion
=
cl_init
->
version
;
memcpy
(
&
clp
->
cl_addr
,
addr
,
sizeof
(
clp
->
cl_addr
));
memcpy
(
&
clp
->
cl_addr
,
cl_init
->
addr
,
sizeof
(
clp
->
cl_addr
));
if
(
hostname
)
{
if
(
cl_init
->
hostname
)
{
clp
->
cl_hostname
=
kstrdup
(
hostname
,
GFP_KERNEL
);
clp
->
cl_hostname
=
kstrdup
(
cl_init
->
hostname
,
GFP_KERNEL
);
if
(
!
clp
->
cl_hostname
)
if
(
!
clp
->
cl_hostname
)
goto
error_3
;
goto
error_3
;
}
}
...
@@ -256,22 +260,20 @@ struct nfs_client *nfs_find_client(const struct sockaddr_in *addr, int nfsversio
...
@@ -256,22 +260,20 @@ struct nfs_client *nfs_find_client(const struct sockaddr_in *addr, int nfsversio
* Look up a client by IP address and protocol version
* Look up a client by IP address and protocol version
* - creates a new record if one doesn't yet exist
* - creates a new record if one doesn't yet exist
*/
*/
static
struct
nfs_client
*
nfs_get_client
(
const
char
*
hostname
,
static
struct
nfs_client
*
nfs_get_client
(
const
struct
nfs_client_initdata
*
cl_init
)
const
struct
sockaddr_in
*
addr
,
int
nfsversion
)
{
{
struct
nfs_client
*
clp
,
*
new
=
NULL
;
struct
nfs_client
*
clp
,
*
new
=
NULL
;
int
error
;
int
error
;
dprintk
(
"--> nfs_get_client(%s,"
NIPQUAD_FMT
":%d,%d)
\n
"
,
dprintk
(
"--> nfs_get_client(%s,"
NIPQUAD_FMT
":%d,%d)
\n
"
,
hostname
?:
""
,
NIPQUAD
(
addr
->
sin_addr
),
cl_init
->
hostname
?:
""
,
NIPQUAD
(
cl_init
->
addr
->
sin_addr
),
addr
->
sin_port
,
nfs
version
);
cl_init
->
addr
->
sin_port
,
cl_init
->
version
);
/* see if the client already exists */
/* see if the client already exists */
do
{
do
{
spin_lock
(
&
nfs_client_lock
);
spin_lock
(
&
nfs_client_lock
);
clp
=
__nfs_find_client
(
addr
,
nfs
version
,
1
);
clp
=
__nfs_find_client
(
cl_init
->
addr
,
cl_init
->
version
,
1
);
if
(
clp
)
if
(
clp
)
goto
found_client
;
goto
found_client
;
if
(
new
)
if
(
new
)
...
@@ -279,7 +281,7 @@ static struct nfs_client *nfs_get_client(const char *hostname,
...
@@ -279,7 +281,7 @@ static struct nfs_client *nfs_get_client(const char *hostname,
spin_unlock
(
&
nfs_client_lock
);
spin_unlock
(
&
nfs_client_lock
);
new
=
nfs_alloc_client
(
hostname
,
addr
,
nfsversion
);
new
=
nfs_alloc_client
(
cl_init
);
}
while
(
new
);
}
while
(
new
);
return
ERR_PTR
(
-
ENOMEM
);
return
ERR_PTR
(
-
ENOMEM
);
...
@@ -540,19 +542,23 @@ static int nfs_init_client(struct nfs_client *clp,
...
@@ -540,19 +542,23 @@ static int nfs_init_client(struct nfs_client *clp,
static
int
nfs_init_server
(
struct
nfs_server
*
server
,
static
int
nfs_init_server
(
struct
nfs_server
*
server
,
const
struct
nfs_parsed_mount_data
*
data
)
const
struct
nfs_parsed_mount_data
*
data
)
{
{
struct
nfs_client_initdata
cl_init
=
{
.
hostname
=
data
->
nfs_server
.
hostname
,
.
addr
=
&
data
->
nfs_server
.
address
,
.
version
=
2
,
};
struct
nfs_client
*
clp
;
struct
nfs_client
*
clp
;
int
error
,
nfsvers
=
2
;
int
error
;
dprintk
(
"--> nfs_init_server()
\n
"
);
dprintk
(
"--> nfs_init_server()
\n
"
);
#ifdef CONFIG_NFS_V3
#ifdef CONFIG_NFS_V3
if
(
data
->
flags
&
NFS_MOUNT_VER3
)
if
(
data
->
flags
&
NFS_MOUNT_VER3
)
nfsvers
=
3
;
cl_init
.
version
=
3
;
#endif
#endif
/* Allocate or find a client reference we can use */
/* Allocate or find a client reference we can use */
clp
=
nfs_get_client
(
data
->
nfs_server
.
hostname
,
clp
=
nfs_get_client
(
&
cl_init
);
&
data
->
nfs_server
.
address
,
nfsvers
);
if
(
IS_ERR
(
clp
))
{
if
(
IS_ERR
(
clp
))
{
dprintk
(
"<-- nfs_init_server() = error %ld
\n
"
,
PTR_ERR
(
clp
));
dprintk
(
"<-- nfs_init_server() = error %ld
\n
"
,
PTR_ERR
(
clp
));
return
PTR_ERR
(
clp
);
return
PTR_ERR
(
clp
);
...
@@ -889,13 +895,18 @@ static int nfs4_set_client(struct nfs_server *server,
...
@@ -889,13 +895,18 @@ static int nfs4_set_client(struct nfs_server *server,
rpc_authflavor_t
authflavour
,
rpc_authflavor_t
authflavour
,
int
proto
,
int
timeo
,
int
retrans
)
int
proto
,
int
timeo
,
int
retrans
)
{
{
struct
nfs_client_initdata
cl_init
=
{
.
hostname
=
hostname
,
.
addr
=
addr
,
.
version
=
4
,
};
struct
nfs_client
*
clp
;
struct
nfs_client
*
clp
;
int
error
;
int
error
;
dprintk
(
"--> nfs4_set_client()
\n
"
);
dprintk
(
"--> nfs4_set_client()
\n
"
);
/* Allocate or find a client reference we can use */
/* Allocate or find a client reference we can use */
clp
=
nfs_get_client
(
hostname
,
addr
,
4
);
clp
=
nfs_get_client
(
&
cl_init
);
if
(
IS_ERR
(
clp
))
{
if
(
IS_ERR
(
clp
))
{
error
=
PTR_ERR
(
clp
);
error
=
PTR_ERR
(
clp
);
goto
error
;
goto
error
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录