Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
9dc6c806
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
160
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9dc6c806
编写于
4月 17, 2015
作者:
C
Christoph Hellwig
提交者:
Jens Axboe
5月 05, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
nbd: stop using req->cmd
Signed-off-by:
N
Christoph Hellwig
<
hch@lst.de
>
Signed-off-by:
N
Jens Axboe
<
axboe@fb.com
>
上级
a7928c15
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
23 addition
and
27 deletion
+23
-27
drivers/block/nbd.c
drivers/block/nbd.c
+23
-25
include/uapi/linux/nbd.h
include/uapi/linux/nbd.h
+0
-2
未找到文件。
drivers/block/nbd.c
浏览文件 @
9dc6c806
...
...
@@ -230,29 +230,40 @@ static int nbd_send_req(struct nbd_device *nbd, struct request *req)
int
result
,
flags
;
struct
nbd_request
request
;
unsigned
long
size
=
blk_rq_bytes
(
req
);
u32
type
;
if
(
req
->
cmd_type
==
REQ_TYPE_DRV_PRIV
)
type
=
NBD_CMD_DISC
;
else
if
(
req
->
cmd_flags
&
REQ_DISCARD
)
type
=
NBD_CMD_TRIM
;
else
if
(
req
->
cmd_flags
&
REQ_FLUSH
)
type
=
NBD_CMD_FLUSH
;
else
if
(
rq_data_dir
(
req
)
==
WRITE
)
type
=
NBD_CMD_WRITE
;
else
type
=
NBD_CMD_READ
;
memset
(
&
request
,
0
,
sizeof
(
request
));
request
.
magic
=
htonl
(
NBD_REQUEST_MAGIC
);
request
.
type
=
htonl
(
nbd_cmd
(
req
));
if
(
nbd_cmd
(
req
)
!=
NBD_CMD_FLUSH
&&
nbd_cmd
(
req
)
!=
NBD_CMD_DISC
)
{
request
.
type
=
htonl
(
type
);
if
(
type
!=
NBD_CMD_FLUSH
&&
type
!=
NBD_CMD_DISC
)
{
request
.
from
=
cpu_to_be64
((
u64
)
blk_rq_pos
(
req
)
<<
9
);
request
.
len
=
htonl
(
size
);
}
memcpy
(
request
.
handle
,
&
req
,
sizeof
(
req
));
dev_dbg
(
nbd_to_dev
(
nbd
),
"request %p: sending control (%s@%llu,%uB)
\n
"
,
req
,
nbdcmd_to_ascii
(
nbd_cmd
(
req
)
),
req
,
nbdcmd_to_ascii
(
type
),
(
unsigned
long
long
)
blk_rq_pos
(
req
)
<<
9
,
blk_rq_bytes
(
req
));
result
=
sock_xmit
(
nbd
,
1
,
&
request
,
sizeof
(
request
),
(
nbd_cmd
(
req
)
==
NBD_CMD_WRITE
)
?
MSG_MORE
:
0
);
(
type
==
NBD_CMD_WRITE
)
?
MSG_MORE
:
0
);
if
(
result
<=
0
)
{
dev_err
(
disk_to_dev
(
nbd
->
disk
),
"Send control failed (result %d)
\n
"
,
result
);
return
-
EIO
;
}
if
(
nbd_cmd
(
req
)
==
NBD_CMD_WRITE
)
{
if
(
type
==
NBD_CMD_WRITE
)
{
struct
req_iterator
iter
;
struct
bio_vec
bvec
;
/*
...
...
@@ -352,7 +363,7 @@ static struct request *nbd_read_stat(struct nbd_device *nbd)
}
dev_dbg
(
nbd_to_dev
(
nbd
),
"request %p: got reply
\n
"
,
req
);
if
(
nbd_cmd
(
req
)
==
NBD_CMD_READ
)
{
if
(
rq_data_dir
(
req
)
!=
WRITE
)
{
struct
req_iterator
iter
;
struct
bio_vec
bvec
;
...
...
@@ -452,24 +463,12 @@ static void nbd_handle_req(struct nbd_device *nbd, struct request *req)
if
(
req
->
cmd_type
!=
REQ_TYPE_FS
)
goto
error_out
;
nbd_cmd
(
req
)
=
NBD_CMD_READ
;
if
(
rq_data_dir
(
req
)
==
WRITE
)
{
if
((
req
->
cmd_flags
&
REQ_DISCARD
))
{
WARN_ON
(
!
(
nbd
->
flags
&
NBD_FLAG_SEND_TRIM
));
nbd_cmd
(
req
)
=
NBD_CMD_TRIM
;
}
else
nbd_cmd
(
req
)
=
NBD_CMD_WRITE
;
if
(
nbd
->
flags
&
NBD_FLAG_READ_ONLY
)
{
if
(
rq_data_dir
(
req
)
==
WRITE
&&
(
nbd
->
flags
&
NBD_FLAG_READ_ONLY
))
{
dev_err
(
disk_to_dev
(
nbd
->
disk
),
"Write on read-only
\n
"
);
goto
error_out
;
}
}
if
(
req
->
cmd_flags
&
REQ_FLUSH
)
{
BUG_ON
(
unlikely
(
blk_rq_sectors
(
req
)));
nbd_cmd
(
req
)
=
NBD_CMD_FLUSH
;
}
req
->
errors
=
0
;
...
...
@@ -593,7 +592,6 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
mutex_lock
(
&
nbd
->
tx_lock
);
blk_rq_init
(
NULL
,
&
sreq
);
sreq
.
cmd_type
=
REQ_TYPE_DRV_PRIV
;
nbd_cmd
(
&
sreq
)
=
NBD_CMD_DISC
;
/* Check again after getting mutex back. */
if
(
!
nbd
->
sock
)
...
...
include/uapi/linux/nbd.h
浏览文件 @
9dc6c806
...
...
@@ -44,8 +44,6 @@ enum {
/* there is a gap here to match userspace */
#define NBD_FLAG_SEND_TRIM (1 << 5)
/* send trim/discard */
#define nbd_cmd(req) ((req)->cmd[0])
/* userspace doesn't need the nbd_device structure */
/* These are sent over the network in the request/reply magic fields */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录