Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
2afdfa5a
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看板
提交
2afdfa5a
编写于
10月 01, 2012
作者:
T
Trond Myklebust
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'bugfixes' into nfs-for-next
上级
7297cb68
0cac1202
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
70 addition
and
34 deletion
+70
-34
fs/nfs/idmap.c
fs/nfs/idmap.c
+70
-34
未找到文件。
fs/nfs/idmap.c
浏览文件 @
2afdfa5a
...
...
@@ -55,18 +55,19 @@
static
const
struct
cred
*
id_resolver_cache
;
static
struct
key_type
key_type_id_resolver_legacy
;
struct
idmap
{
struct
rpc_pipe
*
idmap_pipe
;
struct
key_construction
*
idmap_key_cons
;
struct
mutex
idmap_mutex
;
};
struct
idmap_legacy_upcalldata
{
struct
rpc_pipe_msg
pipe_msg
;
struct
idmap_msg
idmap_msg
;
struct
key_construction
*
key_cons
;
struct
idmap
*
idmap
;
};
struct
idmap
{
struct
rpc_pipe
*
idmap_pipe
;
struct
idmap_legacy_upcalldata
*
idmap_upcall_data
;
struct
mutex
idmap_mutex
;
};
/**
* nfs_fattr_init_names - initialise the nfs_fattr owner_name/group_name fields
* @fattr: fully initialised struct nfs_fattr
...
...
@@ -330,7 +331,6 @@ static ssize_t nfs_idmap_get_key(const char *name, size_t namelen,
ret
=
nfs_idmap_request_key
(
&
key_type_id_resolver_legacy
,
name
,
namelen
,
type
,
data
,
data_size
,
idmap
);
idmap
->
idmap_key_cons
=
NULL
;
mutex_unlock
(
&
idmap
->
idmap_mutex
);
}
return
ret
;
...
...
@@ -465,8 +465,6 @@ nfs_idmap_new(struct nfs_client *clp)
struct
rpc_pipe
*
pipe
;
int
error
;
BUG_ON
(
clp
->
cl_idmap
!=
NULL
);
idmap
=
kzalloc
(
sizeof
(
*
idmap
),
GFP_KERNEL
);
if
(
idmap
==
NULL
)
return
-
ENOMEM
;
...
...
@@ -510,7 +508,6 @@ static int __rpc_pipefs_event(struct nfs_client *clp, unsigned long event,
switch
(
event
)
{
case
RPC_PIPEFS_MOUNT
:
BUG_ON
(
clp
->
cl_rpcclient
->
cl_dentry
==
NULL
);
err
=
__nfs_idmap_register
(
clp
->
cl_rpcclient
->
cl_dentry
,
clp
->
cl_idmap
,
clp
->
cl_idmap
->
idmap_pipe
);
...
...
@@ -662,6 +659,35 @@ static int nfs_idmap_prepare_message(char *desc, struct idmap *idmap,
return
ret
;
}
static
bool
nfs_idmap_prepare_pipe_upcall
(
struct
idmap
*
idmap
,
struct
idmap_legacy_upcalldata
*
data
)
{
if
(
idmap
->
idmap_upcall_data
!=
NULL
)
{
WARN_ON_ONCE
(
1
);
return
false
;
}
idmap
->
idmap_upcall_data
=
data
;
return
true
;
}
static
void
nfs_idmap_complete_pipe_upcall_locked
(
struct
idmap
*
idmap
,
int
ret
)
{
struct
key_construction
*
cons
=
idmap
->
idmap_upcall_data
->
key_cons
;
kfree
(
idmap
->
idmap_upcall_data
);
idmap
->
idmap_upcall_data
=
NULL
;
complete_request_key
(
cons
,
ret
);
}
static
void
nfs_idmap_abort_pipe_upcall
(
struct
idmap
*
idmap
,
int
ret
)
{
if
(
idmap
->
idmap_upcall_data
!=
NULL
)
nfs_idmap_complete_pipe_upcall_locked
(
idmap
,
ret
);
}
static
int
nfs_idmap_legacy_upcall
(
struct
key_construction
*
cons
,
const
char
*
op
,
void
*
aux
)
...
...
@@ -686,17 +712,15 @@ static int nfs_idmap_legacy_upcall(struct key_construction *cons,
if
(
ret
<
0
)
goto
out2
;
BUG_ON
(
idmap
->
idmap_key_cons
!=
NULL
);
idmap
->
idmap_key_cons
=
cons
;
ret
=
-
EAGAIN
;
if
(
!
nfs_idmap_prepare_pipe_upcall
(
idmap
,
data
))
goto
out2
;
ret
=
rpc_queue_upcall
(
idmap
->
idmap_pipe
,
msg
);
if
(
ret
<
0
)
goto
out3
;
nfs_idmap_abort_pipe_upcall
(
idmap
,
ret
)
;
return
ret
;
out3:
idmap
->
idmap_key_cons
=
NULL
;
out2:
kfree
(
data
);
out1:
...
...
@@ -711,21 +735,32 @@ static int nfs_idmap_instantiate(struct key *key, struct key *authkey, char *dat
authkey
);
}
static
int
nfs_idmap_read_message
(
struct
idmap_msg
*
im
,
struct
key
*
key
,
struct
key
*
authkey
)
static
int
nfs_idmap_read_and_verify_message
(
struct
idmap_msg
*
im
,
struct
idmap_msg
*
upcall
,
struct
key
*
key
,
struct
key
*
authkey
)
{
char
id_str
[
NFS_UINT_MAXLEN
];
int
ret
=
-
E
INVAL
;
int
ret
=
-
E
NOKEY
;
/* ret = -ENOKEY */
if
(
upcall
->
im_type
!=
im
->
im_type
||
upcall
->
im_conv
!=
im
->
im_conv
)
goto
out
;
switch
(
im
->
im_conv
)
{
case
IDMAP_CONV_NAMETOID
:
if
(
strcmp
(
upcall
->
im_name
,
im
->
im_name
)
!=
0
)
break
;
sprintf
(
id_str
,
"%d"
,
im
->
im_id
);
ret
=
nfs_idmap_instantiate
(
key
,
authkey
,
id_str
);
break
;
case
IDMAP_CONV_IDTONAME
:
if
(
upcall
->
im_id
!=
im
->
im_id
)
break
;
ret
=
nfs_idmap_instantiate
(
key
,
authkey
,
im
->
im_name
);
break
;
default:
ret
=
-
EINVAL
;
}
out:
return
ret
;
}
...
...
@@ -737,14 +772,16 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
struct
key_construction
*
cons
;
struct
idmap_msg
im
;
size_t
namelen_in
;
int
ret
;
int
ret
=
-
ENOKEY
;
/* If instantiation is successful, anyone waiting for key construction
* will have been woken up and someone else may now have used
* idmap_key_cons - so after this point we may no longer touch it.
*/
cons
=
ACCESS_ONCE
(
idmap
->
idmap_key_cons
);
idmap
->
idmap_key_cons
=
NULL
;
if
(
idmap
->
idmap_upcall_data
==
NULL
)
goto
out_noupcall
;
cons
=
idmap
->
idmap_upcall_data
->
key_cons
;
if
(
mlen
!=
sizeof
(
im
))
{
ret
=
-
ENOSPC
;
...
...
@@ -765,16 +802,19 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
if
(
namelen_in
==
0
||
namelen_in
==
IDMAP_NAMESZ
)
{
ret
=
-
EINVAL
;
goto
out
;
}
}
ret
=
nfs_idmap_read_message
(
&
im
,
cons
->
key
,
cons
->
authkey
);
ret
=
nfs_idmap_read_and_verify_message
(
&
im
,
&
idmap
->
idmap_upcall_data
->
idmap_msg
,
cons
->
key
,
cons
->
authkey
);
if
(
ret
>=
0
)
{
key_set_timeout
(
cons
->
key
,
nfs_idmap_cache_timeout
);
ret
=
mlen
;
}
out:
complete_request_key
(
cons
,
ret
);
nfs_idmap_complete_pipe_upcall_locked
(
idmap
,
ret
);
out_noupcall:
return
ret
;
}
...
...
@@ -785,14 +825,9 @@ idmap_pipe_destroy_msg(struct rpc_pipe_msg *msg)
struct
idmap_legacy_upcalldata
,
pipe_msg
);
struct
idmap
*
idmap
=
data
->
idmap
;
struct
key_construction
*
cons
;
if
(
msg
->
errno
)
{
cons
=
ACCESS_ONCE
(
idmap
->
idmap_key_cons
);
idmap
->
idmap_key_cons
=
NULL
;
complete_request_key
(
cons
,
msg
->
errno
);
}
/* Free memory allocated in nfs_idmap_legacy_upcall() */
kfree
(
data
);
if
(
msg
->
errno
)
nfs_idmap_abort_pipe_upcall
(
idmap
,
msg
->
errno
);
}
static
void
...
...
@@ -800,7 +835,8 @@ idmap_release_pipe(struct inode *inode)
{
struct
rpc_inode
*
rpci
=
RPC_I
(
inode
);
struct
idmap
*
idmap
=
(
struct
idmap
*
)
rpci
->
private
;
idmap
->
idmap_key_cons
=
NULL
;
nfs_idmap_abort_pipe_upcall
(
idmap
,
-
EPIPE
);
}
int
nfs_map_name_to_uid
(
const
struct
nfs_server
*
server
,
const
char
*
name
,
size_t
namelen
,
__u32
*
uid
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录