Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xiphi1978
linux
提交
09c7938c
L
linux
项目概览
xiphi1978
/
linux
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
09c7938c
编写于
3月 20, 2006
作者:
T
Trond Myklebust
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lockd: Fix server-side lock blocking code
Signed-off-by:
N
Trond Myklebust
<
Trond.Myklebust@netapp.com
>
上级
0996905f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
33 deletion
+40
-33
fs/lockd/svclock.c
fs/lockd/svclock.c
+40
-33
未找到文件。
fs/lockd/svclock.c
浏览文件 @
09c7938c
...
...
@@ -193,6 +193,7 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_file *file,
goto
failed_free
;
/* Set notifier function for VFS, and init args */
block
->
b_call
.
a_args
.
lock
.
fl
.
fl_flags
|=
FL_SLEEP
;
block
->
b_call
.
a_args
.
lock
.
fl
.
fl_lmops
=
&
nlmsvc_lock_operations
;
block
->
b_call
.
a_args
.
cookie
=
*
cookie
;
/* see above */
...
...
@@ -228,19 +229,18 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_file *file,
* can be closed hereafter.
*/
static
int
nlmsvc_delete_block
(
struct
nlm_block
*
block
,
int
unlock
)
nlmsvc_delete_block
(
struct
nlm_block
*
block
)
{
struct
file_lock
*
fl
=
&
block
->
b_call
.
a_args
.
lock
.
fl
;
struct
nlm_file
*
file
=
block
->
b_file
;
struct
nlm_block
**
bp
;
int
status
=
0
;
int
status
;
dprintk
(
"lockd: deleting block %p...
\n
"
,
block
);
/* Remove block from list */
nlmsvc_remove_block
(
block
);
if
(
unlock
)
status
=
posix_unblock_lock
(
file
->
f_file
,
fl
);
status
=
posix_unblock_lock
(
file
->
f_file
,
fl
);
/* If the block is in the middle of a GRANT callback,
* don't kill it yet. */
...
...
@@ -282,7 +282,7 @@ nlmsvc_traverse_blocks(struct nlm_host *host, struct nlm_file *file, int action)
block
->
b_host
->
h_inuse
=
1
;
else
if
(
action
==
NLM_ACT_UNLOCK
)
{
if
(
host
==
NULL
||
host
==
block
->
b_host
)
nlmsvc_delete_block
(
block
,
1
);
nlmsvc_delete_block
(
block
);
}
}
up
(
&
file
->
f_sema
);
...
...
@@ -297,7 +297,7 @@ u32
nlmsvc_lock
(
struct
svc_rqst
*
rqstp
,
struct
nlm_file
*
file
,
struct
nlm_lock
*
lock
,
int
wait
,
struct
nlm_cookie
*
cookie
)
{
struct
nlm_block
*
block
;
struct
nlm_block
*
block
,
*
newblock
=
NULL
;
int
error
;
u32
ret
;
...
...
@@ -310,59 +310,65 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
wait
);
/* Get existing block (in case client is busy-waiting) */
block
=
nlmsvc_lookup_block
(
file
,
lock
,
0
);
lock
->
fl
.
fl_flags
&=
~
FL_SLEEP
;
again:
/* Lock file against concurrent access */
down
(
&
file
->
f_sema
);
/* Get existing block (in case client is busy-waiting) */
block
=
nlmsvc_lookup_block
(
file
,
lock
,
0
);
if
(
block
==
NULL
)
{
if
(
newblock
!=
NULL
)
lock
=
&
newblock
->
b_call
.
a_args
.
lock
.
fl
;
}
else
lock
=
&
block
->
b_call
.
a_args
.
lock
.
fl
;
error
=
posix_lock_file
(
file
->
f_file
,
&
lock
->
fl
);
lock
->
fl
.
fl_flags
&=
~
FL_SLEEP
;
dprintk
(
"lockd: posix_lock_file returned %d
\n
"
,
error
);
if
(
error
!=
-
EAGAIN
)
{
if
(
block
)
nlmsvc_delete_block
(
block
,
0
);
up
(
&
file
->
f_sema
);
switch
(
-
error
)
{
switch
(
error
)
{
case
0
:
ret
=
nlm_granted
;
goto
out
;
case
EDEADLK
:
case
-
EAGAIN
:
break
;
case
-
EDEADLK
:
ret
=
nlm_deadlock
;
goto
out
;
default:
/* includes ENOLCK */
ret
=
nlm_lck_denied_nolocks
;
goto
out
;
}
}
if
(
!
wait
)
{
ret
=
nlm_lck_denied
;
goto
out_unlock
;
}
ret
=
nlm_lck_denied
;
if
(
!
wait
)
goto
out
;
ret
=
nlm_lck_blocked
;
if
(
block
!=
NULL
)
goto
out
;
/* If we don't have a block, create and initialize it. Then
* retry because we may have slept in kmalloc. */
/* We have to release f_sema as nlmsvc_create_block may try to
* to claim it while doing host garbage collection */
if
(
block
==
NULL
)
{
if
(
new
block
==
NULL
)
{
up
(
&
file
->
f_sema
);
dprintk
(
"lockd: blocking on this lock (allocating).
\n
"
);
if
(
!
(
block
=
nlmsvc_create_block
(
rqstp
,
file
,
lock
,
cookie
)))
if
(
!
(
new
block
=
nlmsvc_create_block
(
rqstp
,
file
,
lock
,
cookie
)))
return
nlm_lck_denied_nolocks
;
goto
again
;
}
/* Append to list of blocked */
nlmsvc_insert_block
(
block
,
NLM_NEVER
);
nlmsvc_insert_block
(
newblock
,
NLM_NEVER
);
newblock
=
NULL
;
ret
=
nlm_lck_blocked
;
out_unlock:
up
(
&
file
->
f_sema
);
out:
up
(
&
file
->
f_sema
);
if
(
newblock
!=
NULL
)
nlmsvc_delete_block
(
newblock
);
dprintk
(
"lockd: nlmsvc_lock returned %u
\n
"
,
ret
);
return
ret
;
}
...
...
@@ -445,7 +451,7 @@ nlmsvc_cancel_blocked(struct nlm_file *file, struct nlm_lock *lock)
down
(
&
file
->
f_sema
);
if
((
block
=
nlmsvc_lookup_block
(
file
,
lock
,
1
))
!=
NULL
)
status
=
nlmsvc_delete_block
(
block
,
1
);
status
=
nlmsvc_delete_block
(
block
);
up
(
&
file
->
f_sema
);
return
status
?
nlm_lck_denied
:
nlm_granted
;
}
...
...
@@ -519,7 +525,11 @@ nlmsvc_grant_blocked(struct nlm_block *block)
}
/* Try the lock operation again */
posix_unblock_lock
(
file
->
f_file
,
&
lock
->
fl
);
lock
->
fl
.
fl_flags
|=
FL_SLEEP
;
error
=
posix_lock_file
(
file
->
f_file
,
&
lock
->
fl
);
lock
->
fl
.
fl_flags
&=
~
FL_SLEEP
;
switch
(
error
)
{
case
0
:
break
;
...
...
@@ -630,11 +640,8 @@ nlmsvc_grant_reply(struct svc_rqst *rqstp, struct nlm_cookie *cookie, u32 status
}
else
{
/* Lock is now held by client, or has been rejected.
* In both cases, the block should be removed. */
nlmsvc_delete_block
(
block
);
up
(
&
file
->
f_sema
);
if
(
status
==
NLM_LCK_GRANTED
)
nlmsvc_delete_block
(
block
,
0
);
else
nlmsvc_delete_block
(
block
,
1
);
}
}
nlm_release_file
(
file
);
...
...
@@ -661,7 +668,7 @@ nlmsvc_retry_blocked(void)
dprintk
(
"nlmsvc_retry_blocked(%p, when=%ld, done=%d)
\n
"
,
block
,
block
->
b_when
,
block
->
b_done
);
if
(
block
->
b_done
)
nlmsvc_delete_block
(
block
,
0
);
nlmsvc_delete_block
(
block
);
else
nlmsvc_grant_blocked
(
block
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录