Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
e2511578
Commit
e2511578
authored
Mar 05, 2014
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
switch nbd to sockfd_lookup/sockfd_put
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
09aaacf0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
31 deletions
+20
-31
drivers/block/nbd.c
drivers/block/nbd.c
+19
-29
include/linux/nbd.h
include/linux/nbd.h
+1
-2
No files found.
drivers/block/nbd.c
View file @
e2511578
...
@@ -630,37 +630,29 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
...
@@ -630,37 +630,29 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
}
}
case
NBD_CLEAR_SOCK
:
{
case
NBD_CLEAR_SOCK
:
{
struct
file
*
file
;
struct
socket
*
sock
=
nbd
->
sock
;
nbd
->
sock
=
NULL
;
nbd
->
sock
=
NULL
;
file
=
nbd
->
file
;
nbd
->
file
=
NULL
;
nbd_clear_que
(
nbd
);
nbd_clear_que
(
nbd
);
BUG_ON
(
!
list_empty
(
&
nbd
->
queue_head
));
BUG_ON
(
!
list_empty
(
&
nbd
->
queue_head
));
BUG_ON
(
!
list_empty
(
&
nbd
->
waiting_queue
));
BUG_ON
(
!
list_empty
(
&
nbd
->
waiting_queue
));
kill_bdev
(
bdev
);
kill_bdev
(
bdev
);
if
(
file
)
if
(
sock
)
fput
(
file
);
sockfd_put
(
sock
);
return
0
;
return
0
;
}
}
case
NBD_SET_SOCK
:
{
case
NBD_SET_SOCK
:
{
struct
file
*
file
;
struct
socket
*
sock
;
if
(
nbd
->
file
)
int
err
;
if
(
nbd
->
sock
)
return
-
EBUSY
;
return
-
EBUSY
;
file
=
fget
(
arg
);
sock
=
sockfd_lookup
(
arg
,
&
err
);
if
(
file
)
{
if
(
sock
)
{
struct
inode
*
inode
=
file_inode
(
file
);
nbd
->
sock
=
sock
;
if
(
S_ISSOCK
(
inode
->
i_mode
))
{
if
(
max_part
>
0
)
nbd
->
file
=
file
;
bdev
->
bd_invalidated
=
1
;
nbd
->
sock
=
SOCKET_I
(
inode
);
nbd
->
disconnect
=
0
;
/* we're connected now */
if
(
max_part
>
0
)
return
0
;
bdev
->
bd_invalidated
=
1
;
nbd
->
disconnect
=
0
;
/* we're connected now */
return
0
;
}
else
{
fput
(
file
);
}
}
}
return
-
EINVAL
;
return
-
EINVAL
;
}
}
...
@@ -697,12 +689,12 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
...
@@ -697,12 +689,12 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
case
NBD_DO_IT
:
{
case
NBD_DO_IT
:
{
struct
task_struct
*
thread
;
struct
task_struct
*
thread
;
struct
file
*
file
;
struct
socket
*
sock
;
int
error
;
int
error
;
if
(
nbd
->
pid
)
if
(
nbd
->
pid
)
return
-
EBUSY
;
return
-
EBUSY
;
if
(
!
nbd
->
file
)
if
(
!
nbd
->
sock
)
return
-
EINVAL
;
return
-
EINVAL
;
mutex_unlock
(
&
nbd
->
tx_lock
);
mutex_unlock
(
&
nbd
->
tx_lock
);
...
@@ -731,15 +723,15 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
...
@@ -731,15 +723,15 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
if
(
error
)
if
(
error
)
return
error
;
return
error
;
sock_shutdown
(
nbd
,
0
);
sock_shutdown
(
nbd
,
0
);
file
=
nbd
->
file
;
sock
=
nbd
->
sock
;
nbd
->
file
=
NULL
;
nbd
->
sock
=
NULL
;
nbd_clear_que
(
nbd
);
nbd_clear_que
(
nbd
);
dev_warn
(
disk_to_dev
(
nbd
->
disk
),
"queue cleared
\n
"
);
dev_warn
(
disk_to_dev
(
nbd
->
disk
),
"queue cleared
\n
"
);
kill_bdev
(
bdev
);
kill_bdev
(
bdev
);
queue_flag_clear_unlocked
(
QUEUE_FLAG_DISCARD
,
nbd
->
disk
->
queue
);
queue_flag_clear_unlocked
(
QUEUE_FLAG_DISCARD
,
nbd
->
disk
->
queue
);
set_device_ro
(
bdev
,
false
);
set_device_ro
(
bdev
,
false
);
if
(
file
)
if
(
sock
)
fput
(
file
);
sockfd_put
(
sock
);
nbd
->
flags
=
0
;
nbd
->
flags
=
0
;
nbd
->
bytesize
=
0
;
nbd
->
bytesize
=
0
;
bdev
->
bd_inode
->
i_size
=
0
;
bdev
->
bd_inode
->
i_size
=
0
;
...
@@ -875,9 +867,7 @@ static int __init nbd_init(void)
...
@@ -875,9 +867,7 @@ static int __init nbd_init(void)
for
(
i
=
0
;
i
<
nbds_max
;
i
++
)
{
for
(
i
=
0
;
i
<
nbds_max
;
i
++
)
{
struct
gendisk
*
disk
=
nbd_dev
[
i
].
disk
;
struct
gendisk
*
disk
=
nbd_dev
[
i
].
disk
;
nbd_dev
[
i
].
file
=
NULL
;
nbd_dev
[
i
].
magic
=
NBD_MAGIC
;
nbd_dev
[
i
].
magic
=
NBD_MAGIC
;
nbd_dev
[
i
].
flags
=
0
;
INIT_LIST_HEAD
(
&
nbd_dev
[
i
].
waiting_queue
);
INIT_LIST_HEAD
(
&
nbd_dev
[
i
].
waiting_queue
);
spin_lock_init
(
&
nbd_dev
[
i
].
queue_lock
);
spin_lock_init
(
&
nbd_dev
[
i
].
queue_lock
);
INIT_LIST_HEAD
(
&
nbd_dev
[
i
].
queue_head
);
INIT_LIST_HEAD
(
&
nbd_dev
[
i
].
queue_head
);
...
...
include/linux/nbd.h
View file @
e2511578
...
@@ -24,8 +24,7 @@ struct request;
...
@@ -24,8 +24,7 @@ struct request;
struct
nbd_device
{
struct
nbd_device
{
int
flags
;
int
flags
;
int
harderror
;
/* Code of hard error */
int
harderror
;
/* Code of hard error */
struct
socket
*
sock
;
struct
socket
*
sock
;
/* If == NULL, device is not ready, yet */
struct
file
*
file
;
/* If == NULL, device is not ready, yet */
int
magic
;
int
magic
;
spinlock_t
queue_lock
;
spinlock_t
queue_lock
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment