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
529ba807
Commit
529ba807
authored
Oct 05, 2002
by
Alexander Viro
Committed by
Linus Torvalds
Oct 05, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] nbd switched to alloc_disk()
parent
f53197de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
8 deletions
+23
-8
drivers/block/nbd.c
drivers/block/nbd.c
+22
-7
include/linux/nbd.h
include/linux/nbd.h
+1
-1
No files found.
drivers/block/nbd.c
View file @
529ba807
...
...
@@ -444,15 +444,15 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
temp
>>=
1
;
}
nbd_bytesizes
[
dev
]
&=
~
(
nbd_blksizes
[
dev
]
-
1
);
set_capacity
(
&
lo
->
disk
,
nbd_bytesizes
[
dev
]
>>
9
);
set_capacity
(
lo
->
disk
,
nbd_bytesizes
[
dev
]
>>
9
);
return
0
;
case
NBD_SET_SIZE
:
nbd_bytesizes
[
dev
]
=
arg
&
~
(
nbd_blksizes
[
dev
]
-
1
);
set_capacity
(
&
lo
->
disk
,
nbd_bytesizes
[
dev
]
>>
9
);
set_capacity
(
lo
->
disk
,
nbd_bytesizes
[
dev
]
>>
9
);
return
0
;
case
NBD_SET_SIZE_BLOCKS
:
nbd_bytesizes
[
dev
]
=
((
u64
)
arg
)
<<
nbd_blksize_bits
[
dev
];
set_capacity
(
&
lo
->
disk
,
nbd_bytesizes
[
dev
]
>>
9
);
set_capacity
(
lo
->
disk
,
nbd_bytesizes
[
dev
]
>>
9
);
return
0
;
case
NBD_DO_IT
:
if
(
!
lo
->
file
)
...
...
@@ -498,6 +498,7 @@ static struct block_device_operations nbd_fops =
static
int
__init
nbd_init
(
void
)
{
int
err
=
-
ENOMEM
;
int
i
;
if
(
sizeof
(
struct
nbd_request
)
!=
28
)
{
...
...
@@ -505,17 +506,25 @@ static int __init nbd_init(void)
return
-
EIO
;
}
for
(
i
=
0
;
i
<
MAX_NBD
;
i
++
)
{
struct
gendisk
*
disk
=
alloc_disk
();
if
(
!
disk
)
goto
out
;
nbd_dev
[
i
].
disk
=
disk
;
}
if
(
register_blkdev
(
MAJOR_NR
,
"nbd"
,
&
nbd_fops
))
{
printk
(
"Unable to get major number %d for NBD
\n
"
,
MAJOR_NR
);
return
-
EIO
;
err
=
-
EIO
;
goto
out
;
}
#ifdef MODULE
printk
(
"nbd: registered device at major %d
\n
"
,
MAJOR_NR
);
#endif
blk_init_queue
(
BLK_DEFAULT_QUEUE
(
MAJOR_NR
),
do_nbd_request
,
&
nbd_lock
);
for
(
i
=
0
;
i
<
MAX_NBD
;
i
++
)
{
struct
gendisk
*
disk
=
&
nbd_dev
[
i
].
disk
;
struct
gendisk
*
disk
=
nbd_dev
[
i
].
disk
;
nbd_dev
[
i
].
refcnt
=
0
;
nbd_dev
[
i
].
file
=
NULL
;
nbd_dev
[
i
].
magic
=
LO_MAGIC
;
...
...
@@ -541,13 +550,19 @@ static int __init nbd_init(void)
&
nbd_fops
,
NULL
);
return
0
;
out:
while
(
i
--
)
put_disk
(
nbd_dev
[
i
].
disk
);
return
err
;
}
static
void
__exit
nbd_cleanup
(
void
)
{
int
i
;
for
(
i
=
0
;
i
<
MAX_NBD
;
i
++
)
del_gendisk
(
&
nbd_dev
[
i
].
disk
);
for
(
i
=
0
;
i
<
MAX_NBD
;
i
++
)
{
del_gendisk
(
nbd_dev
[
i
].
disk
);
put_disk
(
nbd_dev
[
i
].
disk
);
}
devfs_unregister
(
devfs_handle
);
blk_cleanup_queue
(
BLK_DEFAULT_QUEUE
(
MAJOR_NR
));
...
...
include/linux/nbd.h
View file @
529ba807
...
...
@@ -79,7 +79,7 @@ struct nbd_device {
spinlock_t
queue_lock
;
struct
list_head
queue_head
;
/* Requests are added here... */
struct
semaphore
tx_lock
;
struct
gendisk
disk
;
struct
gendisk
*
disk
;
};
#endif
...
...
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