Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
c9d8f89d
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看板
提交
c9d8f89d
编写于
4月 15, 2008
作者:
T
Trond Myklebust
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
NFS: Ensure that the write code cleans up properly when rpc_run_task() fails
Signed-off-by:
N
Trond Myklebust
<
Trond.Myklebust@netapp.com
>
上级
fdd1e74c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
73 addition
and
48 deletion
+73
-48
fs/nfs/direct.c
fs/nfs/direct.c
+28
-22
fs/nfs/write.c
fs/nfs/write.c
+43
-24
include/linux/nfs_fs.h
include/linux/nfs_fs.h
+2
-2
未找到文件。
fs/nfs/direct.c
浏览文件 @
c9d8f89d
...
...
@@ -508,27 +508,34 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
static
void
nfs_direct_commit_result
(
struct
rpc_task
*
task
,
void
*
calldata
)
{
struct
nfs_write_data
*
data
=
calldata
;
struct
nfs_direct_req
*
dreq
=
(
struct
nfs_direct_req
*
)
data
->
req
;
/* Call the NFS version-specific code */
if
(
NFS_PROTO
(
data
->
inode
)
->
commit_done
(
task
,
data
)
!=
0
)
return
;
if
(
unlikely
(
task
->
tk_status
<
0
))
{
NFS_PROTO
(
data
->
inode
)
->
commit_done
(
task
,
data
);
}
static
void
nfs_direct_commit_release
(
void
*
calldata
)
{
struct
nfs_write_data
*
data
=
calldata
;
struct
nfs_direct_req
*
dreq
=
(
struct
nfs_direct_req
*
)
data
->
req
;
int
status
=
data
->
task
.
tk_status
;
if
(
status
<
0
)
{
dprintk
(
"NFS: %5u commit failed with error %d.
\n
"
,
task
->
tk_pid
,
task
->
tk_
status
);
data
->
task
.
tk_pid
,
status
);
dreq
->
flags
=
NFS_ODIRECT_RESCHED_WRITES
;
}
else
if
(
memcmp
(
&
dreq
->
verf
,
&
data
->
verf
,
sizeof
(
data
->
verf
)))
{
dprintk
(
"NFS: %5u commit verify failed
\n
"
,
task
->
tk_pid
);
dprintk
(
"NFS: %5u commit verify failed
\n
"
,
data
->
task
.
tk_pid
);
dreq
->
flags
=
NFS_ODIRECT_RESCHED_WRITES
;
}
dprintk
(
"NFS: %5u commit returned %d
\n
"
,
task
->
tk_pid
,
task
->
tk_
status
);
dprintk
(
"NFS: %5u commit returned %d
\n
"
,
data
->
task
.
tk_pid
,
status
);
nfs_direct_write_complete
(
dreq
,
data
->
inode
);
nfs_commitdata_release
(
calldata
);
}
static
const
struct
rpc_call_ops
nfs_commit_direct_ops
=
{
.
rpc_call_done
=
nfs_direct_commit_result
,
.
rpc_release
=
nfs_commit_release
,
.
rpc_release
=
nfs_
direct_
commit_release
,
};
static
void
nfs_direct_commit_schedule
(
struct
nfs_direct_req
*
dreq
)
...
...
@@ -596,7 +603,7 @@ static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode
static
void
nfs_alloc_commit_data
(
struct
nfs_direct_req
*
dreq
)
{
dreq
->
commit_data
=
nfs_commit_alloc
();
dreq
->
commit_data
=
nfs_commit
data
_alloc
();
if
(
dreq
->
commit_data
!=
NULL
)
dreq
->
commit_data
->
req
=
(
struct
nfs_page
*
)
dreq
;
}
...
...
@@ -617,11 +624,20 @@ static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode
static
void
nfs_direct_write_result
(
struct
rpc_task
*
task
,
void
*
calldata
)
{
struct
nfs_write_data
*
data
=
calldata
;
struct
nfs_direct_req
*
dreq
=
(
struct
nfs_direct_req
*
)
data
->
req
;
int
status
=
task
->
tk_status
;
if
(
nfs_writeback_done
(
task
,
data
)
!=
0
)
return
;
}
/*
* NB: Return the value of the first error return code. Subsequent
* errors after the first one are ignored.
*/
static
void
nfs_direct_write_release
(
void
*
calldata
)
{
struct
nfs_write_data
*
data
=
calldata
;
struct
nfs_direct_req
*
dreq
=
(
struct
nfs_direct_req
*
)
data
->
req
;
int
status
=
data
->
task
.
tk_status
;
spin_lock
(
&
dreq
->
lock
);
...
...
@@ -643,23 +659,13 @@ static void nfs_direct_write_result(struct rpc_task *task, void *calldata)
break
;
case
NFS_ODIRECT_DO_COMMIT
:
if
(
memcmp
(
&
dreq
->
verf
,
&
data
->
verf
,
sizeof
(
dreq
->
verf
)))
{
dprintk
(
"NFS: %5u write verify failed
\n
"
,
task
->
tk_pid
);
dprintk
(
"NFS: %5u write verify failed
\n
"
,
data
->
task
.
tk_pid
);
dreq
->
flags
=
NFS_ODIRECT_RESCHED_WRITES
;
}
}
}
out_unlock:
spin_unlock
(
&
dreq
->
lock
);
}
/*
* NB: Return the value of the first error return code. Subsequent
* errors after the first one are ignored.
*/
static
void
nfs_direct_write_release
(
void
*
calldata
)
{
struct
nfs_write_data
*
data
=
calldata
;
struct
nfs_direct_req
*
dreq
=
(
struct
nfs_direct_req
*
)
data
->
req
;
if
(
put_dreq
(
dreq
))
nfs_direct_write_complete
(
dreq
,
data
->
inode
);
...
...
fs/nfs/write.c
浏览文件 @
c9d8f89d
...
...
@@ -48,7 +48,7 @@ static struct kmem_cache *nfs_wdata_cachep;
static
mempool_t
*
nfs_wdata_mempool
;
static
mempool_t
*
nfs_commit_mempool
;
struct
nfs_write_data
*
nfs_commit_alloc
(
void
)
struct
nfs_write_data
*
nfs_commit
data
_alloc
(
void
)
{
struct
nfs_write_data
*
p
=
mempool_alloc
(
nfs_commit_mempool
,
GFP_NOFS
);
...
...
@@ -973,7 +973,6 @@ static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata)
{
struct
nfs_write_data
*
data
=
calldata
;
struct
nfs_page
*
req
=
data
->
req
;
struct
page
*
page
=
req
->
wb_page
;
dprintk
(
"NFS: write (%s/%Ld %d@%Ld)"
,
req
->
wb_context
->
path
.
dentry
->
d_inode
->
i_sb
->
s_id
,
...
...
@@ -981,13 +980,20 @@ static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata)
req
->
wb_bytes
,
(
long
long
)
req_offset
(
req
));
if
(
nfs_writeback_done
(
task
,
data
)
!=
0
)
return
;
nfs_writeback_done
(
task
,
data
);
}
if
(
task
->
tk_status
<
0
)
{
static
void
nfs_writeback_release_partial
(
void
*
calldata
)
{
struct
nfs_write_data
*
data
=
calldata
;
struct
nfs_page
*
req
=
data
->
req
;
struct
page
*
page
=
req
->
wb_page
;
int
status
=
data
->
task
.
tk_status
;
if
(
status
<
0
)
{
nfs_set_pageerror
(
page
);
nfs_context_set_write_error
(
req
->
wb_context
,
task
->
tk_
status
);
dprintk
(
", error = %d
\n
"
,
task
->
tk_
status
);
nfs_context_set_write_error
(
req
->
wb_context
,
status
);
dprintk
(
", error = %d
\n
"
,
status
);
goto
out
;
}
...
...
@@ -1012,11 +1018,12 @@ static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata)
out:
if
(
atomic_dec_and_test
(
&
req
->
wb_complete
))
nfs_writepage_release
(
req
);
nfs_writedata_release
(
calldata
);
}
static
const
struct
rpc_call_ops
nfs_write_partial_ops
=
{
.
rpc_call_done
=
nfs_writeback_done_partial
,
.
rpc_release
=
nfs_write
data_release
,
.
rpc_release
=
nfs_write
back_release_partial
,
};
/*
...
...
@@ -1029,17 +1036,21 @@ static const struct rpc_call_ops nfs_write_partial_ops = {
static
void
nfs_writeback_done_full
(
struct
rpc_task
*
task
,
void
*
calldata
)
{
struct
nfs_write_data
*
data
=
calldata
;
struct
nfs_page
*
req
;
struct
page
*
page
;
if
(
nfs_writeback_done
(
task
,
data
)
!=
0
)
return
;
nfs_writeback_done
(
task
,
data
);
}
static
void
nfs_writeback_release_full
(
void
*
calldata
)
{
struct
nfs_write_data
*
data
=
calldata
;
int
status
=
data
->
task
.
tk_status
;
/* Update attributes as result of writeback. */
while
(
!
list_empty
(
&
data
->
pages
))
{
req
=
nfs_list_entry
(
data
->
pages
.
next
);
struct
nfs_page
*
req
=
nfs_list_entry
(
data
->
pages
.
next
);
struct
page
*
page
=
req
->
wb_page
;
nfs_list_remove_request
(
req
);
page
=
req
->
wb_page
;
dprintk
(
"NFS: write (%s/%Ld %d@%Ld)"
,
req
->
wb_context
->
path
.
dentry
->
d_inode
->
i_sb
->
s_id
,
...
...
@@ -1047,10 +1058,10 @@ static void nfs_writeback_done_full(struct rpc_task *task, void *calldata)
req
->
wb_bytes
,
(
long
long
)
req_offset
(
req
));
if
(
task
->
tk_
status
<
0
)
{
if
(
status
<
0
)
{
nfs_set_pageerror
(
page
);
nfs_context_set_write_error
(
req
->
wb_context
,
task
->
tk_
status
);
dprintk
(
", error = %d
\n
"
,
task
->
tk_
status
);
nfs_context_set_write_error
(
req
->
wb_context
,
status
);
dprintk
(
", error = %d
\n
"
,
status
);
goto
remove_request
;
}
...
...
@@ -1070,11 +1081,12 @@ static void nfs_writeback_done_full(struct rpc_task *task, void *calldata)
next:
nfs_clear_page_tag_locked
(
req
);
}
nfs_writedata_release
(
calldata
);
}
static
const
struct
rpc_call_ops
nfs_write_full_ops
=
{
.
rpc_call_done
=
nfs_writeback_done_full
,
.
rpc_release
=
nfs_write
data_release
,
.
rpc_release
=
nfs_write
back_release_full
,
};
...
...
@@ -1160,7 +1172,7 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)
#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
void
nfs_commit_release
(
void
*
data
)
void
nfs_commit
data
_release
(
void
*
data
)
{
struct
nfs_write_data
*
wdata
=
data
;
...
...
@@ -1233,7 +1245,7 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how)
struct
nfs_write_data
*
data
;
struct
nfs_page
*
req
;
data
=
nfs_commit_alloc
();
data
=
nfs_commit
data
_alloc
();
if
(
!
data
)
goto
out_bad
;
...
...
@@ -1261,7 +1273,6 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how)
static
void
nfs_commit_done
(
struct
rpc_task
*
task
,
void
*
calldata
)
{
struct
nfs_write_data
*
data
=
calldata
;
struct
nfs_page
*
req
;
dprintk
(
"NFS: %5u nfs_commit_done (status %d)
\n
"
,
task
->
tk_pid
,
task
->
tk_status
);
...
...
@@ -1269,6 +1280,13 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)
/* Call the NFS version-specific code */
if
(
NFS_PROTO
(
data
->
inode
)
->
commit_done
(
task
,
data
)
!=
0
)
return
;
}
static
void
nfs_commit_release
(
void
*
calldata
)
{
struct
nfs_write_data
*
data
=
calldata
;
struct
nfs_page
*
req
;
int
status
=
data
->
task
.
tk_status
;
while
(
!
list_empty
(
&
data
->
pages
))
{
req
=
nfs_list_entry
(
data
->
pages
.
next
);
...
...
@@ -1283,10 +1301,10 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)
(
long
long
)
NFS_FILEID
(
req
->
wb_context
->
path
.
dentry
->
d_inode
),
req
->
wb_bytes
,
(
long
long
)
req_offset
(
req
));
if
(
task
->
tk_
status
<
0
)
{
nfs_context_set_write_error
(
req
->
wb_context
,
task
->
tk_
status
);
if
(
status
<
0
)
{
nfs_context_set_write_error
(
req
->
wb_context
,
status
);
nfs_inode_remove_request
(
req
);
dprintk
(
", error = %d
\n
"
,
task
->
tk_
status
);
dprintk
(
", error = %d
\n
"
,
status
);
goto
next
;
}
...
...
@@ -1307,6 +1325,7 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)
next:
nfs_clear_page_tag_locked
(
req
);
}
nfs_commitdata_release
(
calldata
);
}
static
const
struct
rpc_call_ops
nfs_commit_ops
=
{
...
...
include/linux/nfs_fs.h
浏览文件 @
c9d8f89d
...
...
@@ -466,9 +466,9 @@ extern int nfs_wb_page(struct inode *inode, struct page* page);
extern
int
nfs_wb_page_cancel
(
struct
inode
*
inode
,
struct
page
*
page
);
#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
extern
int
nfs_commit_inode
(
struct
inode
*
,
int
);
extern
struct
nfs_write_data
*
nfs_commit_alloc
(
void
);
extern
struct
nfs_write_data
*
nfs_commit
data
_alloc
(
void
);
extern
void
nfs_commit_free
(
struct
nfs_write_data
*
wdata
);
extern
void
nfs_commit_release
(
void
*
wdata
);
extern
void
nfs_commit
data
_release
(
void
*
wdata
);
#else
static
inline
int
nfs_commit_inode
(
struct
inode
*
inode
,
int
how
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录