Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
e2511578
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看板
提交
e2511578
编写于
3月 05, 2014
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
switch nbd to sockfd_lookup/sockfd_put
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
09aaacf0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
31 deletion
+20
-31
drivers/block/nbd.c
drivers/block/nbd.c
+19
-29
include/linux/nbd.h
include/linux/nbd.h
+1
-2
未找到文件。
drivers/block/nbd.c
浏览文件 @
e2511578
...
...
@@ -630,37 +630,29 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
}
case
NBD_CLEAR_SOCK
:
{
struct
file
*
file
;
struct
socket
*
sock
=
nbd
->
sock
;
nbd
->
sock
=
NULL
;
file
=
nbd
->
file
;
nbd
->
file
=
NULL
;
nbd_clear_que
(
nbd
);
BUG_ON
(
!
list_empty
(
&
nbd
->
queue_head
));
BUG_ON
(
!
list_empty
(
&
nbd
->
waiting_queue
));
kill_bdev
(
bdev
);
if
(
file
)
fput
(
file
);
if
(
sock
)
sockfd_put
(
sock
);
return
0
;
}
case
NBD_SET_SOCK
:
{
struct
file
*
file
;
if
(
nbd
->
file
)
struct
socket
*
sock
;
int
err
;
if
(
nbd
->
sock
)
return
-
EBUSY
;
file
=
fget
(
arg
);
if
(
file
)
{
struct
inode
*
inode
=
file_inode
(
file
);
if
(
S_ISSOCK
(
inode
->
i_mode
))
{
nbd
->
file
=
file
;
nbd
->
sock
=
SOCKET_I
(
inode
);
if
(
max_part
>
0
)
bdev
->
bd_invalidated
=
1
;
nbd
->
disconnect
=
0
;
/* we're connected now */
return
0
;
}
else
{
fput
(
file
);
}
sock
=
sockfd_lookup
(
arg
,
&
err
);
if
(
sock
)
{
nbd
->
sock
=
sock
;
if
(
max_part
>
0
)
bdev
->
bd_invalidated
=
1
;
nbd
->
disconnect
=
0
;
/* we're connected now */
return
0
;
}
return
-
EINVAL
;
}
...
...
@@ -697,12 +689,12 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
case
NBD_DO_IT
:
{
struct
task_struct
*
thread
;
struct
file
*
file
;
struct
socket
*
sock
;
int
error
;
if
(
nbd
->
pid
)
return
-
EBUSY
;
if
(
!
nbd
->
file
)
if
(
!
nbd
->
sock
)
return
-
EINVAL
;
mutex_unlock
(
&
nbd
->
tx_lock
);
...
...
@@ -731,15 +723,15 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
if
(
error
)
return
error
;
sock_shutdown
(
nbd
,
0
);
file
=
nbd
->
file
;
nbd
->
file
=
NULL
;
sock
=
nbd
->
sock
;
nbd
->
sock
=
NULL
;
nbd_clear_que
(
nbd
);
dev_warn
(
disk_to_dev
(
nbd
->
disk
),
"queue cleared
\n
"
);
kill_bdev
(
bdev
);
queue_flag_clear_unlocked
(
QUEUE_FLAG_DISCARD
,
nbd
->
disk
->
queue
);
set_device_ro
(
bdev
,
false
);
if
(
file
)
fput
(
file
);
if
(
sock
)
sockfd_put
(
sock
);
nbd
->
flags
=
0
;
nbd
->
bytesize
=
0
;
bdev
->
bd_inode
->
i_size
=
0
;
...
...
@@ -875,9 +867,7 @@ static int __init nbd_init(void)
for
(
i
=
0
;
i
<
nbds_max
;
i
++
)
{
struct
gendisk
*
disk
=
nbd_dev
[
i
].
disk
;
nbd_dev
[
i
].
file
=
NULL
;
nbd_dev
[
i
].
magic
=
NBD_MAGIC
;
nbd_dev
[
i
].
flags
=
0
;
INIT_LIST_HEAD
(
&
nbd_dev
[
i
].
waiting_queue
);
spin_lock_init
(
&
nbd_dev
[
i
].
queue_lock
);
INIT_LIST_HEAD
(
&
nbd_dev
[
i
].
queue_head
);
...
...
include/linux/nbd.h
浏览文件 @
e2511578
...
...
@@ -24,8 +24,7 @@ struct request;
struct
nbd_device
{
int
flags
;
int
harderror
;
/* Code of hard error */
struct
socket
*
sock
;
struct
file
*
file
;
/* If == NULL, device is not ready, yet */
struct
socket
*
sock
;
/* If == NULL, device is not ready, yet */
int
magic
;
spinlock_t
queue_lock
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录