Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
kernel_linux
提交
3a649b88
K
kernel_linux
项目概览
OpenHarmony
/
kernel_linux
上一次同步 4 年多
通知
15
Star
8
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kernel_linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
3a649b88
编写于
3月 20, 2006
作者:
T
Trond Myklebust
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
NLM: Simplify client locks
Signed-off-by:
N
Trond Myklebust
<
Trond.Myklebust@netapp.com
>
上级
d72b7a6b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
54 deletion
+35
-54
fs/lockd/clntlock.c
fs/lockd/clntlock.c
+16
-27
fs/lockd/clntproc.c
fs/lockd/clntproc.c
+16
-23
include/linux/lockd/lockd.h
include/linux/lockd/lockd.h
+3
-4
未找到文件。
fs/lockd/clntlock.c
浏览文件 @
3a649b88
...
@@ -44,32 +44,25 @@ static LIST_HEAD(nlm_blocked);
...
@@ -44,32 +44,25 @@ static LIST_HEAD(nlm_blocked);
/*
/*
* Queue up a lock for blocking so that the GRANTED request can see it
* Queue up a lock for blocking so that the GRANTED request can see it
*/
*/
int
nlmclnt_prepare_block
(
struct
nlm_rqst
*
req
,
struct
nlm_host
*
host
,
struct
file_lock
*
fl
)
struct
nlm_wait
*
nlmclnt_prepare_block
(
struct
nlm_host
*
host
,
struct
file_lock
*
fl
)
{
{
struct
nlm_wait
*
block
;
struct
nlm_wait
*
block
;
BUG_ON
(
req
->
a_block
!=
NULL
);
block
=
kmalloc
(
sizeof
(
*
block
),
GFP_KERNEL
);
block
=
kmalloc
(
sizeof
(
*
block
),
GFP_KERNEL
);
if
(
block
==
NULL
)
if
(
block
!=
NULL
)
{
return
-
ENOMEM
;
block
->
b_host
=
host
;
block
->
b_host
=
host
;
block
->
b_lock
=
fl
;
block
->
b_lock
=
fl
;
init_waitqueue_head
(
&
block
->
b_wait
);
init_waitqueue_head
(
&
block
->
b_wait
);
block
->
b_status
=
NLM_LCK_BLOCKED
;
block
->
b_status
=
NLM_LCK_BLOCKED
;
list_add
(
&
block
->
b_list
,
&
nlm_blocked
);
}
list_add
(
&
block
->
b_list
,
&
nlm_blocked
);
return
block
;
req
->
a_block
=
block
;
return
0
;
}
}
void
nlmclnt_finish_block
(
struct
nlm_
rqst
*
req
)
void
nlmclnt_finish_block
(
struct
nlm_
wait
*
block
)
{
{
struct
nlm_wait
*
block
=
req
->
a_block
;
if
(
block
==
NULL
)
if
(
block
==
NULL
)
return
;
return
;
req
->
a_block
=
NULL
;
list_del
(
&
block
->
b_list
);
list_del
(
&
block
->
b_list
);
kfree
(
block
);
kfree
(
block
);
}
}
...
@@ -77,15 +70,14 @@ void nlmclnt_finish_block(struct nlm_rqst *req)
...
@@ -77,15 +70,14 @@ void nlmclnt_finish_block(struct nlm_rqst *req)
/*
/*
* Block on a lock
* Block on a lock
*/
*/
long
nlmclnt_block
(
struct
nlm_rqst
*
req
,
long
timeout
)
int
nlmclnt_block
(
struct
nlm_wait
*
block
,
struct
nlm_rqst
*
req
,
long
timeout
)
{
{
struct
nlm_wait
*
block
=
req
->
a_block
;
long
ret
;
long
ret
;
/* A borken server might ask us to block even if we didn't
/* A borken server might ask us to block even if we didn't
* request it. Just say no!
* request it. Just say no!
*/
*/
if
(
!
req
->
a_args
.
block
)
if
(
block
==
NULL
)
return
-
EAGAIN
;
return
-
EAGAIN
;
/* Go to sleep waiting for GRANT callback. Some servers seem
/* Go to sleep waiting for GRANT callback. Some servers seem
...
@@ -99,13 +91,10 @@ long nlmclnt_block(struct nlm_rqst *req, long timeout)
...
@@ -99,13 +91,10 @@ long nlmclnt_block(struct nlm_rqst *req, long timeout)
ret
=
wait_event_interruptible_timeout
(
block
->
b_wait
,
ret
=
wait_event_interruptible_timeout
(
block
->
b_wait
,
block
->
b_status
!=
NLM_LCK_BLOCKED
,
block
->
b_status
!=
NLM_LCK_BLOCKED
,
timeout
);
timeout
);
if
(
ret
<
0
)
if
(
block
->
b_status
!=
NLM_LCK_BLOCKED
)
{
return
-
ERESTARTSYS
;
req
->
a_res
.
status
=
block
->
b_status
;
req
->
a_res
.
status
=
block
->
b_status
;
block
->
b_status
=
NLM_LCK_BLOCKED
;
return
0
;
}
return
ret
;
}
}
/*
/*
...
...
fs/lockd/clntproc.c
浏览文件 @
3a649b88
...
@@ -136,15 +136,14 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl)
...
@@ -136,15 +136,14 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl)
(
unsigned
int
)
fl
->
fl_u
.
nfs_fl
.
owner
->
pid
,
(
unsigned
int
)
fl
->
fl_u
.
nfs_fl
.
owner
->
pid
,
system_utsname
.
nodename
);
system_utsname
.
nodename
);
lock
->
svid
=
fl
->
fl_u
.
nfs_fl
.
owner
->
pid
;
lock
->
svid
=
fl
->
fl_u
.
nfs_fl
.
owner
->
pid
;
locks_copy_lock
(
&
lock
->
fl
,
fl
);
lock
->
fl
.
fl_start
=
fl
->
fl_start
;
lock
->
fl
.
fl_end
=
fl
->
fl_end
;
lock
->
fl
.
fl_type
=
fl
->
fl_type
;
}
}
static
void
nlmclnt_release_lockargs
(
struct
nlm_rqst
*
req
)
static
void
nlmclnt_release_lockargs
(
struct
nlm_rqst
*
req
)
{
{
struct
file_lock
*
fl
=
&
req
->
a_args
.
lock
.
fl
;
BUG_ON
(
req
->
a_args
.
lock
.
fl
.
fl_ops
!=
NULL
);
if
(
fl
->
fl_ops
&&
fl
->
fl_ops
->
fl_release_private
)
fl
->
fl_ops
->
fl_release_private
(
fl
);
}
}
/*
/*
...
@@ -455,7 +454,6 @@ static void nlmclnt_locks_release_private(struct file_lock *fl)
...
@@ -455,7 +454,6 @@ static void nlmclnt_locks_release_private(struct file_lock *fl)
{
{
list_del
(
&
fl
->
fl_u
.
nfs_fl
.
list
);
list_del
(
&
fl
->
fl_u
.
nfs_fl
.
list
);
nlm_put_lockowner
(
fl
->
fl_u
.
nfs_fl
.
owner
);
nlm_put_lockowner
(
fl
->
fl_u
.
nfs_fl
.
owner
);
fl
->
fl_ops
=
NULL
;
}
}
static
struct
file_lock_operations
nlmclnt_lock_ops
=
{
static
struct
file_lock_operations
nlmclnt_lock_ops
=
{
...
@@ -515,41 +513,36 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
...
@@ -515,41 +513,36 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
{
{
struct
nlm_host
*
host
=
req
->
a_host
;
struct
nlm_host
*
host
=
req
->
a_host
;
struct
nlm_res
*
resp
=
&
req
->
a_res
;
struct
nlm_res
*
resp
=
&
req
->
a_res
;
long
timeout
;
struct
nlm_wait
*
block
=
NULL
;
int
status
;
int
status
=
-
ENOLCK
;
if
(
!
host
->
h_monitored
&&
nsm_monitor
(
host
)
<
0
)
{
if
(
!
host
->
h_monitored
&&
nsm_monitor
(
host
)
<
0
)
{
printk
(
KERN_NOTICE
"lockd: failed to monitor %s
\n
"
,
printk
(
KERN_NOTICE
"lockd: failed to monitor %s
\n
"
,
host
->
h_name
);
host
->
h_name
);
status
=
-
ENOLCK
;
goto
out
;
goto
out
;
}
}
if
(
req
->
a_args
.
block
)
{
block
=
nlmclnt_prepare_block
(
host
,
fl
);
status
=
nlmclnt_prepare_block
(
req
,
host
,
fl
);
if
(
status
<
0
)
goto
out
;
}
for
(;;)
{
for
(;;)
{
status
=
nlmclnt_call
(
req
,
NLMPROC_LOCK
);
status
=
nlmclnt_call
(
req
,
NLMPROC_LOCK
);
if
(
status
<
0
)
if
(
status
<
0
)
goto
out_unblock
;
goto
out_unblock
;
if
(
resp
->
status
!=
NLM_LCK_BLOCKED
)
if
(
!
req
->
a_args
.
block
)
break
;
break
;
/* Wait on an NLM blocking lock */
timeout
=
nlmclnt_block
(
req
,
NLMCLNT_POLL_TIMEOUT
);
/* Did a reclaimer thread notify us of a server reboot? */
/* Did a reclaimer thread notify us of a server reboot? */
if
(
resp
->
status
==
NLM_LCK_DENIED_GRACE_PERIOD
)
if
(
resp
->
status
==
NLM_LCK_DENIED_GRACE_PERIOD
)
continue
;
continue
;
if
(
resp
->
status
!=
NLM_LCK_BLOCKED
)
if
(
resp
->
status
!=
NLM_LCK_BLOCKED
)
break
;
break
;
if
(
timeout
>=
0
)
/* Wait on an NLM blocking lock */
continue
;
status
=
nlmclnt_block
(
block
,
req
,
NLMCLNT_POLL_TIMEOUT
)
;
/*
W
e were interrupted. Send a CANCEL request to the server
/*
if w
e were interrupted. Send a CANCEL request to the server
* and exit
* and exit
*/
*/
status
=
(
int
)
timeout
;
if
(
status
<
0
)
goto
out_unblock
;
goto
out_unblock
;
if
(
resp
->
status
!=
NLM_LCK_BLOCKED
)
break
;
}
}
if
(
resp
->
status
==
NLM_LCK_GRANTED
)
{
if
(
resp
->
status
==
NLM_LCK_GRANTED
)
{
...
@@ -560,7 +553,7 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
...
@@ -560,7 +553,7 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
}
}
status
=
nlm_stat_to_errno
(
resp
->
status
);
status
=
nlm_stat_to_errno
(
resp
->
status
);
out_unblock:
out_unblock:
nlmclnt_finish_block
(
req
);
nlmclnt_finish_block
(
block
);
/* Cancel the blocked request if it is still pending */
/* Cancel the blocked request if it is still pending */
if
(
resp
->
status
==
NLM_LCK_BLOCKED
)
if
(
resp
->
status
==
NLM_LCK_BLOCKED
)
nlmclnt_cancel
(
host
,
req
->
a_args
.
block
,
fl
);
nlmclnt_cancel
(
host
,
req
->
a_args
.
block
,
fl
);
...
...
include/linux/lockd/lockd.h
浏览文件 @
3a649b88
...
@@ -86,7 +86,6 @@ struct nlm_rqst {
...
@@ -86,7 +86,6 @@ struct nlm_rqst {
struct
nlm_host
*
a_host
;
/* host handle */
struct
nlm_host
*
a_host
;
/* host handle */
struct
nlm_args
a_args
;
/* arguments */
struct
nlm_args
a_args
;
/* arguments */
struct
nlm_res
a_res
;
/* result */
struct
nlm_res
a_res
;
/* result */
struct
nlm_wait
*
a_block
;
unsigned
int
a_retries
;
/* Retry count */
unsigned
int
a_retries
;
/* Retry count */
char
a_owner
[
NLMCLNT_OHSIZE
];
char
a_owner
[
NLMCLNT_OHSIZE
];
};
};
...
@@ -149,9 +148,9 @@ extern unsigned long nlmsvc_timeout;
...
@@ -149,9 +148,9 @@ extern unsigned long nlmsvc_timeout;
* Lockd client functions
* Lockd client functions
*/
*/
struct
nlm_rqst
*
nlmclnt_alloc_call
(
void
);
struct
nlm_rqst
*
nlmclnt_alloc_call
(
void
);
int
nlmclnt_prepare_block
(
struct
nlm_rqst
*
req
,
struct
nlm_host
*
host
,
struct
file_lock
*
fl
);
struct
nlm_wait
*
nlmclnt_prepare_block
(
struct
nlm_host
*
host
,
struct
file_lock
*
fl
);
void
nlmclnt_finish_block
(
struct
nlm_
rqst
*
req
);
void
nlmclnt_finish_block
(
struct
nlm_
wait
*
block
);
long
nlmclnt_block
(
struct
nlm_rqst
*
req
,
long
timeout
);
int
nlmclnt_block
(
struct
nlm_wait
*
block
,
struct
nlm_rqst
*
req
,
long
timeout
);
u32
nlmclnt_grant
(
const
struct
sockaddr_in
*
addr
,
const
struct
nlm_lock
*
);
u32
nlmclnt_grant
(
const
struct
sockaddr_in
*
addr
,
const
struct
nlm_lock
*
);
void
nlmclnt_recovery
(
struct
nlm_host
*
,
u32
);
void
nlmclnt_recovery
(
struct
nlm_host
*
,
u32
);
int
nlmclnt_reclaim
(
struct
nlm_host
*
,
struct
file_lock
*
);
int
nlmclnt_reclaim
(
struct
nlm_host
*
,
struct
file_lock
*
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录